Skip to content

Bug Report: code bug, check err !=nil but return a nil value error e #1961

@alingse

Description

@alingse

I create a linter to detect code that returns a non-relevant nilness error bug. I checked the top 1000 GitHub Go repositories and found this, all result listed in alingse/sundrylint#4

this project output was this.
https://github.com/alingse/sundrylint/actions/runs/12331397347

providers/okta/app_signon_policy_rule.go#L80 return a error variable but it's nil
providers/okta/authorization_server.go#L54 return a error variable but it's nil
providers/okta/event_hook.go#L48 return a error variable but it's nil
providers/okta/group.go#L50 return a error variable but it's nil
providers/okta/group_rule.go#L48 return a error variable but it's nil
providers/okta/inline_hook.go#L48 return a error variable but it's nil
providers/okta/policy_rule_mfa.go#L80 return a error variable but it's nil
providers/okta/policy_rule_password.go#L80 return a error variable but it's nil
providers/okta/policy_rule_signon.go#L80 return a error variable but it's nil
providers/okta/template_sms.go#L48 return a error variable but it's nil
providers/okta/trusted_origin.go#L48 return a error variable but it's nil
providers/okta/user.go#L48 return a error variable but it's nil
providers/okta/user_type.go#L48 return a error variable but it's nil

It's all one style code

ctx, client, e := g.Client()
	if e != nil {
		return e
	}

	output, err := getAuthorizationServers(ctx, client)
	if err != nil {
		return e // which should be err
	}

the e is already be nil, and return as a error,

🤔, see #1000

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions