-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
Make CLI not to return non-zero exist code when only warnings occur #368
Comments
I’m open to something along these lines, but not exactly what ESLint does. I think number of warnings is arbitrary, if you’re asking for feedback on your specs and you get some then you should fix it, and if you don’t like what feedback you’re getting use skip, make a custom ruleset, or extend the default ruleset to change the severity of a specific rule. With that said, can you think of a switch? —error-only or something? |
@philsturgeon |
I mildly favor a boolean-style flag vs tracking how many warnings trigger an error. It's lower-complexity, and also I am skeptical of the use case where 3 warnings is ok, but 4 is an error. |
I prefer a Boolean flag too but —ignore-warnings could be a tad confusing. We’re not ignoring them, just not failing the run if we see them. Ignoring might be closer to #381. Should these two features perhaps be the same feature? We could have —severity=error and it will only show errors, and only fail if errors come back. —severity=warm would show warnings and errors, and fail if either came back. —severity=info would show info, warnings, errors, and fail if... info came back? Or warnings/errors? Not sure on the last one. |
There could be two switches, —fail-severity=warn —severity=info First is where it fails, second is what it shows. Both have same defaults they have now. |
I had a look to some other tools on the market that deal with the same situation; mscpp (Microsoft's C/C++ compiler) has a dedicated flag ( |
We can currently specify which warnings should be treated as errors with ruleset extension and changing the severity level in the ruleset file. This might be a slightly different thing? |
Yeah, but still there's an option on the compiler itself to treat all the warnings as errors. I've also checked out GCC, and they do basically the same thing. |
Right, you were saying two things and I replied to one of the things :D
We got that bit covered already.
Converting all warnings into errors is essentially what we are currently doing, as we return a failure status code if we spot a warning. The requester is asking for an option to do the opposite. Does mscapp or GCC have that? Also im not sure compilers are the closest comparison, maybe other linting tools would be more similar. I like Rubocop for example. They have a similar two switch approach that I was hinting towards pre-coffee:
|
|
Ok so we have two possible approaches so far:
|
Though you all prefer boolean flag, let me share my use case of ESLint Linter wasn't used in my team from day 0. When I introduced it we already had tens of projects and their quality was no so good. You can imagine that the linter reported a large number of errors and warnings. I forced the team to fix errors immediately but the project schedule won't allow us to spend too much time to fix all warnings -- I had carefully define the ruleset to limit the number of error rules. But if there is no any restriction on the number of warnings, the team won't take care of them. So I set max warnings in the CI pipeline to make sure at least the number of warnings won't go up. And also I decreased the number gradually, so that developer had to fix some warnings in each commit but not too many to impact his/her progress. After 2~3 months, the code quality finally reaches a satisfactory status. Even though, I never set the max warnings to zero but give it a reasonable value -- of cause you can say it's arbitrary. We adjust the value by retrospective of overall product quality. We do not force to fix all warning because in some cases there is reason to break the rule otherwise there will be other negative impacts. (BTW, in ESLint/TSLint there is option to temporarily disable a rule for a line, but it's impossible to do it in Spectral). Working in software enterprise, we have to compromise and get balance between quality, workload, and schedule. |
Alright, chatting with @P0lip I think we're aligned that option 2 is the way to go. I'm going to update the initial message with this. |
@aleung sorry I didn't see your reply there before I wrote my last one. I had this page open a while I guess. That's absolutely a valid use case, and I get it, but I think it can be handled in other ways. For now people have |
User story.
As a continuous integration user, I can provide a parameter to CLI, so that the CI pipeline won't fail when there is no error but only warnings.
As a continuous integration user, I can provide a parameter to the CLI, so that only results of a certain severity will be returned as output.
Describe the solution you'd like
Updated 2019-07-16 by @philsturgeon
Two new CLI options:
--fail-severity=warn
- enum[hint
,info
,warn
,error
] - change the level of results which come out of Spectral.--display-only-fail-severity-results
- boolean - spectral will error if results of any level at all are reported. We should make that configurable.We should probably not change the default behavior in this as its aiming for v4.1. Place a TODO note in the code to change the default to
warn
in v5.0.The text was updated successfully, but these errors were encountered: