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

Status code is 0 when high-severity errors found. #30

Closed
pawrsccouk opened this issue May 22, 2015 · 5 comments
Closed

Status code is 0 when high-severity errors found. #30

pawrsccouk opened this issue May 22, 2015 · 5 comments
Labels
enhancement Ideas for improvements of existing features and rules.

Comments

@pawrsccouk
Copy link
Contributor

In the example file ok.swift, containing:

import UIKit
class Foo {
    var _badVariable = 0
}

The bash command:

swiftlint lint
echo "Return Status = $?"

Returns

Finding Swift files in current directory...
Linting 'ok.swift' (1/1)
/tmp/ok.swift:3: error: Name Format Violation (High Severity): Variable name should only contain alphanumeric characters: '_badVariable'
Done linting! Found 1 violation in 1 file.
Return Status = 0

The return status of a shell script which generates error messages should not be 0. Xcode gives the following message at the end of the build process:

Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure

Currently the swiftlint command-line application only returns a non-zero exit code when swiftlint itself had errors, not when it discovers style violations in the source files it looks at. Please can you change it so that it returns a non-zero exit status when it finds style violations?

@jpsim
Copy link
Collaborator

jpsim commented May 22, 2015

You're right that SwiftLint should exit with a non-zero code when it finds violations, but only when errors are found, not warnings.

I'd appreciate a PR doing this, if you're interested.

@jpsim jpsim added the enhancement Ideas for improvements of existing features and rules. label May 22, 2015
@pawrsccouk
Copy link
Contributor Author

I'll have a look.

@jpsim
Copy link
Collaborator

jpsim commented May 22, 2015

You could keep track of the number of violations above ViolationSeverity.Medium here and return .failure(()) instead of .success(()).

@pawrsccouk
Copy link
Contributor Author

Done. It passes the SwiftLintFramework unit tests and lints against one of my projects successfully. If you want any more testing, or want me to make further changes please give me a shout.

@segiddins
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Ideas for improvements of existing features and rules.
Projects
None yet
Development

No branches or pull requests

3 participants