mirror of
https://github.com/securego/gosec.git
synced 2024-12-26 12:35:52 +00:00
Simplify Analyzer.ignore by reducing nesting (#1269)
This commit is contained in:
parent
b62cc3316d
commit
b01f49e366
1 changed files with 60 additions and 55 deletions
|
@ -558,7 +558,13 @@ func (gosec *Analyzer) AppendError(file string, err error) {
|
||||||
|
|
||||||
// ignore a node (and sub-tree) if it is tagged with a nosec tag comment
|
// ignore a node (and sub-tree) if it is tagged with a nosec tag comment
|
||||||
func (gosec *Analyzer) ignore(n ast.Node) map[string]issue.SuppressionInfo {
|
func (gosec *Analyzer) ignore(n ast.Node) map[string]issue.SuppressionInfo {
|
||||||
if groups, ok := gosec.context.Comments[n]; ok && !gosec.ignoreNosec {
|
if gosec.ignoreNosec {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
groups, ok := gosec.context.Comments[n]
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Checks if an alternative for #nosec is set and, if not, uses the default.
|
// Checks if an alternative for #nosec is set and, if not, uses the default.
|
||||||
noSecDefaultTag, err := gosec.config.GetGlobal(Nosec)
|
noSecDefaultTag, err := gosec.config.GetGlobal(Nosec)
|
||||||
|
@ -619,7 +625,6 @@ func (gosec *Analyzer) ignore(n ast.Node) map[string]issue.SuppressionInfo {
|
||||||
return ignores
|
return ignores
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue