Add this line to your Gemfile:
The easiest way to use is just add this to your Dangerfile:
By default danger-swiftlint will lint added and modified files.
swiftlint.config_file = '.swiftlint.yml' swiftlint.binary_path = '/path/to/swiftlint' swiftlint.max_num_violations = 20 swiftlint.lint_files
If you want the lint result shows in diff instead of comment, you can use
inline_mode option. Violations that out of the diff will show in danger's fail or warn section.
swiftlint.lint_files inline_mode: true
If you want different configurations on different directories, you can specify the directory. Note: Run
swiftlint.lint_files per specified directory then.
swiftlint.directory = "Directory A"
If you want lint errors to fail Danger, you can use
swiftlint.lint_files fail_on_error: true
If you need to specify options for
swiftlint that can only be specified by command line arguments, use the
swiftlint.lint_files additional_swiftlint_args: '--lenient'
By default, only files that were added or modified are linted.
It's not possible to use nested configurations in that case, because Danger SwiftLint lints each file on it's own, and by doing that the nested configuration is disabled. If you want to learn more details about this, read the whole issue here.
However, you can use the
lint_all_files option to lint all the files. In that case, Danger SwiftLint doesn't lint files individually, which makes nested configuration to work. It'd be the same as you were running
swiftlint on the root folder:
swiftlint.lint_all_files = true swiftlint.lint_files
You can use the
SWIFTLINT_VERSION environment variable to override the default version installed via the
rake install task.
Finally, if something's not working correctly, you can debug this plugin by using setting
swiftlint.verbose = true.