Field Validator: Skip subdirectory module roots when scanning for logging offenses

Context

When introducing the logging field validator to the Gitaly project here, we observed that the related job fails even when all local offenses are present: https://gitlab.com/gitlab-org/gitaly/-/jobs/13705028105

This MR

Why the job fails: Gitaly's CI sets GOMODCACHE to ${CI_PROJECT_DIR}/_build/cache/go-mod — a path inside the project directory. When validate-log-fields . scans the project root, filepath.WalkDir recurses into _build/cache/go-mod/ and finds Go source files from all downloaded dependencies. Many of those files use deprecated logging field names, producing false-positive offenses that Gitaly cannot fix.

How the fix resolves it: Scan() in v2/fieldvalidator/validator.go now skips any subdirectory that contains its own go.mod. Every entry in a Go module cache (dep@v1.0.0/) has its own go.mod, so they are all silently skipped.

Merge request reports

Loading
Loading