Simplify Analyzer.ignore by reducing nesting (#1269)

This commit is contained in:
Oleksandr Redko 2024-12-16 16:17:42 +02:00 committed by GitHub
parent b62cc3316d
commit b01f49e366
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
} }