Skip to content
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

Is it possible for revive to return a non-zero exit code when there are issues and zero if not? #241

Closed
inliquid opened this issue Oct 17, 2019 · 9 comments

Comments

@inliquid
Copy link

I'd like to run revive in some sort of automated test during build. However I found that it returns zero in any case. This makes it more complicated to check result of running the tool.

@chavacava
Copy link
Collaborator

chavacava commented Oct 17, 2019

Hi @inliquid, in the configuration you can set errorCode and warningCode to the values you need.

For example with

# Sets the error code for failures with severity "error"
errorCode = 2
# Sets the error code for failures with severity "warning"
warningCode = 1

revive will return 2 if it found at least one error, 1 if there are no errors but at least one warning, or 0 if there are no errors nor warnings.

@mgechev mgechev closed this as completed Oct 17, 2019
@mgechev
Copy link
Owner

mgechev commented Oct 17, 2019

@inliquid I'm closing the issue. Feel free to comment/open a new issue in case we misunderstood you.

@jan-xyz
Copy link
Contributor

jan-xyz commented Oct 7, 2021

The above example overwrites also the linter configuration, so having a file with just that content also disables all the linters. Is there a way to say: "lint as usual and per default but exit 1 if there was a problem"?

@chavacava
Copy link
Collaborator

@jan-xyz the above example is NOT a full configuration, just the lines you need to modify in order to get error codes when the linter finds issues.

@jan-xyz
Copy link
Contributor

jan-xyz commented Oct 7, 2021

I understand that. Before I was running revive without a config though, now by adding the exit codes I need to specify a full config, and I am curious if the list of linter default rules will change in the future and I will miss those new rules?

@chavacava
Copy link
Collaborator

I get your point @jan-xyz.
The default rules will not be updated, they correspond to these of golint (now frozen)
If you want to continue using revive without a configuration you can rely on some bash hacks to get an error code when failures are found.
golint finished adding a flag (set_exit_status) to return 1 if failures are found. We might consider adding this flag to revive (that is meant to be a drop-in replacement of golint)

@jan-xyz
Copy link
Contributor

jan-xyz commented Oct 9, 2021

That would be my favorite solution 🤗 I would also offer to provide the PR for it, if you are ok with adding it

@chavacava
Copy link
Collaborator

I would also offer to provide the PR for it, if you are ok with adding it

PRs are welcome!

@jan-xyz
Copy link
Contributor

jan-xyz commented Oct 10, 2021

I filed #589 , let me know what you think 🤗

mihaitodor added a commit to mihaitodor/franz-go that referenced this issue Mar 9, 2025
Note: You can use `golangci-lint config verify` to check if the
`.golangci.yml` config matches the published schema.

- `tenv` has been deprecated in favour of `usetesting`
- `allow-leading-space` has been removed from `nolintlint`: golangci/golangci-lint#3063
- `revive` doesn't have `error-code` `warning-code` as config
options (see https://golangci-lint.run/usage/linters/#revive).
There's some discussion mgechev/revive#241
about adding `set_exit_status` to `revive`, but it's not exposed
via `golangci-lint`

Signed-off-by: Mihai Todor <todormihai@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants