Pull some high level options up into the toolchain - #237
Open
Bencodes wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR moves several Detekt invocation options (configs, plugins, JVM/language settings, and flags) into the Detekt toolchain so they can be set once and inherited by targets, and updates analysis tests and documentation accordingly.
Changes:
- Extends
detekt_toolchainto carry defaults for cfgs/plugins and several CLI flags (and wires the rule implementation to inherit them). - Updates analysis tests to validate toolchain-default forwarding and removal of JVM flag forwarding.
- Updates README and generated attributes docs to describe toolchain default behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
detekt/toolchain.bzl |
Adds toolchain attributes for cfgs/plugins and CLI default flags, and exposes the detekt wrapper through the toolchain. |
detekt/defs.bzl |
Inherits cfgs/plugins and several flags from the toolchain when the target leaves attributes at rule defaults. |
tests/analysis/tests.bzl |
Updates existing analysis tests and adds a new test for toolchain-default inheritance. |
tests/analysis/BUILD |
Adds a custom toolchain instance used by analysis tests to validate toolchain defaults. |
README.md |
Documents toolchain defaults and updates JVM target / language version inheritance wording. |
docs/attrs.md |
Updates generated attribute documentation to mention inheritance from the toolchain. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| assert_argv_contains(env, action, "--input") | ||
| assert_argv_contains(env, action, _expand_path(ctx, "{{source_dir}}/path A.kt,{{source_dir}}/path B.kt,{{source_dir}}/path C.kt")) | ||
|
|
||
| # These values are supplied by custom_defaults_toolchain, not the target. |
Comment on lines
+179
to
+180
| build_upon_default_config = ctx.attr.build_upon_default_config or detekt_toolchain.build_upon_default_config | ||
| if build_upon_default_config: |
Comment on lines
212
to
215
| `cfgs`, `plugins`, `build_upon_default_config`, `disable_default_rulesets`, `jvm_target`, | ||
| `language_version`, `max_issues`, and `parallel` can be set once on a custom | ||
| `detekt_toolchain`. Target attributes use those values when left at their rule defaults: | ||
|
|
Comment on lines
+13
to
+16
| | `build_upon_default_config` | [`bool`](https://docs.bazel.build/versions/master/skylark/lib/bool.html) | `False` | Preconfigures detekt with a bunch of rules and some opinionated defaults for you. Defaults to the detekt toolchain value. | | ||
| | `cfgs` | [`[Label]`](https://docs.bazel.build/versions/master/skylark/lib/list.html) | `[]` | Path to the config file (path/to/config.yml). Multiple configuration files can be specified. Empty list inherits from the detekt toolchain. | | ||
| | `config_resource` | [`string`](https://docs.bazel.build/versions/master/skylark/lib/string.html) | `""` | Path to the config resource on detekt's classpath (path/to/config.yml). | | ||
| | `disable_default_rulesets` | [`bool`](https://docs.bazel.build/versions/master/skylark/lib/bool.html) | `False` | Disables default rule sets. | | ||
| | `disable_default_rulesets` | [`bool`](https://docs.bazel.build/versions/master/skylark/lib/bool.html) | `False` | Disables default rule sets. Defaults to the detekt toolchain value. | |
Bencodes
force-pushed
the
pull-some-high-level-options-up-into-the-toolchain
branch
from
July 22, 2026 14:43
7657d67 to
88819be
Compare
Bencodes
force-pushed
the
pull-some-high-level-options-up-into-the-toolchain
branch
3 times, most recently
from
August 26, 2026 19:16
84ffeda to
94b5a27
Compare
Bencodes
force-pushed
the
pull-some-high-level-options-up-into-the-toolchain
branch
from
August 26, 2026 19:46
94b5a27 to
72ddd79
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
detekt_toolchain: config files, plugins, configuration booleans, JVM and Kotlin targets, failure policy, parallel execution, and the wrapper executable.False, empty lists, empty strings, andmax_issues = -1. An explicit rule failure policy replaces the inherited failure-policy pair.--host_jvmoptconfiguration instead.Compatibility notes
Toolchain profiles configure the selected Detekt runtime; they do not select a Detekt version. Use
max_issueswith Detekt 1.x,fail_on_severitywith Detekt 2.x, and plugins built for the matching major version. Target-specific inputs, baselines, filters, Android context, autocorrection, and report outputs remain rule-level options.Windows support remains separate in #250.
Validation
pre-commit run --all-filesbazel mod deps --lockfile_mode=errorbazel build //docs:docsand generated documentation comparison