Skip to content

Generated-file suppression (detect codegen headers / default ignore globs) #26

Description

@Dominik-O22

Problem

Generated files (protobuf/openapi/prisma output, *.gen.ts, bundled barrels) are a large structural-duplicate source: codegen emits near-identical shapes by design, so they cluster trivially and drown real findings. The only escape today is .gitignore (gitignoreMatcher in src/TypeScriptDuplicateFinder.ts) or --no-gitignore, neither of which targets generated code specifically — generated files are often committed and not gitignored.

Proposed change

Two complementary mechanisms:

  1. Header sniff: skip a file in FileScanner.scanFile (src/FileScanner.ts) when its leading bytes match a common generated banner (e.g. // Code generated, @generated, eslint-disable + DO NOT EDIT, prettier-ignore codegen markers). Read the first ~1KB only.
  2. Default + configurable ignore globs for known generated patterns (**/*.gen.ts, **/__generated__/**, **/*.pb.ts), opt-out via flag, and extensible via the .dryrc ignore list (issue Config file (.dryrc) with ignore globs and per-path threshold/minNodes overrides #23 / plan 011).

Default behavior must stay opt-in or clearly documented — header sniff is low-risk (generated files rarely carry hand-written duplicates worth catching), but a default glob list changes output, so version it.

Acceptance

  • A file with a @generated banner is skipped; removing the banner restores scanning.
  • A *.gen.ts file is excluded under the default/opt-in glob, without touching .gitignore.

Related

Part of the false-positive-reduction set (#19-#24). Surfaced by a codex second-opinion on that set. Pairs with .dryrc ignore globs (#23).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions