fleetlint Policy for a fleet of repositories
v0.11 (latest)
Getting started

lint/strict/kotlin

detekt enforces the exception and size rules

Implements lint/strict for kotlin.

Severitywarning
Tiers1, 2
Stackskotlin
Scopeeach
Kindexpr
Sourcelibrary v0.8.0
Selected byfleetlint-recommended@v0.8.0

Requirement

The detekt configuration sets active: true for every rule in params.required (ruleset.Rule): swallowed and too-generic exceptions, empty catch blocks, method length and cognitive complexity. detekt --generate-config writes a full configuration to edit.

Why

The compiler accepts a swallowed exception and a 400-line method; detekt is the only place these are refused, and only when the rules are on.

Applies when

exists("**/detekt*.yml") || exists("**/detekt*.yaml") || ["../", "../../", "../../../"].exists(d, file(d + "config/detekt/detekt.yml")) || (["", "../", "../../", "../../../"].map(d, [d + "build.gradle", d + "build.gradle.kts", d + "settings.gradle.kts", d + "settings.gradle"]).flatten()
  + glob("buildSrc/**/*.gradle*") + glob("build-logic/**/*.gradle*"))
  .exists(f, file(f) && text(f).matches("io\\.gitlab\\.arturbosch\\.detekt|dev\\.detekt|libs\\.plugins\\.detekt|\\bdetekt\\s*\\{"))

Check

For each item in:

params.required
(glob("**/detekt*.y*ml") + ["../", "../../", "../../../"].map(d, d + "config/detekt/detekt.yml").filter(f, file(f))) .exists(f, [yaml(f)].exists(y, y != null
  && item.split(".")[0] in y && y[item.split(".")[0]] != null
  && item.split(".")[1] in y[item.split(".")[0]] && y[item.split(".")[0]][item.split(".")[1]] != null
  && "active" in y[item.split(".")[0]][item.split(".")[1]]
  && y[item.split(".")[0]][item.split(".")[1]].active == true))

Parameters

  • required: [exceptions.SwallowedException exceptions.TooGenericExceptionCaught empty-blocks.EmptyCatchBlock complexity.LongMethod complexity.CognitiveComplexMethod]

Fix

Set the reported rules to active: true in the detekt configuration (thresholds: LongMethod 50, CognitiveComplexMethod 15); fleetlint fix --apply writes config/detekt/detekt.yml when there is none, where the detekt Gradle plugin looks by default.

Agent instruction: Set each reported rule to active: true in the detekt configuration and fix the findings it produces instead of adding a baseline entry.

fleetlint fix can apply this rule’s fix automatically (1 action(s)).

Sources


Generated by fleetlint docs from catalog v0.8.0.