diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e68981c..684eb4a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,5 +21,5 @@ jobs: run: uv run --group dev ruff format --check src/rattle scripts examples docs/conf.py - name: Run Ruff lint run: uv run --group dev ruff check src/rattle scripts examples docs/conf.py - - name: Run Rattle lint - run: uv run --group dev python -m rattle lint src/rattle + - name: Run Rattle check + run: uv run --group dev python -m rattle check src/rattle diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 9c880e8..be1ba06 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,12 +1,12 @@ - id: rattle-lint - name: Rattle - lint + name: Rattle - check description: This hook shows Rattle lints and suggested changes without applying autofixes. - entry: rattle lint --diff + entry: rattle check --diff language: python types: [python] - id: rattle-fix - name: Rattle - lint and apply autofixes + name: Rattle - check and apply autofixes description: This hook shows Rattle lints and applies suggested changes. - entry: rattle fix + entry: rattle check --fix language: python types: [python] diff --git a/Justfile b/Justfile index 270c229..b9f8c27 100644 --- a/Justfile +++ b/Justfile @@ -27,7 +27,7 @@ venv: install lint: _require-uv uv run --group dev ruff check src/rattle scripts examples docs/conf.py uv run --group dev ruff format --check src/rattle scripts examples docs/conf.py - uv run --group dev python -m rattle lint src/rattle + uv run --group dev python -m rattle check src/rattle # Format code format: _require-uv diff --git a/README.md b/README.md index faa67dc..47e4c0d 100644 --- a/README.md +++ b/README.md @@ -97,13 +97,13 @@ forbidden_calls = ["typing.cast"] Adjust the list to match the project, then lint the repository: ```bash -rattle lint . +rattle check . ``` Apply available autofixes: ```bash -rattle fix . +rattle check --fix . ``` Explain rule metadata, examples, and settings: diff --git a/docs/guide/commands.md b/docs/guide/commands.md index cecc630..b33cf01 100644 --- a/docs/guide/commands.md +++ b/docs/guide/commands.md @@ -8,9 +8,9 @@ $ rattle COMMAND [OPTIONS] ... Use `--help` on any command to print its supported options. -## Shared lint/fix options +## Check options -The following options are available on commands that check or fix code. +The following options are available on `check`, with or without `--fix`. ### `--config / -c CONFIG` @@ -23,7 +23,7 @@ Like Ruff's `--exclude`, direct path arguments are also excluded when they match the pattern. ```console -$ rattle lint . --exclude "generated/**" +$ rattle check . --exclude "generated/**" ``` ### `--extend-exclude PATTERN` @@ -33,7 +33,7 @@ arguments are still checked unless they are excluded by configuration with `force-exclude`. ```console -$ rattle lint . --extend-exclude "docs/_build/**" +$ rattle check . --extend-exclude "docs/_build/**" ``` ### `--rules / -r RULES` @@ -55,9 +55,9 @@ A selector that does not resolve to a rule is an error. For example: ```console -$ rattle lint --rules "use-f-string" path/to/file.py -$ rattle lint --rules "my-custom-rule" path/to/file.py -$ rattle lint --rules "fixit,legacy" path/to/file.py +$ rattle check --rules "use-f-string" path/to/file.py +$ rattle check --rules "my-custom-rule" path/to/file.py +$ rattle check --rules "fixit,legacy" path/to/file.py ``` ### `--jobs / -j JOBS` @@ -71,11 +71,11 @@ Print compact diagnostics. ### `--quiet / -q` Print only the final summary. `--quiet` cannot be used with `--diff`, `--stats`, -or `fix --interactive`. +or `--interactive`. ### `--diff / -d` -Show fixes as unified diffs. +Show available fixes as unified diffs, or applied changes with `--fix`. ### `--stats / -s` @@ -89,25 +89,26 @@ Override the configured `output-format`: `rattle`, `vscode`, or `custom`. Override the configured `output-template` used by the `custom` output format. -## `lint` +## `check` -Check files for Rattle violations. Use `- PATH` to check code from standard -input as `PATH`. +Check files for Rattle violations without modifying source files. With no paths, +check the current directory. Use `- PATH` to check standard input as `PATH`. ```console -$ rattle lint [OPTIONS] [PATH ...] +$ rattle check [OPTIONS] [PATH ...] ``` ### `--json` Print diagnostics as a JSON array on standard output. The summary still goes to standard error. Cannot be combined with `--quiet`, `--diff`, `--compact`, -`--output-format`, or `--output-template`. +`--output-format`, `--output-template`, or `--fix`. -## `fix` +### `--fix` -Apply available autofixes to files. Use `- PATH` to fix code from standard -input as `PATH` and write the fixed code to standard output. +Apply available autofixes, then report remaining violations. Use `- PATH` to fix +standard input as `PATH` and write fixed code to standard output; diagnostics +and the summary go to standard error. By default, automatic fixing runs available autofixes until the file stops changing or no more autofixes are found. Diagnostics shown after fixing are @@ -116,14 +117,14 @@ applied changes, or `--interactive` to review one initial pass of fixes before verification. ```console -$ rattle fix [OPTIONS] [--interactive] [PATH ...] +$ rattle check --fix [OPTIONS] [PATH ...] ``` ### `--interactive / -i` Prompt before applying each autofix. Answer `y` to apply, `n` or Enter to skip, or `q` to stop prompting and leave the remaining fixes unapplied. This option -requires a terminal on standard input and cannot be used with `- PATH`. +requires `--fix` and a terminal on standard input, and cannot be used with `- PATH`. (lsp_command)= @@ -222,4 +223,4 @@ Enable debug logging. ### `RATTLE_METRICS=1` -Print internal run metrics for `lint` and `fix`. +Print internal run metrics for `check`, with or without `--fix`. diff --git a/docs/guide/quickstart.md b/docs/guide/quickstart.md index 7d30979..aa2a007 100644 --- a/docs/guide/quickstart.md +++ b/docs/guide/quickstart.md @@ -29,13 +29,13 @@ Rattle also supports editor integrations, LSP, and pre-commit. See the See lints and suggested changes for a set of source files: ```console -$ rattle lint +$ rattle check ``` Apply suggested changes on those same files automatically: ```console -$ rattle fix +$ rattle check --fix ``` If given directories, Rattle will recurse them automatically, finding `.py` @@ -59,7 +59,7 @@ handler: Callable[[...], int] With `modernization` enabled, running Rattle shows the rule violation: ```console -$ rattle lint handlers.py +$ rattle check handlers.py use-callable-ellipsis [*] Use Callable[..., T] instead of Callable[[...], T]. --> handlers.py:4:10 | @@ -73,7 +73,7 @@ help: Apply the available autofix You can also see suggested changes by passing `--diff`: ```console -$ rattle lint --diff handlers.py +$ rattle check --diff handlers.py use-callable-ellipsis [*] Use Callable[..., T] instead of Callable[[...], T]. --> handlers.py:4:10 | @@ -255,7 +255,7 @@ def main(): ``` ```console -$ rattle lint --diff sourdough/baker.py +$ rattle check --diff sourdough/baker.py hollywood-name-rule [*] It's underproved! --> sourdough/baker.py:2:12 | @@ -274,19 +274,19 @@ help: Apply the available autofix print(f"hello {name}") ``` -Note that the `lint` command only shows lint errors and suggested changes. -The `fix` command applies those changes to the codebase: +The `check` command only shows lint errors and suggested changes. +Pass `--fix` to apply those changes to the codebase: ```console -$ rattle fix sourdough/baker.py +$ rattle check --fix sourdough/baker.py 1 file checked, 1 fix applied ``` -Pass `--interactive` to confirm each available autofix one at a time. +Pass `--fix --interactive` to confirm each available autofix one at a time. Now that the suggested changes have been applied, the codebase is clean: ```console -$ rattle lint sourdough/baker.py +$ rattle check sourdough/baker.py 1 file clean ``` diff --git a/docs/index.md b/docs/index.md index 6f99b1d..f90fc88 100644 --- a/docs/index.md +++ b/docs/index.md @@ -93,13 +93,13 @@ forbidden_calls = ["typing.cast"] Adjust the list to match the project, then lint the repository: ```bash -rattle lint . +rattle check . ``` Apply available autofixes: ```bash -rattle fix . +rattle check --fix . ``` Explain rule metadata, examples, and settings: diff --git a/src/rattle/.agents/skills/create-rattle-lint-rules/SKILL.md b/src/rattle/.agents/skills/create-rattle-lint-rules/SKILL.md index 6ba8e65..9469001 100644 --- a/src/rattle/.agents/skills/create-rattle-lint-rules/SKILL.md +++ b/src/rattle/.agents/skills/create-rattle-lint-rules/SKILL.md @@ -163,10 +163,10 @@ Use the repository's command runner and configuration context. At minimum run: ```bash rattle validate pyproject.toml rattle rules --test --config pyproject.toml . -rattle lint --diff . +rattle check --diff . ``` -Run focused project tests for affected code. Apply `rattle fix` across the +Run focused project tests for affected code. Apply `rattle check --fix` across the repository only when the user requests it. If the rule is noisy, add valid cases before changing the implementation. Test diff --git a/src/rattle/cli/app.py b/src/rattle/cli/app.py index 357626b..cdb973a 100644 --- a/src/rattle/cli/app.py +++ b/src/rattle/cli/app.py @@ -8,9 +8,8 @@ from interfacy.naming import NoAbbreviations from interfacy.plugins import ExecuteContext, InterfacyPlugin +from rattle.cli.commands.check import check from rattle.cli.commands.explain import explain_command -from rattle.cli.commands.fix import fix -from rattle.cli.commands.lint import lint from rattle.cli.commands.lsp import lsp from rattle.cli.commands.rules import rules_command from rattle.cli.commands.validate import validate_command @@ -23,9 +22,10 @@ from rattle.config import CollectionError, ConfigError CONFIG_PARAM = Param(short="c", metavar="") -LINT_PARAMS = { +CHECK_PARAMS = { "config": CONFIG_PARAM, "diff": Param(short="d"), + "interactive": Param(short="i"), "exclude": Param(short="e", metavar=""), "extend_exclude": Param(metavar=""), "jobs": Param(short="j", metavar=""), @@ -35,10 +35,6 @@ "output_format": Param(metavar=""), "output_template": Param(metavar="