Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove file reference from ruleRecord #1869

Merged
merged 1 commit into from
Aug 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions resolve/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ type RuleIndex struct {
type ruleRecord struct {
rule *rule.Rule
label label.Label
file *rule.File

pkg string

// importedAs is a list of ImportSpecs by which this rule may be imported.
// Used to build a map from ImportSpecs to ruleRecords.
Expand Down Expand Up @@ -149,8 +150,8 @@ func (ix *RuleIndex) AddRule(c *config.Config, r *rule.Rule, f *rule.File) {

record := &ruleRecord{
rule: r,
pkg: f.Pkg,
label: label.New(c.RepoName, f.Pkg, r.Name()),
file: f,
importedAs: imps,
lang: lang,
}
Expand Down Expand Up @@ -179,7 +180,7 @@ func (ix *RuleIndex) collectEmbeds(r *ruleRecord) {
if r.didCollectEmbeds {
return
}
resolver := ix.mrslv(r.rule, r.file.Pkg)
resolver := ix.mrslv(r.rule, r.pkg)
r.didCollectEmbeds = true
embedLabels := resolver.Embeds(r.rule, r.label)
r.embeds = embedLabels
Expand All @@ -189,7 +190,7 @@ func (ix *RuleIndex) collectEmbeds(r *ruleRecord) {
continue
}
ix.collectEmbeds(er)
erResolver := ix.mrslv(er.rule, er.file.Pkg)
erResolver := ix.mrslv(er.rule, er.pkg)
if resolver.Name() == erResolver.Name() {
er.embedded = true
r.embeds = append(r.embeds, er.embeds...)
Expand Down