-
-
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.
review fixes & go-critic tests improving
- Loading branch information
Showing
9 changed files
with
85 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
This directory contains ruleguard files that are used in functional tests. | ||
This directory contains ruleguard files that are used in functional tests: | ||
|
||
```bash | ||
T=gocritic.go make test_linters | ||
``` | ||
|
||
```bash | ||
T=gocritic.go make test_fix | ||
``` | ||
|
||
Helpful: | ||
|
||
- https://go-critic.com/overview.html | ||
- https://github.com/go-critic/go-critic/blob/master/checkers/rules/rules.go |
This file was deleted.
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,12 @@ | ||
//go:build ruleguard | ||
|
||
package ruleguard | ||
|
||
import "github.com/quasilyte/go-ruleguard/dsl" | ||
|
||
func preferWriteString(m dsl.Matcher) { | ||
m.Match(`$w.Write([]byte($s))`). | ||
Where(m["w"].Type.Implements("io.StringWriter")). | ||
Suggest("$w.WriteString($s)"). | ||
Report(`$w.WriteString($s) should be preferred to the $$`) | ||
} |
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 |
---|---|---|
|
@@ -5,4 +5,3 @@ linters-settings: | |
settings: | ||
ruleguard: | ||
rules: 'ruleguard/rangeExprCopy.go,ruleguard/strings_simplify.go' | ||
|
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
linters-settings: | ||
gocritic: | ||
disabled-checks: | ||
- appendAssign | ||
- switchTrue | ||
enabled-checks: | ||
- rangeValCopy | ||
- hugeParam | ||
- ruleguard | ||
disabled-checks: | ||
- dupSubExpr # So as not to overlap `ruleguard`. | ||
settings: | ||
rangeValCopy: | ||
sizeThreshold: 2 | ||
hugeParam: | ||
sizeThreshold: 24 | ||
ruleguard: | ||
debug: dupSubExpr | ||
failOn: dsl,import | ||
# comma-separated paths to ruleguard files. | ||
# Comma-separated paths to ruleguard files. | ||
# The ${configDir} is substituted by the directory containing the golangci-lint config file. | ||
# Note about the directory structure for functional tests: | ||
# The ruleguard files used in functional tests cannot be under the 'testdata' directory. | ||
# This is because they import the 'github.com/quasilyte/go-ruleguard/dsl' package, | ||
# which needs to be added to go.mod. The testdata directory is ignored by go mod. | ||
rules: '${configDir}/../../ruleguard/strings_simplify.go,${configDir}/../../ruleguard/dup.go' | ||
rules: '${configDir}/../../ruleguard/preferWriteString.go,${configDir}/../../ruleguard/stringsSimplify.go' |
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