Repository navigation
feat(config): support .dupehound.yml config file with auto-discovery - #8
Merged
Merged
Conversation
- Add FindConfig to walk up directories for .dupehound.yml - Add LoadConfig (yaml.v3) and ApplyConfigDefaults (CLI wins over config) - Add `dupehound init` subcommand to write a starter config file - Support format, output, exit-zero from config file - Use c.IsSet() throughout scan action to distinguish explicit CLI flags from defaults - Add 9 unit tests for config and 6 integration tests for config+init Closes #2
StructLint — All checks passed46 rules validated against
|
There was a problem hiding this comment.
Core Changes
This Pull Request introduces support for a .dupehound.yml configuration file, allowing users to define scan parameters outside of command-line flags. Key features include:
- Config File (
.dupehound.yml): A newdupehound initcommand creates a starter configuration file. This file can specifypath,min-tokens,exclude,language,format,output, andexit-zerosettings. - Auto-discovery: The tool automatically searches for
.dupehound.ymlby walking up the directory tree from the current working directory. - CLI Flag Precedence: Command-line flags always override values specified in the configuration file.
- Explicit Config Path: A new
--configflag allows users to specify a custom path to a configuration file, bypassing auto-discovery. - Integration: The
scanaction now loads and applies settings from the config file, respecting the CLI flag precedence.
Concerns
None. The implementation correctly handles precedence, error wrapping, and provides good test coverage.
Verdict
Approve
Code review performed by GEMINI - gemini-2.5-flash.
- Handle os.Getwd() error in scan action instead of silently discarding it - Add integration tests for config auto-discovery (cwd and walk-up) - Add integration tests for --config with missing/invalid file returning errors - Add integration tests for format, output, and language fields from config file
There was a problem hiding this comment.
Core Changes
This pull request introduces support for a .dupehound.yml configuration file, allowing users to define scan parameters outside of command-line flags. Key features include:
- Config File Loading: The
scancommand now attempts to load a.dupehound.ymlfile, either specified explicitly via--configor auto-discovered by walking up the directory tree from the current working directory. - CLI Flag Precedence: Command-line flags always override values specified in the configuration file, providing a clear hierarchy for settings.
initCommand: A newdupehound initcommand is added to generate a starter.dupehound.ymlfile, with an option to force overwrite existing files.- Configurable Options: The configuration file supports
path,min-tokens,exclude,language,format,output, andexit-zerosettings.
Concerns
None. The changes are well-implemented and thoroughly tested.
Verdict
Approve
Code review performed by GEMINI - gemini-2.5-flash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.dupehound.ymlconfig file support with automatic directory-tree discovery (FindConfig)ApplyConfigDefaults)path,min-tokens,exclude,language,format,output,exit-zeroin configdupehound initsubcommand writes a starter config with inline comments--configflag to override auto-discovery pathTests
services/config_test.go: parse all fields, empty path, missing file, invalid YAML, FindConfig current dir, FindConfig walks up, CLI wins, fills zero valuesintegration/cli_test.go: config settings respected, CLI flag overrides config, exclude from config, init creates file, init fails if exists, init --force overwritesChecklist
go test ./...— 100 tests)golangci-lintcleangofumptcleanstructlintcleandupehound initwrites a starter.dupehound.ymlCloses #2