Skip to content

Integrate Detekt via custom aspect_rules_lint aspect - #3

Merged
menny merged 1 commit into
cognate-detectorfrom
detekt-aspect
Oct 15, 2026
Merged

menny merged 1 commit into
cognate-detectorfrom
detekt-aspect

Conversation

@menny

@menny menny commented Oct 15, 2026

Copy link
Copy Markdown
Member

Summary

Replaces ktlint with detekt as Calque's static analysis tool while keeping ktfmt as the authoritative Kotlin formatter, eliminating rule overlap and enabling deep Kotlin-specific smell and complexity checks.

Key Changes

  • Detekt CLI via Maven: Added io.gitlab.arturbosch.detekt:detekt-cli:1.23.8 to rules_jvm_external maven dependencies and declared a java_binary in //tools/lint:detekt.
  • Custom Detekt Aspect: Implemented lint_detekt_aspect in tools/lint/detekt.bzl backed by aspect_rules_lint's lint_aspect.bzl. It outputs both human-readable console diagnostics and standard SARIF reports.
  • Detekt Configuration: Added detekt.yml to the root with guard clause exclusions enabled and baseline support.
  • Linter & .bazelrc Integration: Wired detekt into tools/lint/linters.bzl and .bazelrc under --config=lint.
  • Code Refinements: Refactored CognateDetector.kt to extract length constants and use idiomatic collection predicates, resolving ReturnCount and MagicNumber rules.
  • Removed ktlint: Cleaned up ktlint repo extensions, .editorconfig ktlint rules, and baseline file.

Verification

  • bazelisk run //:format & bazelisk run //:format.check pass cleanly.
  • bazelisk build --config=lint //... runs Detekt across all targets and passes.
  • Verified Detekt properly catches violations and halts builds when intentional issues are introduced.
  • bazelisk test //... passes (21/21 tests passing).

Introduce custom Detekt aspect in tools/lint/detekt.bzl using aspect_rules_lint.
Fetch io.gitlab.arturbosch.detekt:detekt-cli via rules_jvm_external maven dependency and run via java_binary.
Wire Detekt into linters.bzl and .bazelrc, producing both terminal output and SARIF reports.
Clean up ktlint configuration and baseline.
@menny
menny merged commit 39970ee into cognate-detector Oct 15, 2026
1 check passed
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.

1 participant