uncloak is a CLI tool for analyzing new Go code coverage on the current branch with the current branch's nearest parent branch.
At a high level, it:
- runs
git diffagainst the parent branch - runs Go tests to collect coverage data
- compares new Go lines from the diff against the coverage profile
- reports uncovered new lines and fails when coverage drops below the configurable threshold
Install the latest version with:
go install github.com/engmtcdrm/uncloak@latestThis installs the uncloak binary into your Go bin directory.
Run uncloak from the root of a Git repository:
uncloakBy default, uncloak will analyze against the nearest parent branch of the current branch.
That default behavior requires a branch with a parent branch, so feature branches are the intended use.
If coverage is below the threshold, the command exits with an error and prints the uncovered new line ranges.
uncloak reads configuration from a YAML file in the current working directory.
Supported file names:
.uncloak.yml.uncloak.yaml
If no config file is present, uncloak uses built-in defaults. Empty config files are rejected.
version: 0
coverage-threshold: 80
exclusions: []version: config file versioncoverage-threshold: minimum acceptable coverage percentage for new codeexclusions: list of file paths or glob patterns to exclude from analysis
version: 0
coverage-threshold: 90
exclusions:
- "docs/**"
- "**/*_generated.go"Exclusions support exact file matches and glob patterns. For example:
main.gointernal/****/*_generated.go
uncloak supports these command-line flags:
-c, --coverage-threshold <float>: (optional) coverage threshold override. This will also overwrite what is specified in the configuration file-d, --debug: enable debug output, e.g. what commands are run-t, --target-ref <string>: git target ref to compare against-v, --verbose: enable verbose output, e.g. output from go test command
Example:
uncloak --coverage-threshold 70.31 --verbose0when coverage meets the configured threshold- non-zero when coverage is below the threshold or an analysis error occurs
- Create or switch to a feature branch.
- Make changes.
- Run
uncloakfrom the repository root. - Review any uncovered new lines.
- Add tests or adjust code until the new coverage meets the threshold.
- Brand new Go files must be staged or committed for
uncloakto analyze them. - The tool expects to run inside a Git repository on a branch with a parent branch.
- The default coverage threshold is
80%. - Unknown YAML fields are rejected, so config files should only contain supported keys.