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
use multiple exit codes to distinguish between errors & strict warnings #584
Conversation
|
That's funny! I just implemented the same thing--though slightly differently. I created a new error type to be used as Commandant's enum SwiftLintError: ErrorType {
case ExitCode(Int)
}
if numberOfSeriousViolations > 0 {
return .Failure(.CommandError(.ExitCode(2)))
} else if options.strict && !violations.isEmpty {
return .Failure(.CommandError(.ExitCode(3)))
} Then in registry.main(defaultVerb: LintCommand().verb) { error in
queuedPrintError(String(error))
switch error {
case .CommandError(.ExitCode(let code)):
exit(Int32(code))
default:
break
}
} The effect was the same as what you did, though I suppose it's a solution that might offer room for expansion to more types of errors/handling, but there's no good use case for that currently, so I'm happy to go with your much simpler approach. 👍 |
otherwise we get a function length exceeded violation
Oh, sorry for stepping on your toes then @scottrhoyt! Your approach is definitely nicer, while mine is simpler. In this case, I'd prefer keeping things simple until that "doesn't scale" 😛 |
Premature optimization is the root of all evil. 😄 I'm all for simple. I'll keep it stashed away incase we go that direction. |
👍 |
use multiple exit codes to distinguish between errors & strict warnings
Awesome! Thanks for doing this. |
Nice! |
Fix printing duplicated violations bug that introduced by #584
Awesome |
SwiftLint returns 2 as exit code when detecting style violations of severity "Error”. realm/SwiftLint#584 That produces error on running linter-swiftlint as following: > Error: Process exited with non-zero code: 2 This commit avoid that error.
Addresses #166.
Does this approach make sense to you all? /cc @jakecraige @kylef @scottrhoyt @norio-nomura