From ea85cae27e7dc08281f2d5bb0211153550ba7356 Mon Sep 17 00:00:00 2001 From: Lukasz Mierzwa Date: Tue, 2 Apr 2024 13:18:35 +0100 Subject: [PATCH] Ignore symlinks in rule/dependency --- cmd/pint/tests/0172_rule_dependency_symlink_delete.txt | 2 -- docs/changelog.md | 1 + internal/checks/rule_dependency.go | 7 ++++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/pint/tests/0172_rule_dependency_symlink_delete.txt b/cmd/pint/tests/0172_rule_dependency_symlink_delete.txt index 17848663..86c7c9e6 100644 --- a/cmd/pint/tests/0172_rule_dependency_symlink_delete.txt +++ b/cmd/pint/tests/0172_rule_dependency_symlink_delete.txt @@ -24,8 +24,6 @@ pint.ok -l error --offline --no-color ci cmp stderr ../stderr.txt -- stderr.txt -- -rules2/record.yml ~> rules1/record.yml:4-5 (deleted) Warning: Metric generated by this rule is used by 1 other rule(s). (rule/dependency) - -- src/alert.yml -- groups: - name: g1 diff --git a/docs/changelog.md b/docs/changelog.md index df9f6c25..fcf7de16 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -6,6 +6,7 @@ - Fixed false positives from [rule/duplicate](checks/rule/duplicate.md) check when running `pint ci` on files that are both edited and renamed in the same PR. +- [rule/dependency](checks/rule/dependency.md) will no longer report removed symlinks. ## v0.57.3 diff --git a/internal/checks/rule_dependency.go b/internal/checks/rule_dependency.go index 12d86bd5..4813523b 100644 --- a/internal/checks/rule_dependency.go +++ b/internal/checks/rule_dependency.go @@ -41,7 +41,12 @@ func (c RuleDependencyCheck) Reporter() string { return RuleDependencyCheckName } -func (c RuleDependencyCheck) Check(_ context.Context, _ discovery.Path, rule parser.Rule, entries []discovery.Entry) (problems []Problem) { +func (c RuleDependencyCheck) Check(_ context.Context, path discovery.Path, rule parser.Rule, entries []discovery.Entry) (problems []Problem) { + if path.Name != path.SymlinkTarget { + // Don't reported symlinks that are being removed. + return problems + } + var broken []*brokenDependency var dep *brokenDependency for _, entry := range entries {