From 1bf80fd6c744e4b07b95ddb529b24805a8ccc999 Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Thu, 21 Oct 2021 20:02:06 +0200 Subject: [PATCH] checkers/preferFprint: fix docs --- checkers/rules/rules.go | 2 +- checkers/rulesdata/rulesdata.go | 2 +- docs/overview.md | 71 ++++++++++++++++++--------------- 3 files changed, 40 insertions(+), 35 deletions(-) diff --git a/checkers/rules/rules.go b/checkers/rules/rules.go index 447a87544..188ac3c66 100644 --- a/checkers/rules/rules.go +++ b/checkers/rules/rules.go @@ -339,7 +339,7 @@ func preferWriteByte(m dsl.Matcher) { ).Report(`consider replacing $$ with $w.WriteByte($c)`) } -//doc:summary Detects fmt.Sprint(f|ln) calls which can be replaced with fmt.Fprint(f|ln) +//doc:summary Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln) //doc:tags performance experimental //doc:before w.Write([]byte(fmt.Sprintf("%x", 10))) //doc:after fmt.Fprintf(w, "%x", 10) diff --git a/checkers/rulesdata/rulesdata.go b/checkers/rulesdata/rulesdata.go index c53265e31..252dd17cf 100644 --- a/checkers/rulesdata/rulesdata.go +++ b/checkers/rulesdata/rulesdata.go @@ -1432,7 +1432,7 @@ var PrecompiledRules = &ir.File{ "performance", "experimental", }, - DocSummary: "Detects fmt.Sprint(f|ln) calls which can be replaced with fmt.Fprint(f|ln)", + DocSummary: "Detects fmt.Sprint(f/ln) calls which can be replaced with fmt.Fprint(f/ln)", DocBefore: "w.Write([]byte(fmt.Sprintf(\"%x\", 10)))", DocAfter: "fmt.Fprintf(w, \"%x\", 10)", Rules: []ir.Rule{ diff --git a/docs/overview.md b/docs/overview.md index d26b554ec..a5945dfb8 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -52,6 +52,11 @@ They also detect code that may be correct, but looks suspicious. badRegexp Detects suspicious regexp patterns + + :white_check_mark: + badSorting + + Detects bad usage of sort package :white_check_mark: builtinShadowDecl @@ -182,11 +187,6 @@ They also detect code that may be correct, but looks suspicious. sqlQuery Detects issue in Query() and Exec() calls - - :white_check_mark: - suspiciousSorting - - Detects bad usage of sort package :white_check_mark: syncMapLoadAndDelete @@ -755,6 +755,31 @@ regexp.MustCompile(`^(?:aa|bb|cc)foo[ab]`) + +## badSorting + +[ + **diagnostic** + **experimental** ] + +Detects bad usage of sort package. + + + + + +**Before:** +```go +xs = sort.StringSlice(xs) +``` + +**After:** +```go +sort.Strings(xs) +``` + + + ## boolExprSimplify @@ -2423,12 +2448,12 @@ Detects suspicious http.Error call without following return. **Before:** ```go -x + string(os.PathSeparator) + y +if err != nil { http.Error(...); } ``` **After:** ```go -filepath.Join(x, y) +if err != nil { http.Error(...); return; } ``` @@ -2467,12 +2492,17 @@ Checker parameters:
  • - `@ruleguard.failOnError` Determines the behavior when an error occurs while parsing ruleguard files. + `@ruleguard.failOn` Determines the behavior when an error occurs while parsing ruleguard files. If flag is not set, log error and skip rule files that contain an error. If flag is set, the value must be a comma-separated list of error conditions. * 'import': rule refers to a package that cannot be loaded. * 'dsl': gorule file does not comply with the ruleguard DSL. (default ) +
  • +
  • + + `@ruleguard.failOnError` deprecated, use failOn param; if set to true, identical to failOn='all', otherwise failOn='' (default false) +
  • @@ -2738,31 +2768,6 @@ copy(b, s) - -## suspiciousSorting - -[ - **diagnostic** - **experimental** ] - -Detects bad usage of sort package. - - - - - -**Before:** -```go -xs = sort.StringSlice(xs) -``` - -**After:** -```go -sort.Strings(xs) -``` - - - ## switchTrue