Skip to content

Commit

Permalink
cmd/makedocs: fix headers formatting (go-critic#803)
Browse files Browse the repository at this point in the history
The problem was caused by checker params list
that included (for some reason) the next header.

To avoid whitespace-driven decisions, use
HTML elements to emit lists, so they are closed
before next checker heading starts.

Also added octalLiteral checker docs.

Fixes go-critic#802

Signed-off-by: Iskander Sharipov <[email protected]>
  • Loading branch information
quasilyte authored Feb 10, 2019
1 parent 765907a commit ee9bf58
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 13 deletions.
122 changes: 112 additions & 10 deletions docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ They also detect code that may be correct, but looks suspicious.
<a href="#nilValReturn-ref">nilValReturn</a>
</td>
<td>Detects return statements those results evaluate to nil</td>
</tr><tr>
<td nowrap>:white_check_mark:
<a href="#octalLiteral-ref">octalLiteral</a>
</td>
<td>Detects octal literals passed to functions</td>
</tr><tr>
<td nowrap>:white_check_mark:
<a href="#offBy1-ref">offBy1</a>
Expand Down Expand Up @@ -557,7 +562,15 @@ func f(in int, out *int) (err error) {}


Checker parameters:
* `@captLocal.paramsOnly` whether to restrict checker to params only (default true)
<ul>
<li>

`@captLocal.paramsOnly` whether to restrict checker to params only (default true)

</li>

</ul>


<a name="caseOrder-ref"></a>
## caseOrder
Expand Down Expand Up @@ -937,7 +950,15 @@ if cond1 {


Checker parameters:
* `@elseif.skipBalanced` whether to skip balanced if-else pairs (default true)
<ul>
<li>

`@elseif.skipBalanced` whether to skip balanced if-else pairs (default true)

</li>

</ul>


<a name="emptyFallthrough-ref"></a>
## emptyFallthrough
Expand Down Expand Up @@ -1161,7 +1182,15 @@ func f(x *[1024]int) {}


Checker parameters:
* `@hugeParam.sizeThreshold` size in bytes that makes the warning trigger (default 80)
<ul>
<li>

`@hugeParam.sizeThreshold` size in bytes that makes the warning trigger (default 80)

</li>

</ul>


<a name="ifElseChain-ref"></a>
## ifElseChain
Expand Down Expand Up @@ -1345,7 +1374,15 @@ for _, v := range a {


Checker parameters:
* `@nestingReduce.bodyWidth` min number of statements inside a branch to trigger a warning (default 5)
<ul>
<li>

`@nestingReduce.bodyWidth` min number of statements inside a branch to trigger a warning (default 5)

</li>

</ul>


<a name="nilValReturn-ref"></a>
## nilValReturn
Expand Down Expand Up @@ -1381,6 +1418,31 @@ if err != nil {



<a name="octalLiteral-ref"></a>
## octalLiteral

[
**diagnostic**
**experimental** ]

Detects octal literals passed to functions.





**Before:**
```go
foo(02)
```

**After:**
```go
foo(2)
```



<a name="offBy1-ref"></a>
## offBy1

Expand Down Expand Up @@ -1488,8 +1550,20 @@ for _, x := range &xs { // No copy


Checker parameters:
* `@rangeExprCopy.sizeThreshold` size in bytes that makes the warning trigger (default 512)
* `@rangeExprCopy.skipTestFuncs` whether to check test functions (default true)
<ul>
<li>

`@rangeExprCopy.sizeThreshold` size in bytes that makes the warning trigger (default 512)

</li>
<li>

`@rangeExprCopy.skipTestFuncs` whether to check test functions (default true)

</li>

</ul>


<a name="rangeValCopy-ref"></a>
## rangeValCopy
Expand Down Expand Up @@ -1522,8 +1596,20 @@ for i := range xs {


Checker parameters:
* `@rangeValCopy.sizeThreshold` size in bytes that makes the warning trigger (default 128)
* `@rangeValCopy.skipTestFuncs` whether to check test functions (default true)
<ul>
<li>

`@rangeValCopy.sizeThreshold` size in bytes that makes the warning trigger (default 128)

</li>
<li>

`@rangeValCopy.skipTestFuncs` whether to check test functions (default true)

</li>

</ul>


<a name="regexpMust-ref"></a>
## regexpMust
Expand Down Expand Up @@ -1810,7 +1896,15 @@ v := a[5]


Checker parameters:
* `@underef.skipRecvDeref` whether to skip (*x).method() calls where x is a pointer receiver (default true)
<ul>
<li>

`@underef.skipRecvDeref` whether to skip (*x).method() calls where x is a pointer receiver (default true)

</li>

</ul>


<a name="unlabelStmt-ref"></a>
## unlabelStmt
Expand Down Expand Up @@ -1896,7 +1990,15 @@ func f() (x, y float64)


Checker parameters:
* `@unnamedResult.checkExported` whether to check exported functions (default false)
<ul>
<li>

`@unnamedResult.checkExported` whether to check exported functions (default false)

</li>

</ul>


<a name="unnecessaryBlock-ref"></a>
## unnecessaryBlock
Expand Down
14 changes: 11 additions & 3 deletions docs/templates/checker.partial.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,17 @@

{{ if .Params }}
Checker parameters:
<ul>

{{- range $key, $_ := .Params }}
* `@{{$.Name}}.{{$key}}` {{.Usage}} (default {{.Value}})
{{- end }}
<li>

`@{{$.Name}}.{{$key}}` {{.Usage}} (default {{.Value}})

</li>
{{- end }}

{{- end }}
</ul>
{{ end }}

{{- end }}

0 comments on commit ee9bf58

Please sign in to comment.