This repository was archived by the owner on Jul 2, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
1010### Fixed
1111
12+ - ` detekt ` : hook now translates pre-commit's positional file arguments into
13+ the detekt CLI's ` --input <comma-separated> ` form. Previously detekt CLI
14+ rejected positional args with `Was passed main parameter '<file >' but no
15+ main parameter was defined in your arg class`, which broke the hook for
16+ every downstream consumer.
1217- ` detekt ` : regenerate ` checksums.txt ` for detekt-cli 1.23.8 (Renovate had
1318 bumped ` version.txt ` without re-running ` scripts/fetch_checksums.py ` ,
1419 breaking the hook for downstream consumers).
Original file line number Diff line number Diff line change @@ -24,4 +24,29 @@ java_bin="$(locate_java)"
2424
2525jar_path=" $( download_tool detekt " ${VERSION} " " ${url} " " ${asset_name} " " ${CHECKSUMS} " ) "
2626
27- exec " ${java_bin} " -jar " ${jar_path} " " $@ "
27+ # detekt-cli does not accept positional file arguments — it requires
28+ # `--input <path>[,path...]`. pre-commit/prek pass staged files as
29+ # positional args at the end of the invocation (after any manifest `args:`),
30+ # so split flags from file paths and re-assemble as `--input <csv>`.
31+ flags=()
32+ files=()
33+ for arg in " $@ " ; do
34+ case " ${arg} " in
35+ -* ) flags+=(" ${arg} " ) ;;
36+ * ) files+=(" ${arg} " ) ;;
37+ esac
38+ done
39+
40+ cmd=(" ${java_bin} " -jar " ${jar_path} " )
41+ if [ " ${# flags[@]} " -gt 0 ]; then
42+ cmd+=(" ${flags[@]} " )
43+ fi
44+ if [ " ${# files[@]} " -gt 0 ]; then
45+ # Join file paths with commas without leaking IFS to the rest of the script.
46+ input_paths=" $(
47+ IFS=' ,'
48+ printf ' %s' " ${files[*]} "
49+ ) "
50+ cmd+=(--input " ${input_paths} " )
51+ fi
52+ exec " ${cmd[@]} "
You can’t perform that action at this time.
0 commit comments