Skip to content

Commit b3f43d7

Browse files
committed
feat(cli): Warn about unused disabled detectors
Closes #393
1 parent 139f6e2 commit b3f43d7

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
### Changed
1515
- `DuplicatedImport` and `TransitiveImport`: Don't check internal stdlib imports
1616
- `ZeroAddress` and `ConstantAddress`: Ignore uses in comparisons: Issue [#384](https://github.com/nowarp/misti/issues/384)
17+
- Warn if one of the disabled detectors (`-dd`) is unused: Issue [#393](https://github.com/nowarp/misti/issues/393)
1718

1819
### Fixed
1920
- `ImportGraph`: Set correct file paths of import nodes for `.func` files: PR [#381](https://github.com/nowarp/misti/pull/381)

src/cli/driver.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,12 @@ export class Driver {
272272
* @throws Error if a detector class cannot be found in the specified module or as a built-in.
273273
*/
274274
async initializeDetectors(): Promise<void> {
275+
const usedDisabledDetectors = new Set<string>();
275276
const detectorPromises = this.ctx.config.detectors.reduce<
276277
Promise<Detector | null>[]
277278
>((acc, config) => {
278279
if (this.disabledDetectors.has(config.className)) {
280+
usedDisabledDetectors.add(config.className);
279281
this.ctx.logger.debug(`Suppressed detector: ${config.className}`);
280282
return acc;
281283
}
@@ -311,6 +313,16 @@ export class Driver {
311313
this.ctx.logger.debug(
312314
`Enabled detectors (${this.detectors.length}): ${this.detectors.map((d) => d.id).join(", ")}`,
313315
);
316+
317+
// Warn about unused disabled detectors
318+
const unusedDisabledDetectors = [...this.disabledDetectors].filter(
319+
(detector) => !usedDisabledDetectors.has(detector),
320+
);
321+
if (unusedDisabledDetectors.length > 0) {
322+
this.ctx.logger.warn(
323+
`The following disabled detectors were never encountered: ${unusedDisabledDetectors.join(", ")}`,
324+
);
325+
}
314326
}
315327

316328
/**

0 commit comments

Comments
 (0)