@@ -167,7 +167,7 @@ func checkExpression(pass *analysis.Pass, exprSuppress types.Suppress, actualArg
167
167
return checkLengthMatcher (assertionExp , pass , handler , oldExpr )
168
168
} else {
169
169
if nilable , compOp := getNilableFromComparison (actualArg ); nilable != nil {
170
- if IsExprError (pass , nilable ) {
170
+ if isExprError (pass , nilable ) {
171
171
if exprSuppress .Err {
172
172
return true
173
173
}
@@ -177,7 +177,7 @@ func checkExpression(pass *analysis.Pass, exprSuppress types.Suppress, actualArg
177
177
178
178
return checkNilMatcher (assertionExp , pass , nilable , handler , compOp == token .NEQ , oldExpr )
179
179
180
- } else if IsExprError (pass , actualArg ) {
180
+ } else if isExprError (pass , actualArg ) {
181
181
return bool (exprSuppress .Err ) || checkNilError (pass , assertionExp , handler , actualArg , oldExpr )
182
182
183
183
} else {
@@ -521,26 +521,26 @@ func handleEqualNilMatcher(matcher *ast.CallExpr, pass *analysis.Pass, exp *ast.
521
521
return
522
522
}
523
523
524
- newFuncName , isError := handleNilComparisonErr (pass , exp , nilable )
524
+ newFuncName , isItError := handleNilComparisonErr (pass , exp , nilable )
525
525
526
526
handler .ReplaceFunction (exp .Args [0 ].(* ast.CallExpr ), ast .NewIdent (newFuncName ))
527
527
exp .Args [0 ].(* ast.CallExpr ).Args = nil
528
528
529
- reportNilAssertion (pass , exp , handler , nilable , notEqual , oldExp , isError )
529
+ reportNilAssertion (pass , exp , handler , nilable , notEqual , oldExp , isItError )
530
530
}
531
531
532
532
func handleNilBeBoolMatcher (pass * analysis.Pass , exp * ast.CallExpr , handler gomegahandler.Handler , nilable ast.Expr , notEqual bool , oldExp string ) {
533
- newFuncName , isError := handleNilComparisonErr (pass , exp , nilable )
533
+ newFuncName , isItError := handleNilComparisonErr (pass , exp , nilable )
534
534
handler .ReplaceFunction (exp .Args [0 ].(* ast.CallExpr ), ast .NewIdent (newFuncName ))
535
535
exp .Args [0 ].(* ast.CallExpr ).Args = nil
536
536
537
- reportNilAssertion (pass , exp , handler , nilable , notEqual , oldExp , isError )
537
+ reportNilAssertion (pass , exp , handler , nilable , notEqual , oldExp , isItError )
538
538
}
539
539
540
540
func handleNilComparisonErr (pass * analysis.Pass , exp * ast.CallExpr , nilable ast.Expr ) (string , bool ) {
541
541
newFuncName := beNil
542
- isError := IsExprError (pass , nilable )
543
- if isError {
542
+ isItError := isExprError (pass , nilable )
543
+ if isItError {
544
544
if _ , ok := nilable .(* ast.CallExpr ); ok {
545
545
newFuncName = succeed
546
546
} else {
@@ -549,7 +549,7 @@ func handleNilComparisonErr(pass *analysis.Pass, exp *ast.CallExpr, nilable ast.
549
549
}
550
550
}
551
551
552
- return newFuncName , isError
552
+ return newFuncName , isItError
553
553
}
554
554
func isAssertionFunc (name string ) bool {
555
555
switch name {
@@ -565,7 +565,7 @@ func reportLengthAssertion(pass *analysis.Pass, expr *ast.CallExpr, handler gome
565
565
report (pass , expr , wrongLengthWarningTemplate , oldExpr )
566
566
}
567
567
568
- func reportNilAssertion (pass * analysis.Pass , expr * ast.CallExpr , handler gomegahandler.Handler , nilable ast.Expr , notEqual bool , oldExpr string , isError bool ) {
568
+ func reportNilAssertion (pass * analysis.Pass , expr * ast.CallExpr , handler gomegahandler.Handler , nilable ast.Expr , notEqual bool , oldExpr string , isItError bool ) {
569
569
changed := replaceNilActualArg (expr .Fun .(* ast.SelectorExpr ).X .(* ast.CallExpr ), handler , nilable )
570
570
if ! changed {
571
571
return
@@ -575,7 +575,7 @@ func reportNilAssertion(pass *analysis.Pass, expr *ast.CallExpr, handler gomegah
575
575
reverseAssertionFuncLogic (expr )
576
576
}
577
577
template := wrongNilWarningTemplate
578
- if isError {
578
+ if isItError {
579
579
template = wrongErrWarningTemplate
580
580
}
581
581
@@ -636,22 +636,22 @@ func init() {
636
636
errorType = gotypes .Universe .Lookup ("error" ).Type ().Underlying ().(* gotypes.Interface )
637
637
}
638
638
639
- func IsError (t gotypes.Type ) bool {
639
+ func isError (t gotypes.Type ) bool {
640
640
return gotypes .Implements (t , errorType )
641
641
}
642
642
643
- func IsExprError (pass * analysis.Pass , expr ast.Expr ) bool {
643
+ func isExprError (pass * analysis.Pass , expr ast.Expr ) bool {
644
644
actualArgType := pass .TypesInfo .TypeOf (expr )
645
645
switch t := actualArgType .(type ) {
646
646
case * gotypes.Named :
647
- if IsError (actualArgType ) {
647
+ if isError (actualArgType ) {
648
648
return true
649
649
}
650
650
case * gotypes.Tuple :
651
651
if t .Len () > 0 {
652
652
switch t0 := t .At (0 ).Type ().(type ) {
653
653
case * gotypes.Named , * gotypes.Pointer :
654
- if IsError (t0 ) {
654
+ if isError (t0 ) {
655
655
return true
656
656
}
657
657
}
0 commit comments