-
-
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.
- Loading branch information
1 parent
a9dc1ce
commit 5f99c2e
Showing
6 changed files
with
118 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package golinters | ||
|
||
import ( | ||
"github.com/sashamelentyev/reusestdlibvars/pkg/analyzer" | ||
"golang.org/x/tools/go/analysis" | ||
|
||
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis" | ||
) | ||
|
||
func NewReuseStdlibVars() *goanalysis.Linter { | ||
a := analyzer.New() | ||
|
||
return goanalysis.NewLinter( | ||
a.Name, | ||
a.Doc, | ||
[]*analysis.Analyzer{a}, | ||
nil, | ||
).WithLoadMode(goanalysis.LoadModeSyntax) | ||
} |
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,89 @@ | ||
//golangcitest:args -Ereusestdlibvars | ||
package testdata | ||
|
||
import "net/http" | ||
|
||
func _200() { | ||
_ = 200 | ||
} | ||
|
||
func _200_1() { | ||
var w http.ResponseWriter | ||
w.WriteHeader(200) // ERROR `can use http.StatusOK instead "200"` | ||
} | ||
|
||
func sunday() { | ||
_ = "Sunday" // ERROR `can use time.Sunday.String\(\) instead "Sunday"` | ||
} | ||
|
||
func monday() { | ||
_ = "Monday" // ERROR `can use time.Monday.String\(\) instead "Monday"` | ||
} | ||
|
||
func tuesday() { | ||
_ = "Tuesday" // ERROR `can use time.Tuesday.String\(\) instead "Tuesday"` | ||
} | ||
|
||
func wednesday() { | ||
_ = "Wednesday" // ERROR `can use time.Wednesday.String\(\) instead "Wednesday"` | ||
} | ||
|
||
func thursday() { | ||
_ = "Thursday" // ERROR `can use time.Thursday.String\(\) instead "Thursday"` | ||
} | ||
|
||
func friday() { | ||
_ = "Friday" // ERROR `can use time.Friday.String\(\) instead "Friday"` | ||
} | ||
|
||
func saturday() { | ||
_ = "Saturday" // ERROR `can use time.Saturday.String\(\) instead "Saturday"` | ||
} | ||
|
||
func january() { | ||
_ = "January" // ERROR `can use time.January.String\(\) instead "January"` | ||
} | ||
|
||
func february() { | ||
_ = "February" // ERROR `can use time.February.String\(\) instead "February"` | ||
} | ||
|
||
func march() { | ||
_ = "March" // ERROR `can use time.March.String\(\) instead "March"` | ||
} | ||
|
||
func april() { | ||
_ = "April" // ERROR `can use time.April.String\(\) instead "April"` | ||
} | ||
|
||
func may() { | ||
_ = "May" // ERROR `can use time.May.String\(\) instead "May"` | ||
} | ||
|
||
func june() { | ||
_ = "June" // ERROR `can use time.June.String\(\) instead "June"` | ||
} | ||
|
||
func july() { | ||
_ = "July" // ERROR `can use time.July.String\(\) instead "July"` | ||
} | ||
|
||
func august() { | ||
_ = "August" // ERROR `can use time.August.String\(\) instead "August"` | ||
} | ||
|
||
func september() { | ||
_ = "September" // ERROR `can use time.September.String\(\) instead "September"` | ||
} | ||
|
||
func october() { | ||
_ = "October" // ERROR `can use time.October.String\(\) instead "October"` | ||
} | ||
|
||
func november() { | ||
_ = "November" // ERROR `can use time.November.String\(\) instead "November"` | ||
} | ||
|
||
func december() { | ||
_ = "December" // ERROR `can use time.December.String\(\) instead "December"` | ||
} |