Skip to content

Commit

Permalink
Update CONTRIBUTING.md to reflect Settings refactor (#7555)
Browse files Browse the repository at this point in the history
## Summary

See:
#7544 (comment).
  • Loading branch information
charliermarsh committed Sep 20, 2023
1 parent a0917ec commit 86faee1
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,25 +251,24 @@ Once you've completed the code for the rule itself, you can define tests with th

Ruff's user-facing settings live in a few different places.

First, the command-line options are defined via the `Cli` struct in `crates/ruff_linter/src/cli.rs`.
First, the command-line options are defined via the `Args` struct in `crates/ruff_cli/src/args.rs`.

Second, the `pyproject.toml` options are defined in `crates/ruff_linter/src/settings/options.rs` (via the
`Options` struct), `crates/ruff_linter/src/settings/configuration.rs` (via the `Configuration` struct), and
`crates/ruff_linter/src/settings/mod.rs` (via the `Settings` struct). These represent, respectively: the
schema used to parse the `pyproject.toml` file; an internal, intermediate representation; and the
final, internal representation used to power Ruff.
Second, the `pyproject.toml` options are defined in `crates/ruff_workspace/src/options.rs` (via the
`Options` struct), `crates/ruff_workspace/src/configuration.rs` (via the `Configuration` struct),
and `crates/ruff_workspace/src/settings.rs` (via the `Settings` struct), which then includes
the `LinterSettings` struct as a field.

These represent, respectively: the schema used to parse the `pyproject.toml` file; an internal,
intermediate representation; and the final, internal representation used to power Ruff.

To add a new configuration option, you'll likely want to modify these latter few files (along with
`cli.rs`, if appropriate). If you want to pattern-match against an existing example, grep for
`arg.rs`, if appropriate). If you want to pattern-match against an existing example, grep for
`dummy_variable_rgx`, which defines a regular expression to match against acceptable unused
variables (e.g., `_`).

Note that plugin-specific configuration options are defined in their own modules (e.g.,
`crates/ruff_linter/src/flake8_unused_arguments/settings.rs`).

You may also want to add the new configuration option to the `flake8-to-ruff` tool, which is
responsible for converting `flake8` configuration files to Ruff's TOML format. This logic
lives in `crates/ruff_linter/src/flake8_to_ruff/converter.rs`.
`Settings` in `crates/ruff_linter/src/flake8_unused_arguments/settings.rs` coupled with
`Flake8UnusedArgumentsOptions` in `crates/ruff_workspace/src/options.rs`).

Finally, regenerate the documentation and generated code with `cargo dev generate-all`.

Expand Down

0 comments on commit 86faee1

Please sign in to comment.