generated from TrueCloudLab/basic
[#30] noliteral: Simplify code
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
parent
588336678b
commit
e1ec8c5a6f
1 changed files with 3 additions and 7 deletions
|
@ -3,6 +3,7 @@ package noliteral
|
|||
import (
|
||||
"go/ast"
|
||||
"go/token"
|
||||
"slices"
|
||||
|
||||
astutils "git.frostfs.info/TrueCloudLab/linters/pkg/ast-utils"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
|
@ -85,16 +86,11 @@ func (l *noliteral) analyzeCallExpr(pass *analysis.Pass, expr *ast.CallExpr, fil
|
|||
|
||||
if !astutils.IsStringValue(expr.Args[0]) {
|
||||
alias, _ := astutils.GetAliasByPkgName(file, l.config.ConstantsPackage)
|
||||
if l.config.ConstantsPackage == "" || astutils.GetPackageName(expr.Args[0]) == alias || astutils.GetPackageName(expr.Args[0]) == "" {
|
||||
pkgName := astutils.GetPackageName(expr.Args[0])
|
||||
if l.config.ConstantsPackage == "" || pkgName == alias || pkgName == "" || slices.Contains(l.config.DisablePackages, pkgName) {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, pkgName := range l.config.DisablePackages {
|
||||
if pkgName == astutils.GetPackageName(expr.Args[0]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
pass.Report(analysis.Diagnostic{
|
||||
Pos: expr.Pos(),
|
||||
End: expr.End(),
|
||||
|
|
Loading…
Add table
Reference in a new issue