Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip more add new files run command fixes more * go.mod * order * same package * review comment * enable linter in .golangci.yml * add testcase for default-signifies-exhaustive: true * adjust runGoErrchk instead * disable the linter * cleanup * more cleanup * cleanup
- Loading branch information
Showing
12 changed files
with
102 additions
and
6 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package golinters | ||
|
||
import ( | ||
"github.com/nishanths/exhaustive" | ||
"golang.org/x/tools/go/analysis" | ||
|
||
"github.com/golangci/golangci-lint/pkg/config" | ||
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis" | ||
) | ||
|
||
func NewExhaustive(settings *config.ExhaustiveSettings) *goanalysis.Linter { | ||
a := exhaustive.Analyzer | ||
|
||
var cfg map[string]map[string]interface{} | ||
if settings != nil { | ||
cfg = map[string]map[string]interface{}{ | ||
a.Name: { | ||
exhaustive.DefaultSignifiesExhaustiveFlag: settings.DefaultSignifiesExhaustive, | ||
}, | ||
} | ||
} | ||
|
||
return goanalysis.NewLinter(a.Name, a.Doc, []*analysis.Analyzer{a}, cfg). | ||
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
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
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,3 @@ | ||
linters-settings: | ||
exhaustive: | ||
default-signifies-exhaustive: true |
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,17 @@ | ||
//args: -Eexhaustive | ||
package testdata | ||
|
||
type Direction int | ||
|
||
const ( | ||
North Direction = iota | ||
East | ||
South | ||
West | ||
) | ||
|
||
func processDirection(d Direction) { | ||
switch d { // ERROR "missing cases in switch of type Direction: East, West" | ||
case North, South: | ||
} | ||
} |
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,19 @@ | ||
//args: -Eexhaustive | ||
//config_path: testdata/configs/exhaustive.yml | ||
package testdata | ||
|
||
type Direction int | ||
|
||
const ( | ||
North Direction = iota | ||
East | ||
South | ||
West | ||
) | ||
|
||
func processDirectionDefault(d Direction) { | ||
switch d { | ||
case North, South: | ||
default: | ||
} | ||
} |