Skip to content

Commit

Permalink
feat: ignore package
Browse files Browse the repository at this point in the history
  • Loading branch information
ldez committed Jun 24, 2023
1 parent e25d19a commit 90f7aab
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tagliatelle.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Base struct {
Rules map[string]string
UseFieldName bool
IgnoredFields []string
Ignore bool
}

// New creates an analyzer.
Expand Down Expand Up @@ -75,6 +76,10 @@ func run(pass *analysis.Pass, config Config) (interface{}, error) {

for _, field := range node.Fields.List {
_, v, _ := r.Root().LongestPrefix([]byte(path.Join(pass.Pkg.Path(), filepath.Base(pass.Fset.File(node.Pos()).Name()))))
if v.Ignore {
continue
}

analyze(pass, v, node, field)
}
})
Expand Down Expand Up @@ -253,6 +258,7 @@ func createRadixTree(config Config) *iradix.Tree[Base] {
defaultRule := Base{
Rules: copyMap(config.Rules),
UseFieldName: config.UseFieldName,
Ignore: config.Ignore,
}
defaultRule.IgnoredFields = append(defaultRule.IgnoredFields, config.IgnoredFields...)

Expand All @@ -262,6 +268,7 @@ func createRadixTree(config Config) *iradix.Tree[Base] {
c := Base{
Rules: copyMap(config.Rules),
UseFieldName: override.UseFieldName,
Ignore: override.Ignore,
}
c.IgnoredFields = append(c.IgnoredFields, config.IgnoredFields...)
c.IgnoredFields = append(c.IgnoredFields, override.IgnoredFields...)
Expand Down

0 comments on commit 90f7aab

Please sign in to comment.