-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
- Loading branch information
Showing
9 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -397,6 +397,7 @@ | |
"nakedret", | ||
"nestif", | ||
"nilerr", | ||
"nilnesserr", | ||
"nilnil", | ||
"nlreturn", | ||
"noctx", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package nilnesserr | ||
|
||
import ( | ||
"github.com/alingse/nilnesserr" | ||
"golang.org/x/tools/go/analysis" | ||
|
||
"github.com/golangci/golangci-lint/pkg/goanalysis" | ||
"github.com/golangci/golangci-lint/pkg/golinters/internal" | ||
) | ||
|
||
func New() *goanalysis.Linter { | ||
a, err := nilnesserr.NewAnalyzer(nilnesserr.LinterSetting{}) | ||
if err != nil { | ||
internal.LinterLogger.Fatalf("nilnesserr: create analyzer: %v", err) | ||
} | ||
|
||
return goanalysis.NewLinter( | ||
a.Name, | ||
a.Doc, | ||
[]*analysis.Analyzer{a}, | ||
nil, | ||
).WithLoadMode(goanalysis.LoadModeTypesInfo) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package nilnesserr | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/golangci/golangci-lint/test/testshared/integration" | ||
) | ||
|
||
func TestFromTestdata(t *testing.T) { | ||
integration.RunTestdata(t) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//golangcitest:args -Enilnesserr | ||
package testdata | ||
|
||
import "fmt" | ||
|
||
func do() error { | ||
return fmt.Errorf("do error") | ||
} | ||
|
||
func do2() error { | ||
return fmt.Errorf("do2 error") | ||
} | ||
|
||
func someCall() error { | ||
err := do() | ||
if err != nil { | ||
return err | ||
} | ||
err2 := do2() | ||
if err2 != nil { | ||
return err // want `return a nil value error after check error` | ||
} | ||
return nil | ||
} | ||
|
||
func sameCall2() error { | ||
err := do() | ||
if err == nil { | ||
err2 := do2() | ||
if err2 != nil { | ||
return err // want `return a nil value error after check error` | ||
} | ||
return nil | ||
} | ||
return err | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//golangcitest:args -Enilnesserr | ||
package testdata | ||
|
||
/* | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
void myprint(char* s) { | ||
printf("%d\n", s); | ||
} | ||
*/ | ||
import "C" | ||
|
||
import ( | ||
"fmt" | ||
"unsafe" | ||
) | ||
|
||
func _() { | ||
cs := C.CString("Hello from stdio\n") | ||
C.myprint(cs) | ||
C.free(unsafe.Pointer(cs)) | ||
} | ||
|
||
func do() error { | ||
return fmt.Errorf("do error") | ||
} | ||
|
||
func do2() error { | ||
return fmt.Errorf("do2 error") | ||
} | ||
|
||
func someCall() error { | ||
err := do() | ||
if err != nil { | ||
return err | ||
} | ||
err2 := do2() | ||
if err2 != nil { | ||
return err // want `return a nil value error after check error` | ||
} | ||
return nil | ||
} | ||
|
||
func sameCall2() error { | ||
err := do() | ||
if err == nil { | ||
err2 := do2() | ||
if err2 != nil { | ||
return err // want `return a nil value error after check error` | ||
} | ||
return nil | ||
} | ||
return err | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters