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

Add --only-rule command line option #5666

Conversation

mildm8nnered
Copy link
Collaborator

@mildm8nnered mildm8nnered commented Jul 11, 2024

Addresses #5659

Adds an --only-rule option to the lint and analyze subcommands (--fix is also supported), which behaves as though that single rule was specified in only_rules: in the configuration file.

This is very similar in spirit to the --enable-all-rules command line option. Configuration file settings will be ignored.

A primary use case for this feature is to be able to autocorrect violations of a single rule at a time.

Previously the alternative was to hack the existing .swiftlint.yml file, or to provide a custom one.

 % swiftlint.debug help lint   
OVERVIEW: Print lint warnings and errors

USAGE: swiftlint lint [<options>] [<paths> ...]

ARGUMENTS:
  <paths>                 List of paths to the files or directories to lint.

OPTIONS:
  --only-rule <only-rule> Run only the specified rule, ignoring `only_rules`, `opt_in_rules` and `disabled_rules`.
% swiftlint help analyze
OVERVIEW: Run analysis rules

USAGE: swiftlint analyze [<options>] [<paths> ...]

ARGUMENTS:
  <paths>                 List of paths to the files or directories to analyze.

OPTIONS:
  --only-rule <only-rule> Run only the specified rule, ignoring `only_rules`, `opt_in_rules` and `disabled_rules`.

@SwiftLintBot
Copy link

SwiftLintBot commented Jul 11, 2024

17 Messages
📖 Linting Aerial with this PR took 1.04s vs 1.01s on main (2% slower)
📖 Linting Alamofire with this PR took 1.37s vs 1.37s on main (0% slower)
📖 Linting Brave with this PR took 8.12s vs 8.08s on main (0% slower)
📖 Linting DuckDuckGo with this PR took 4.6s vs 4.61s on main (0% faster)
📖 Linting Firefox with this PR took 11.47s vs 11.46s on main (0% slower)
📖 Linting Kickstarter with this PR took 10.12s vs 10.15s on main (0% faster)
📖 Linting Moya with this PR took 0.56s vs 0.56s on main (0% slower)
📖 Linting NetNewsWire with this PR took 2.76s vs 2.76s on main (0% slower)
📖 Linting Nimble with this PR took 0.81s vs 0.81s on main (0% slower)
📖 Linting PocketCasts with this PR took 8.72s vs 8.85s on main (1% faster)
📖 Linting Quick with this PR took 0.45s vs 0.46s on main (2% faster)
📖 Linting Realm with this PR took 5.06s vs 5.06s on main (0% slower)
📖 Linting Sourcery with this PR took 2.52s vs 2.53s on main (0% faster)
📖 Linting Swift with this PR took 4.96s vs 4.96s on main (0% slower)
📖 Linting VLC with this PR took 1.33s vs 1.34s on main (0% faster)
📖 Linting Wire with this PR took 19.5s vs 19.33s on main (0% slower)
📖 Linting WordPress with this PR took 14.65s vs 14.66s on main (0% faster)

Generated by 🚫 Danger

@mildm8nnered mildm8nnered changed the title Started to pass arguments down Add --only-rule command line option Jul 12, 2024
@mildm8nnered mildm8nnered marked this pull request as ready for review July 13, 2024 11:57
Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really look forward to have this. Every so often I mangle the configuration file instead. 🫣

Source/swiftlint/Commands/Lint.swift Outdated Show resolved Hide resolved
@mildm8nnered mildm8nnered merged commit b1234e3 into realm:main Jul 15, 2024
12 checks passed
@mildm8nnered mildm8nnered deleted the mildm8nnered-only-rule-command-line-option branch July 15, 2024 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants