Match file references on path-word boundaries - #89
Merged
Conversation
Fixes #85. When a reference source and an inventory file shared a directory, the sourceDir-relative fallback reduced the match needle to a bare filename, and the extensionless variant then substring-matched ordinary prose: references/lint.yml was reported as "referenced without its extension" because the word "lint" appeared in a sibling markdown file that never mentions the path. Reference matching now requires path-word boundaries on both sides of a match (references/lint no longer matches inside references/linting, and lint.yml no longer matches inside eslint.yml), and the extensionless sourceDir-relative fallback is skipped when it would reduce to a bare filename. Root-relative extensionless matching is unchanged, so flat layouts still resolve "helper" to helper.py and nested skills still resolve scripts/check_fillable_fields to the .py file. The Python-import test that relied on the old fallback now expects an orphan warning: "import data_loader" refers to a Python module and cannot reference data_loader.sh, so reporting the script as unreferenced is the accurate outcome.
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.
What this PR does
Fixes #85, where
references/lint.ymlwas reported as "referenced without its extension (as references/lint in references/check-skill-nonlinks.md)" even though that file never containsreferences/lint.Root cause: when the referencing file and the inventory file share a directory,
containsReference's sourceDir-relative fallback reduces the needle to a bare filename. The extensionless variant then reducedreferences/lint.ymlto the single wordlintand substring-matched it against ordinary prose ("Run the lint step…", "Linting catches…").Two changes:
references/lintno longer matches insidereferences/linting, andlint.ymlno longer matches insideeslint.yml.helpertohelper.py, and nested skills still resolvescripts/check_fillable_fieldsto the.pyfile.One test intentionally updated:
Python import does not match non-Python filespreviously relied on the bare-word fallback to claimdata_loader.shwas "referenced without its extension" byimport data_loader. A Python import cannot reference a shell script, so the accurate outcome — now asserted — is an unreferenced-file warning.How to test
Reproduced the report with a minimal fixture (a
references/lint.ymlbeside a markdown file whose prose mentions "lint"): before this change it produces the false extension warning; after, it produces the truthful "potentially unreferenced file" warning. Also:go test -race ./... -count=1go vet ./...,gofmt -l .Checklist
go test -race ./... -count=1)golangci-lint run)