Skip to content

Allow exit failure only on specified severities #3926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

ImprintNav
Copy link

@ImprintNav ImprintNav commented Jun 27, 2023

Summary

Allow golangci-lint runs to exit with failed statuses only on specified issue severities

Fixes #1981

Details

  • Define severity.fail-on-severities string slice config option as well as --fail-on-severities string slice command
    line option
  • When this option is empty or nil (default value), keep behavior identical to current behavior
  • When this option is not empty, only exit with an "issues found" code when at least one issue's severity matches one of
    values specified in the option

Notes / Concerns

  • This implementation requires an explicit list of all codes resulting in failures; there is no "minimum cutoff" logic
    e.g. fail on warnings and above. A more sophisticated solution would need to establish total orderings of error
    severities across each output format and possibly across output formats, which is annoying to maintain and may
    confuse users.
  • An empty config list is more strict than nonempty config lists, but larger config lists are more strict than smaller
    nonempty config lists; this is not that hard to fathom for users, since never exiting with a failed code is not too
    useful.
  • Mixing config files with command line flags will merge the lists of exit codes upon which to fail; this can be a bit
    counterintuitive for the above reason.

Testing

  • Add special test cases for the following cases
    • Info and warning issues with a config that fails on errors will result in a successful exit code
    • Info and warning issues with a config that fails on errors and warnings will result in a failed exit code
    • Info and warning issues with a config that fails on errors + a command line flag that fails on errors and
      warnings will fail

@boring-cyborg
Copy link

boring-cyborg bot commented Jun 27, 2023

Hey, thank you for opening your first Pull Request !

@CLAassistant
Copy link

CLAassistant commented Jun 27, 2023

CLA assistant check
All committers have signed the CLA.

@ldez ldez changed the title (Resolves #1981) Allow exit failure only on specified severities Allow exit failure only on specified severities Jun 27, 2023
@ldez ldez self-requested a review June 27, 2023 09:07
@ldez ldez added the blocked Need's direct action from maintainer label Jun 27, 2023
@ldez
Copy link
Member

ldez commented Jun 27, 2023

@ImprintNav
Copy link
Author

#2595 (comment)

#3184 (comment)

It seems I misread previous discussions. That's a shame. Now we'll need multiple configurations to continue using the golangci-lint action or switch to a different action. We can't highlight deprecated code in editors like VSCode without breaking builds on deprecated code otherwise.

@ImprintNav ImprintNav closed this Jun 27, 2023
@ldez ldez added area: severity declined and removed blocked Need's direct action from maintainer labels Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

golangci-lint cli returning non-zero value for issues raised at a severity level not of error
3 participants