Skip to content

feat: add opt-in generated file skipping#6

Merged
cffls merged 1 commit intomainfrom
psp-skip-generated
Apr 24, 2026
Merged

feat: add opt-in generated file skipping#6
cffls merged 1 commit intomainfrom
psp-skip-generated

Conversation

@pratikspatil024
Copy link
Copy Markdown
Member

This PR adds a --skip-generated flag so diffguard can ignore auto-generated source files that include a standard banner such as Code generated ... DO NOT EDIT.

When the flag is enabled, generated files are filtered out before analysis in both diff mode and --paths mode. That keeps generated code from affecting complexity, size, dependency, churn, or mutation results while preserving the current default behavior for existing users.

It also adds tests covering generated-file detection and filtering, and updates the README with usage and CLI documentation.

Comment thread cmd/diffguard/main.go Outdated
flag.IntVar(&cfg.FunctionSizeThreshold, "function-size-threshold", 50, "Maximum lines per function")
flag.IntVar(&cfg.FileSizeThreshold, "file-size-threshold", 500, "Maximum lines per file")
flag.BoolVar(&cfg.SkipMutation, "skip-mutation", false, "Skip mutation testing")
flag.BoolVar(&cfg.SkipGenerated, "skip-generated", false, "Skip files marked as generated (for example `Code generated ... DO NOT EDIT`)")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can set the default to true. I don't think we want to evaluate the auto-generated code.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

  - add --skip-generated to exclude files marked Code generated ... DO NOT EDIT
  - apply the filter in both diff mode and --paths mode
  - add tests and README documentation
@cffls cffls merged commit b831483 into main Apr 24, 2026
4 checks 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.

2 participants