-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Added a command line option to specify a path to lint #44
Conversation
Usage example: `swiftlint lint --path Source/swiftlint/LintCommand.swift`
Thanks for the PR, @larslockefeer! This is definitely on the right track, but needs a bit of work:
Otherwise, I have a few minor comments that I'll add inline to your PR now. Again, thanks for doing this! |
|
||
static func evaluate(m: CommandMode) -> Result<LintOptions, CommandantError<()>> { | ||
return create | ||
<*> m <| Option(key: "path", defaultValue: "", usage: "theff path to the file or directory to lint") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theff
should be the
…han `stringByAppendingPathComponent`
Conflicts: Source/swiftlint/LintCommand.swift
Thanks for the feedback @jpsim! I have processed your comments and synced with the upstream again. I have discovered one additional issue after syncing with the upstream: files are now linted twice. I suspect that it is due to Also, I see that the tests failed. On my machine, they ran fine so this could be an issue with Travis. I see the following error in their console output:
|
Failure looks unrelated, I restarted the build. |
} | ||
} | ||
|
||
func filesToLintAtPath(path: String) -> [String] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this function could be simplified:
func filesToLintAtPath(path: String) -> [String] {
let absolutePath = path.absolutePathRepresentation()
var isDirectory: ObjCBool = false
if fileManager.fileExistsAtPath(absolutePath, isDirectory: &isDirectory) {
if isDirectory {
return fileManager.allFilesRecursively(directory: absolutePath).filter {
$0.isSwiftFile()
}
} else if standardizedPath.isSwiftFile() {
return [standardizedPath]
}
}
return []
}
This is great, @larslockefeer. My final comment is about perhaps simplifying |
Thanks again @jpsim, I have processed your feedback. |
Added a command line option to specify a path to lint
Hurray! Great work. |
This pull request adds a command-line option to specify an (absolute or relative) path to a file or directory to lint.
This enables use cases such as:
Usage examples:
swiftlint lint --path Source/swiftlint/LintCommand.swift
swiftlint lint --path Source/SwiftLintFramework
This PR relates to issues #6, #16 and #20