Feature Request: Add a configure subcommand to SwiftLint
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
Describe the bug
The requested configure command is slightly akin to swift-format's dump-configuration command, or Periphery's --setup flag.
When run, configure will construct a .swiftlint.yml file. By default, configure would run interactively.
Additional command line options would allow configure to run non-interactively, accepting all the recommended defaults.
Additional command line options would allow configure's behaviour to be modifier still further - e.g., a threshold value, indicating that any rules with more then X violations should be disabled.
Additional command line options would allow configure to modify an existing configuration file.
A shell script follows in a comment which provides a proof-of-concept implementation of what configure might look like.
Additional features that could be added could be detection of files that should likely be excluded: files under Pods, or where generated or build appears in the path name, for example, and allowing the user to select a reporter.
Sample output when it's run at the top level of SwiftLint's source tree follows below:
% ./configure_swiftlint.sh
Welcome to the SwiftLint configuration assistant. Press any key to begin.
Checking for existing configuration files...
Found an existing configuration in .swiftlint.yml
Do you wish to continue? (Y/n)
Found other configuration files:
./Tests/SwiftLintFrameworkTests/Resources/ProjectMock/NestedConfig/Test/.swiftlint.yml
./Tests/SwiftLintFrameworkTests/Resources/ProjectMock/NestedConfig/Test/Sub/.swiftlint.yml
./Tests/SwiftLintFrameworkTests/Resources/ProjectMock/ChildConfig/Cycle1/.swiftlint.yml
./Tests/SwiftLintFrameworkTests/Resources/ProjectMock/ChildConfig/Cycle2/.swiftlint.yml
./Tests/SwiftLintFrameworkTests/Resources/ProjectMock/ChildConfig/Cycle3/Main/.swiftlint.yml
./Tests/SwiftLintFrameworkTests/Resources/ProjectMock/ParentConfig/Cycle1/.swiftlint.yml
./Tests/SwiftLintFrameworkTests/Resources/ProjectMock/ParentConfig/Cycle2/.swiftlint.yml
./Tests/SwiftLintFrameworkTests/Resources/ProjectMock/ParentConfig/Cycle3/.swiftlint.yml
./Tests/SwiftLintFrameworkTests/Resources/ProjectMock/.swiftlint.yml
./Tests/SwiftLintFrameworkTests/Resources/ProjectMock/RemoteConfig/LocalRef/.swiftlint.yml
./Tests/SwiftLintFrameworkTests/Resources/ProjectMock/RemoteConfig/Cycle/.swiftlint.yml
./Tests/SwiftLintFrameworkTests/Resources/ProjectMock/Level1/Level2/.swiftlint.yml
./Tests/SwiftLintFrameworkTests/Resources/ProjectMock/Level1/Level2/Level3/.swiftlint.yml
./osscheck/builds/.swiftlint.yml
./osscheck/builds/Tests/SwiftLintFrameworkTests/Resources/ProjectMock/NestedConfig/Test/.swiftlint.yml
./osscheck/builds/Tests/SwiftLintFrameworkTests/Resources/ProjectMock/NestedConfig/Test/Sub/.swiftlint.yml
./osscheck/builds/Tests/SwiftLintFrameworkTests/Resources/ProjectMock/ChildConfig/Cycle1/.swiftlint.yml
./osscheck/builds/Tests/SwiftLintFrameworkTests/Resources/ProjectMock/ChildConfig/Cycle2/.swiftlint.yml
./osscheck/builds/Tests/SwiftLintFrameworkTests/Resources/ProjectMock/ChildConfig/Cycle3/Main/.swiftlint.yml
./osscheck/builds/Tests/SwiftLintFrameworkTests/Resources/ProjectMock/ParentConfig/Cycle1/.swiftlint.yml
./osscheck/builds/Tests/SwiftLintFrameworkTests/Resources/ProjectMock/ParentConfig/Cycle2/.swiftlint.yml
./osscheck/builds/Tests/SwiftLintFrameworkTests/Resources/ProjectMock/ParentConfig/Cycle3/.swiftlint.yml
./osscheck/builds/Tests/SwiftLintFrameworkTests/Resources/ProjectMock/.swiftlint.yml
./osscheck/builds/Tests/SwiftLintFrameworkTests/Resources/ProjectMock/RemoteConfig/LocalRef/.swiftlint.yml
./osscheck/builds/Tests/SwiftLintFrameworkTests/Resources/ProjectMock/RemoteConfig/Cycle/.swiftlint.yml
./osscheck/builds/Tests/SwiftLintFrameworkTests/Resources/ProjectMock/Level1/Level2/.swiftlint.yml
./osscheck/builds/Tests/SwiftLintFrameworkTests/Resources/ProjectMock/Level1/Level2/Level3/.swiftlint.yml
Do you wish to continue? (Y/n)
Checking for swift files...
Found swift source files in the following directories:
Plugins
Source
Tests
osscheck
Do you wish to continue? (Y/n)
Do you want SwiftLint to scan all the directories listed above? (Y/n) n
Do you want SwiftLint to scan source files in the "Plugins" directory? (Y/n)
Do you want SwiftLint to scan source files in the "Source" directory? (Y/n)
Do you want SwiftLint to scan source files in the "Tests" directory? (Y/n)
Do you want SwiftLint to scan source files in the "osscheck" directory? (Y/n) n
configure_excluded
Checking for swift rules violations...
Found rule violations.
Do you want to disable all the rules with current violations? (Y/n) n
Do you want to the disable the "explicit_type_interface" rule (3,518 violations in 485 files)? (Y/n)
Do you want to the disable the "explicit_acl" rule (3,376 violations in 505 files)? (Y/n)
Do you want to the disable the "indentation_width" rule (1,625 violations in 316 files)? (Y/n)
Do you want to the disable the "prefer_nimble" rule (788 violations in 58 files)? (Y/n)
Do you want to the disable the "multiline_arguments_brackets" rule (749 violations in 128 files)? (Y/n)
Do you want to the disable the "explicit_top_level_acl" rule (676 violations in 421 files)? (Y/n)
Do you want to the disable the "type_contents_order" rule (657 violations in 270 files)? (Y/n)
Do you want to the disable the "required_deinit" rule (558 violations in 281 files)? (Y/n)
Do you want to the disable the "no_magic_numbers" rule (537 violations in 90 files)? (Y/n)
Do you want to the disable the "implicit_return" rule (448 violations in 200 files)? (Y/n)
Do you want to the disable the "no_extension_access_modifier" rule (386 violations in 212 files)? (Y/n)
Do you want to the disable the "multiline_parameters_brackets" rule (250 violations in 68 files)? (Y/n)
Do you want to the disable the "multiline_arguments" rule (223 violations in 58 files)? (Y/n)
Do you want to the disable the "anonymous_argument_in_multiline_closure" rule (188 violations in 72 files)? (Y/n)
Do you want to the disable the "file_types_order" rule (179 violations in 92 files)? (Y/n)
Do you want to the disable the "no_grouping_extension" rule (166 violations in 153 files)? (Y/n)
Do you want to the disable the "multiline_literal_brackets" rule (122 violations in 31 files)? (Y/n)
Do you want to the disable the "force_unwrapping" rule (103 violations in 36 files)? (Y/n)
Do you want to the disable the "vertical_whitespace_between_cases" rule (101 violations in 43 files)? (Y/n)
Do you want to the disable the "conditional_returns_on_newline" rule (82 violations in 53 files)? (Y/n)
Do you want to the disable the "trailing_closure" rule (80 violations in 47 files)? (Y/n)
Do you want to the disable the "explicit_enum_raw_value" rule (78 violations in 14 files)? (Y/n)
Do you want to the disable the "missing_docs" rule (70 violations in 13 files)? (Y/n)
Do you want to the disable the "switch_case_on_newline" rule (63 violations in 12 files)? (Y/n)
Do you want to the disable the "prefixed_toplevel_constant" rule (53 violations in 27 files)? (Y/n)
Do you want to the disable the "convenience_type" rule (52 violations in 48 files)? (Y/n)
Do you want to the disable the "strict_fileprivate" rule (52 violations in 21 files)? (Y/n)
Do you want to the disable the "multiline_parameters" rule (51 violations in 32 files)? (Y/n)
Do you want to the disable the "multiline_function_chains" rule (44 violations in 28 files)? (Y/n)
Do you want to the disable the "discouraged_optional_collection" rule (25 violations in 15 files)? (Y/n)
Do you want to the disable the "function_default_parameter_at_end" rule (18 violations in 12 files)? (Y/n)
Do you want to the disable the "file_name" rule (17 violations in 17 files)? (Y/n)
Do you want to the disable the "type_body_length" rule (17 violations in 17 files)? (Y/n)
Do you want to the disable the "closure_body_length" rule (15 violations in 6 files)? (Y/n)
Do you want to the disable the "function_body_length" rule (8 violations in 7 files)? (Y/n)
Do you want to the disable the "large_tuple" rule (7 violations in 7 files)? (Y/n)
Do you want to the disable the "number_separator" rule (7 violations in 5 files)? (Y/n)
Do you want to the disable the "implicitly_unwrapped_optional" rule (6 violations in 5 files)? (Y/n)
Do you want to the disable the "type_name" rule (6 violations in 6 files)? (Y/n)
Do you want to the disable the "file_header" rule (5 violations in 5 files)? (Y/n)
Do you want to the disable the "attributes" rule (4 violations in 4 files)? (Y/n)
Do you want to the disable the "self_binding" rule (4 violations in 3 files)? (Y/n)
Do you want to the disable the "superfluous_disable_command" rule (4 violations in 3 files)? (Y/n)
Do you want to the disable the "empty_xctest_method" rule (1 violations in 1 files)? (Y/n)
Do you want to the disable the "legacy_objc_type" rule (1 violations in 1 files)? (Y/n)
Do you want to the disable the "prefer_self_in_static_references" rule (1 violations in 1 files)? (Y/n)
configure_reporter
Printing configuration...
included:
- Plugins
- Source
- Tests
opt_in_rules:
- all
disabled_rules:
- explicit_type_interface
- explicit_acl
- indentation_width
- prefer_nimble
- multiline_arguments_brackets
- explicit_top_level_acl
- type_contents_order
- required_deinit
- no_magic_numbers
- implicit_return
- no_extension_access_modifier
- multiline_parameters_brackets
- multiline_arguments
- anonymous_argument_in_multiline_closure
- file_types_order
- no_grouping_extension
- multiline_literal_brackets
- force_unwrapping
- vertical_whitespace_between_cases
- conditional_returns_on_newline
- trailing_closure
- explicit_enum_raw_value
- missing_docs
- switch_case_on_newline
- prefixed_toplevel_constant
- convenience_type
- strict_fileprivate
- multiline_parameters
- multiline_function_chains
- discouraged_optional_collection
- function_default_parameter_at_end
- file_name
- type_body_length
- closure_body_length
- function_body_length
- large_tuple
- number_separator
- implicitly_unwrapped_optional
- type_name
- file_header
- attributes
- self_binding
- superfluous_disable_command
- empty_xctest_method
- legacy_objc_type
- prefer_self_in_static_references
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review the proposed configure command and the proof-of-concept shell script referenced in the issue, starting with SwiftLint's command-line entry point. Done requires agreeing on a bounded initial scope and implementing the command's configuration-file generation and documented interactive or non-interactive behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100