diff --git a/cmd/makedocs/main.go b/cmd/makedocs/main.go
index 671e48a55..318d370b2 100644
--- a/cmd/makedocs/main.go
+++ b/cmd/makedocs/main.go
@@ -16,9 +16,12 @@ const (
)
func main() {
- tmpl := template.Must(template.ParseFiles(templatesPath + "overview.md.tmpl"))
+ tmpl := parseTemplate(
+ "overview.md.tmpl",
+ "checker_tr.partial.tmpl")
+
buf := bytes.Buffer{}
- err := tmpl.Execute(&buf, struct {
+ err := tmpl.ExecuteTemplate(&buf, "overview", struct {
Checkers []*lintpack.CheckerInfo
}{
Checkers: lintpack.GetCheckersInfo(),
@@ -30,3 +33,11 @@ func main() {
log.Fatalf("write output file: %v", err)
}
}
+
+func parseTemplate(names ...string) *template.Template {
+ paths := make([]string, len(names))
+ for i := range names {
+ paths[i] = templatesPath + names[i]
+ }
+ return template.Must(template.ParseFiles(paths...))
+}
diff --git a/docs/overview.md b/docs/overview.md
index 7efadfd44..fb8302f99 100644
--- a/docs/overview.md
+++ b/docs/overview.md
@@ -4,253 +4,356 @@ This page describes checks supported by [go-critic](https://github.com/go-critic
[//]: # (This is generated file, please don't edit it yourself.)
-## Checkers:
+## Checkers
+
+* :heavy_check_mark: checker is enabled by default.
+* :white_check_mark: checker is disabled by default.
+
+### Checkers from the "diagnostic" group
+
+Diagnostics try to find programming errors in the code.
+They also detect code that may be correct, but looks suspicious.
+
+> All diagnostics are enabled by default (unless it has "experimental" tag).
Name |
Short description |
-
-
- appendAssign |
- Detects suspicious append result assignments |
-
-
- appendCombine |
- Detects `append` chains to the same slice that can be done in a single `append` call |
-
-
- argOrder |
- Detects suspicious arguments order |
-
-
- assignOp |
- Detects assignments that can be simplified by using assignment operators |
-
-
- badCond |
- Detects suspicious condition expressions |
-
-
- boolExprSimplify |
- Detects bool expressions that can be simplified |
-
-
- builtinShadow |
- Detects when predeclared identifiers shadowed in assignments |
-
-
- captLocal |
- Detects capitalized names for local variables |
-
-
- caseOrder |
- Detects erroneous case order inside switch statements |
-
-
- codegenComment |
- Detects malformed 'code generated' file comments |
-
-
- commentFormatting |
- Detects comments with non-idiomatic formatting |
-
-
- commentedOutCode |
- Detects commented-out code inside function bodies |
-
-
- commentedOutImport |
- Detects commented-out imports |
-
-
- defaultCaseOrder |
- Detects when default case in switch isn't on 1st or last position |
-
-
- deprecatedComment |
- Detects malformed 'deprecated' doc-comments |
-
-
- docStub |
- Detects comments that silence go lint complaints about doc-comment |
-
-
- dupArg |
- Detects suspicious duplicated arguments |
-
-
- dupBranchBody |
- Detects duplicated branch bodies inside conditional statements |
-
-
- dupCase |
- Detects duplicated case clauses inside switch statements |
-
-
- dupSubExpr |
- Detects suspicious duplicated sub-expressions |
-
-
- elseif |
- Detects else with nested if statement that can be replaced with else-if |
-
-
- emptyFallthrough |
- Detects fallthrough that can be avoided by using multi case values |
-
-
- emptyStringTest |
- Detects empty string checks that can be written more idiomatically |
-
-
- equalFold |
- Detects unoptimal strings/bytes case-insensitive comparison |
-
-
- exitAfterDefer |
- Detects calls to exit/fatal inside functions that use defer |
-
-
- flagDeref |
- Detects immediate dereferencing of `flag` package pointers |
-
-
- flagName |
- Detects flag names with whitespace |
-
-
- hexLiteral |
- Detects hex literals that have mixed case letter digits |
-
-
- hugeParam |
- Detects params that incur excessive amount of copying |
-
-
- ifElseChain |
- Detects repeated if-else statements and suggests to replace them with switch statement |
-
-
- importShadow |
- Detects when imported package names shadowed in the assignments |
-
-
- indexAlloc |
- Detects strings.Index calls that may cause unwanted allocs |
-
-
- initClause |
- Detects non-assignment statements inside if/switch init clause |
-
-
- methodExprCall |
- Detects method expression call that can be replaced with a method call |
-
-
- nestingReduce |
- Finds where nesting level could be reduced |
-
-
- nilValReturn |
- Detects return statements those results evaluate to nil |
-
-
- offBy1 |
- Detects various off-by-one kind of errors |
-
-
- paramTypeCombine |
- Detects if function parameters could be combined by type and suggest the way to do it |
-
-
- ptrToRefParam |
- Detects input and output parameters that have a type of pointer to referential type |
-
-
- rangeExprCopy |
- Detects expensive copies of `for` loop range expressions |
-
-
- rangeValCopy |
- Detects loops that copy big objects during each iteration |
-
-
- regexpMust |
- Detects `regexp.Compile*` that can be replaced with `regexp.MustCompile*` |
-
-
- singleCaseSwitch |
- Detects switch statements that could be better written as if statement |
-
-
- sloppyLen |
- Detects usage of `len` when result is obvious or doesn't make sense |
-
-
- sloppyReassign |
- Detects suspicious/confusing re-assignments |
-
-
- stringXbytes |
- Detects redundant conversions between string and []byte |
-
-
- switchTrue |
- Detects switch-over-bool statements that use explicit `true` tag value |
-
-
- typeAssertChain |
- Detects repeated type assertions and suggests to replace them with type switch statement |
-
-
- typeSwitchVar |
- Detects type switches that can benefit from type guard clause with variable |
-
-
- typeUnparen |
- Detects unneded parenthesis inside type expressions and suggests to remove them |
-
-
- underef |
- Detects dereference expressions that can be omitted |
-
-
- unlabelStmt |
- Detects redundant statement labels |
-
-
- unlambda |
- Detects function literals that can be simplified |
-
-
- unnamedResult |
- Detects unnamed results that may benefit from names |
-
-
- unnecessaryBlock |
- Detects unnecessary braced statement blocks |
-
-
- unslice |
- Detects slice expressions that can be simplified to sliced expression itself |
-
-
- valSwap |
- Detects value swapping code that are not using parallel assignment |
-
-
- weakCond |
- Detects conditions that are unsafe due to not being exhaustive |
-
-
- wrapperFunc |
- Detects function calls that can be replaced with convenience wrappers |
-
-
- yodaStyleExpr |
- Detects Yoda style expressions and suggests to replace them |
-
+
+ :heavy_check_mark:
+ appendAssign
+ |
+ Detects suspicious append result assignments |
+
+ :white_check_mark:
+ argOrder
+ |
+ Detects suspicious arguments order |
+
+ :white_check_mark:
+ badCond
+ |
+ Detects suspicious condition expressions |
+
+ :heavy_check_mark:
+ caseOrder
+ |
+ Detects erroneous case order inside switch statements |
+
+ :white_check_mark:
+ codegenComment
+ |
+ Detects malformed 'code generated' file comments |
+
+ :white_check_mark:
+ commentedOutCode
+ |
+ Detects commented-out code inside function bodies |
+
+ :white_check_mark:
+ deprecatedComment
+ |
+ Detects malformed 'deprecated' doc-comments |
+
+ :heavy_check_mark:
+ dupArg
+ |
+ Detects suspicious duplicated arguments |
+
+ :white_check_mark:
+ dupAssign
+ |
+ Detects suspicious re-assignments |
+
+ :heavy_check_mark:
+ dupBranchBody
+ |
+ Detects duplicated branch bodies inside conditional statements |
+
+ :heavy_check_mark:
+ dupCase
+ |
+ Detects duplicated case clauses inside switch statements |
+
+ :heavy_check_mark:
+ dupSubExpr
+ |
+ Detects suspicious duplicated sub-expressions |
+
+ :white_check_mark:
+ exitAfterDefer
+ |
+ Detects calls to exit/fatal inside functions that use defer |
+
+ :heavy_check_mark:
+ flagDeref
+ |
+ Detects immediate dereferencing of `flag` package pointers |
+
+ :white_check_mark:
+ flagName
+ |
+ Detects flag names with whitespace |
+
+ :white_check_mark:
+ nilValReturn
+ |
+ Detects return statements those results evaluate to nil |
+
+ :white_check_mark:
+ offBy1
+ |
+ Detects various off-by-one kind of errors |
+
+ :white_check_mark:
+ sloppyReassign
+ |
+ Detects suspicious/confusing re-assignments |
+
+ :white_check_mark:
+ weakCond
+ |
+ Detects conditions that are unsafe due to not being exhaustive |
+
+
+
+### Checkers from the "style" group
+
+Style checks suggest replacing some form of expression/statement
+with another one that is considered more idiomatic or simple.
+
+> Only non-opinionated style checks are enabled by default.
+
+
+
+ Name |
+ Short description |
+
+ :heavy_check_mark:
+ assignOp
+ |
+ Detects assignments that can be simplified by using assignment operators |
+
+ :white_check_mark:
+ boolExprSimplify
+ |
+ Detects bool expressions that can be simplified |
+
+ :white_check_mark:
+ builtinShadow
+ |
+ Detects when predeclared identifiers shadowed in assignments |
+
+ :heavy_check_mark:
+ captLocal
+ |
+ Detects capitalized names for local variables |
+
+ :white_check_mark:
+ commentFormatting
+ |
+ Detects comments with non-idiomatic formatting |
+
+ :white_check_mark:
+ commentedOutImport
+ |
+ Detects commented-out imports |
+
+ :heavy_check_mark:
+ defaultCaseOrder
+ |
+ Detects when default case in switch isn't on 1st or last position |
+
+ :white_check_mark:
+ docStub
+ |
+ Detects comments that silence go lint complaints about doc-comment |
+
+ :heavy_check_mark:
+ elseif
+ |
+ Detects else with nested if statement that can be replaced with else-if |
+
+ :white_check_mark:
+ emptyFallthrough
+ |
+ Detects fallthrough that can be avoided by using multi case values |
+
+ :white_check_mark:
+ emptyStringTest
+ |
+ Detects empty string checks that can be written more idiomatically |
+
+ :white_check_mark:
+ hexLiteral
+ |
+ Detects hex literals that have mixed case letter digits |
+
+ :heavy_check_mark:
+ ifElseChain
+ |
+ Detects repeated if-else statements and suggests to replace them with switch statement |
+
+ :white_check_mark:
+ importShadow
+ |
+ Detects when imported package names shadowed in the assignments |
+
+ :white_check_mark:
+ initClause
+ |
+ Detects non-assignment statements inside if/switch init clause |
+
+ :white_check_mark:
+ methodExprCall
+ |
+ Detects method expression call that can be replaced with a method call |
+
+ :white_check_mark:
+ nestingReduce
+ |
+ Finds where nesting level could be reduced |
+
+ :white_check_mark:
+ paramTypeCombine
+ |
+ Detects if function parameters could be combined by type and suggest the way to do it |
+
+ :white_check_mark:
+ ptrToRefParam
+ |
+ Detects input and output parameters that have a type of pointer to referential type |
+
+ :heavy_check_mark:
+ regexpMust
+ |
+ Detects `regexp.Compile*` that can be replaced with `regexp.MustCompile*` |
+
+ :heavy_check_mark:
+ singleCaseSwitch
+ |
+ Detects switch statements that could be better written as if statement |
+
+ :heavy_check_mark:
+ sloppyLen
+ |
+ Detects usage of `len` when result is obvious or doesn't make sense |
+
+ :white_check_mark:
+ stringXbytes
+ |
+ Detects redundant conversions between string and []byte |
+
+ :heavy_check_mark:
+ switchTrue
+ |
+ Detects switch-over-bool statements that use explicit `true` tag value |
+
+ :white_check_mark:
+ typeAssertChain
+ |
+ Detects repeated type assertions and suggests to replace them with type switch statement |
+
+ :heavy_check_mark:
+ typeSwitchVar
+ |
+ Detects type switches that can benefit from type guard clause with variable |
+
+ :white_check_mark:
+ typeUnparen
+ |
+ Detects unneded parenthesis inside type expressions and suggests to remove them |
+
+ :heavy_check_mark:
+ underef
+ |
+ Detects dereference expressions that can be omitted |
+
+ :white_check_mark:
+ unlabelStmt
+ |
+ Detects redundant statement labels |
+
+ :heavy_check_mark:
+ unlambda
+ |
+ Detects function literals that can be simplified |
+
+ :white_check_mark:
+ unnamedResult
+ |
+ Detects unnamed results that may benefit from names |
+
+ :white_check_mark:
+ unnecessaryBlock
+ |
+ Detects unnecessary braced statement blocks |
+
+ :heavy_check_mark:
+ unslice
+ |
+ Detects slice expressions that can be simplified to sliced expression itself |
+
+ :white_check_mark:
+ valSwap
+ |
+ Detects value swapping code that are not using parallel assignment |
+
+ :white_check_mark:
+ wrapperFunc
+ |
+ Detects function calls that can be replaced with convenience wrappers |
+
+ :white_check_mark:
+ yodaStyleExpr
+ |
+ Detects Yoda style expressions and suggests to replace them |
+
+
+
+### Checkers from the "performance" group
+
+Performance checks tell you about potential issues that
+can make your code run slower than it could be.
+
+> All performance checks are disabled by default.
+
+