-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
PoC: Add Severity Levels, use it to return zero exit code #3184
base: master
Are you sure you want to change the base?
Conversation
Hey, thank you for opening your first Pull Request ! |
9a60153
to
4f234cc
Compare
@ldez I've seen these discussions, but issues are still, so I decided to take a chance and purpose my solution. So, do I understand correctly that
means that there will be no any work done on this matter any time soon and we should try to find alternative solutions if we want to ignore issues that should not result with non-zero code? |
As I said, the decision was made not to correlate severity and exit code, for me nothing changed. For me, it's useless to create a lint report just to ignore it, the correlation between severity and exit code is a bad historical way to manage linting: it's like you write tests but you want to exit 0 even if the tests are failing. If you want to ignore/skip reports you can read this page: https://golangci-lint.run/usage/false-positives/ |
@ldez But maybe you can give and advice, how we can approach out problem? We want to add some linter and we want to give some time to developers to fix it, having some clear indication that this problem exits. But as we don't want to enforce it right away, we don't want to it to break pipelines on non-zero code. That's the reasoning behind my intentions hack this part. What will be the best approach from your perspective? Thank you! |
I'm torn but I think I mostly agree with @ldez. Now that we have severity, I can kinda see why you would want to filter them out. Also judging by #1981 (comment) Personally I also think that it's a somewhat odd requirement to ask for the reports and then ignoring them, it's like running I don't really remember the historical reasons to support severity and even less memory about discussions where we decided to not add support to match it with exit codes. Given that we actually did a change regarding exit codes pretty recently in #2357 and that this seems to be a request from several people I would be open to reconsider this and add support for this. |
I would start by using The people that would then iteratively fix old issues could run a different config file that is more strict and fail on these issues, then you can pick this config by using This probably doesn't solve your issue but maybe it could inspire a workflow that suits you. |
Why would you want to add a linter but wait to fix its reports? I think the approach explained by @bombsimon with |
Dummy simple reason — we want to "flash in face" the soon-to-be-errors in the pipeline logs, so it would be visible in case someone will check it or will try to read other linter problems, but not failing the whole. Yes, totally agree, @bombsimon approach sounds really good! We also considering creating separate task in the pipeline with the future version of lint config, that won't be blocking anything and later will just swap it with the main task. Thank you for your time and help, guys! |
Ref: #1981 (comment) for a full outline of the reasoning with citations of examples used elsewhere (thus an expectation of the ability in the software engineering space more broadly). IMHO a severity level implies the ability to filter on the severity level for linting issues. I'm supportive of the change(s) as proposed here. They don't detract from the existing use cases, but allow for additional support as outlined as a requirement. In the absence I would support the removal of severity levels for linting issues as its a binary as to whether or not a linting run will be considered "passed" under the current implementation. |
@ldez What's the reasoning for having severity levels if the tool provides no means of treating them differently in terms of CI success or run-time filtering? If everything is blocked at the CI level, you might as well make everything an error. We don't have "warnings" or "info" for unit tests either precisely because we don't want to filter out unit test failures by severity level. |
Hi, In my opinion it makes sens to be able to keep a zero exit code despite having warning, it doesn't mean dismissing the linter report, only that we can keep working until it's fixed. |
You can configure # ...
linters-settings:
godox:
keywords:
- FIXME
# ... You will have 2 levels:
I will add an element: the goal of golangci-lint has always been to reduce and not report false positives. golangci-lint tries to provide the most effective information, non-blocking reports are the opposite of that. |
I'd love to see something like this go in. The reason for this is that I want godox to leave annotations for A good alternative might however be to default to non-zero exit codes for everything and allow users to explicitly set it i.e. severity:
default-severity: error
rules:
- linters:
- godox
severity: warning
exit-code: 0 |
Hi!
This is my Proof-of-Concept of how it could be possible to approach problem with non-zero exit codes on issues with non-error level.
I've tested it on very simple severity config:
Running with
golangci-lint run ./... && echo $?
in my project with several missingt.Parallel()
.I don't insist it is final or ideal, just my view on how it could be done.
What do you think, guys?
Solves #1981