1
0
mirror of https://github.com/mgechev/revive.git synced 2025-10-08 22:41:54 +02:00

docs: update TOC; check for TOC consistency in GHA (#1493)

This commit is contained in:
Oleksandr Redko
2025-08-28 17:54:28 +03:00
committed by GitHub
parent e1d05f7a0e
commit 0e76b4d0b4
4 changed files with 179 additions and 151 deletions

View File

@@ -72,11 +72,24 @@ jobs:
# https://taplo.tamasfe.dev/cli/installation/binary.html # https://taplo.tamasfe.dev/cli/installation/binary.html
run: curl -fsSL https://github.com/tamasfe/taplo/releases/download/0.10.0/taplo-linux-x86_64.gz | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo run: curl -fsSL https://github.com/tamasfe/taplo/releases/download/0.10.0/taplo-linux-x86_64.gz | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install markdown-toc
run: npm install -g markdown-toc
- name: Verify files format using markdownlint-cli2 - name: Verify files format using markdownlint-cli2
uses: DavidAnson/markdownlint-cli2-action@v20 uses: DavidAnson/markdownlint-cli2-action@v20
with: with:
config: .markdownlint-cli2.yaml config: .markdownlint-cli2.yaml
- name: Verify TOC in markdown files
run: |
markdown-toc --maxdepth 4 --no-first1 --bullets "-" -i README.md && git diff --exit-code README.md
markdown-toc --maxdepth 2 --no-first1 --bullets "-" -i RULES_DESCRIPTIONS.md && git diff --exit-code RULES_DESCRIPTIONS.md
- name: Verify code snippets using mdsf - name: Verify code snippets using mdsf
id: verify_snippets id: verify_snippets
run: mdsf verify --on-missing-language-definition ignore --on-missing-tool-binary fail-fast . run: mdsf verify --on-missing-language-definition ignore --on-missing-tool-binary fail-fast .

View File

@@ -93,15 +93,20 @@ type Formatter interface {
### Lint Markdown files ### Lint Markdown files
We use [markdownlint](https://github.com/DavidAnson/markdownlint) and [mdsf](https://github.com/hougesen/mdsf) to check Markdown files. We use [markdownlint](https://github.com/DavidAnson/markdownlint),
`markdownlint` verifies document formatting, such as line length and empty lines, while `mdsf` is responsible for formatting code snippets. [markdown-toc](https://github.com/jonschlinkert/markdown-toc),
and [mdsf](https://github.com/hougesen/mdsf) to check Markdown files.
`markdownlint` verifies document formatting, such as line length and empty lines.
`markdown-toc` checks the entries in the table of contents.
`mdsf` is responsible for formatting code snippets.
1. Install [markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2#install). 1. Install [markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2#install).
2. Install [mdsf](https://mdsf.mhouge.dk/#installation) and formatters: 2. Install [markdown-toc](https://github.com/jonschlinkert/markdown-toc#quick-start).
3. Install [mdsf](https://mdsf.mhouge.dk/#installation) and formatters:
- [goimports](https://pkg.go.dev/golang.org/x/tools/cmd/goimports) for `go`: `go install golang.org/x/tools/cmd/goimports@latest` - [goimports](https://pkg.go.dev/golang.org/x/tools/cmd/goimports) for `go`: `go install golang.org/x/tools/cmd/goimports@latest`
- [shfmt](https://github.com/mvdan/sh#shfmt) for `sh, shell, bash`: `go install mvdan.cc/sh/v3/cmd/shfmt@latest` - [shfmt](https://github.com/mvdan/sh#shfmt) for `sh, shell, bash`: `go install mvdan.cc/sh/v3/cmd/shfmt@latest`
- [taplo](https://taplo.tamasfe.dev/cli/installation/binary.html) for `toml` - [taplo](https://taplo.tamasfe.dev/cli/installation/binary.html) for `toml`
3. Run the following command to check formatting: 4. Run the following command to check formatting:
```shellsession ```shellsession
$ markdownlint-cli2 . $ markdownlint-cli2 .
@@ -118,7 +123,15 @@ Summary: 0 error(s)
_The `markdownlint-cli2` tool automatically uses the config file [.markdownlint-cli2.yaml](./.markdownlint-cli2.yaml)._ _The `markdownlint-cli2` tool automatically uses the config file [.markdownlint-cli2.yaml](./.markdownlint-cli2.yaml)._
\ \
4. Run the following commands to verify and format code snippets: 4. Run the following command to check TOC:
```sh
markdown-toc --maxdepth 4 --no-first1 --bullets "-" -i README.md && git diff --exit-code README.md
markdown-toc --maxdepth 2 --no-first1 --bullets "-" -i RULES_DESCRIPTIONS.md && git diff --exit-code RULES_DESCRIPTIONS.md
```
\
5. Run the following commands to verify and format code snippets:
```sh ```sh
mdsf verify . mdsf verify .

View File

@@ -32,57 +32,56 @@ If you disable them in the config file, revive will run over 6x faster than goli
<img src="./assets/demo.svg" alt="" width="700"> <img src="./assets/demo.svg" alt="" width="700">
</p> </p>
<!-- TOC --> <!-- toc -->
- [revive](#revive) - [Installation](#installation)
- [Installation](#installation) - [Homebrew](#homebrew)
- [Homebrew](#homebrew) - [Install from Sources](#install-from-sources)
- [Install from Sources](#install-from-sources) - [Docker](#docker)
- [Docker](#docker) - [Manual Binary Download](#manual-binary-download)
- [Manual Binary Download](#manual-binary-download) - [Usage](#usage)
- [Usage](#usage) - [Bazel](#bazel)
- [Bazel](#bazel) - [Text Editors](#text-editors)
- [Text Editors](#text-editors) - [GitHub Actions](#github-actions)
- [GitHub Actions](#github-actions) - [Continuous Integration](#continuous-integration)
- [Continuous Integration](#continuous-integration) - [Linter aggregators](#linter-aggregators)
- [Linter aggregators](#linter-aggregators) - [golangci-lint](#golangci-lint)
- [golangci-lint](#golangci-lint) - [Command Line Flags](#command-line-flags)
- [Command Line Flags](#command-line-flags) - [Sample Invocations](#sample-invocations)
- [Sample Invocations](#sample-invocations) - [Comment Directives](#comment-directives)
- [Comment Directives](#comment-directives) - [Configuration](#configuration)
- [Configuration](#configuration) - [Default Configuration](#default-configuration)
- [Default Configuration](#default-configuration) - [Custom Configuration](#custom-configuration)
- [Custom Configuration](#custom-configuration) - [Recommended Configuration](#recommended-configuration)
- [Recommended Configuration](#recommended-configuration) - [Rule-level file excludes](#rule-level-file-excludes)
- [Rule-level file excludes](#rule-level-file-excludes) - [Available Rules](#available-rules)
- [Available Rules](#available-rules) - [Configurable rules](#configurable-rules)
- [Configurable rules](#configurable-rules) - [`var-naming`](#var-naming)
- [`var-naming`](#var-naming) - [Available Formatters](#available-formatters)
- [Available Formatters](#available-formatters) - [Friendly](#friendly)
- [Friendly](#friendly) - [Stylish](#stylish)
- [Stylish](#stylish) - [Default](#default)
- [Default](#default) - [Plain](#plain)
- [Plain](#plain) - [Unix](#unix)
- [Unix](#unix) - [JSON](#json)
- [JSON](#json) - [NDJSON](#ndjson)
- [NDJSON](#ndjson) - [Checkstyle](#checkstyle)
- [Checkstyle](#checkstyle) - [SARIF](#sarif)
- [SARIF](#sarif) - [Extensibility](#extensibility)
- [Extensibility](#extensibility) - [Writing a Custom Rule](#writing-a-custom-rule)
- [Writing a Custom Rule](#writing-a-custom-rule) - [Using `revive` as a library](#using-revive-as-a-library)
- [Using `revive` as a library](#using-revive-as-a-library) - [Custom Formatter](#custom-formatter)
- [Custom Formatter](#custom-formatter) - [Speed Comparison](#speed-comparison)
- [Speed Comparison](#speed-comparison) - [golint](#golint)
- [golint](#golint) - [revive's speed](#revives-speed)
- [revive's speed](#revives-speed) - [Overriding colorization detection](#overriding-colorization-detection)
- [Overriding colorization detection](#overriding-colorization-detection) - [Who uses Revive](#who-uses-revive)
- [Who uses Revive](#who-uses-revive) - [Contributors](#contributors)
- [Contributors](#contributors) - [Maintainers](#maintainers)
- [Maintainers](#maintainers) - [All](#all)
- [All](#all) - [License](#license)
- [License](#license)
<!-- /TOC --> <!-- tocstop -->
## Installation ## Installation

View File

@@ -2,103 +2,106 @@
List of all available rules. List of all available rules.
- [Description of available rules](#description-of-available-rules) <!-- toc -->
- [add-constant](#add-constant)
- [argument-limit](#argument-limit) - [add-constant](#add-constant)
- [atomic](#atomic) - [argument-limit](#argument-limit)
- [banned-characters](#banned-characters) - [atomic](#atomic)
- [bare-return](#bare-return) - [banned-characters](#banned-characters)
- [blank-imports](#blank-imports) - [bare-return](#bare-return)
- [bool-literal-in-expr](#bool-literal-in-expr) - [blank-imports](#blank-imports)
- [call-to-gc](#call-to-gc) - [bool-literal-in-expr](#bool-literal-in-expr)
- [cognitive-complexity](#cognitive-complexity) - [call-to-gc](#call-to-gc)
- [comment-spacings](#comment-spacings) - [cognitive-complexity](#cognitive-complexity)
- [comments-density](#comments-density) - [comment-spacings](#comment-spacings)
- [confusing-naming](#confusing-naming) - [comments-density](#comments-density)
- [confusing-results](#confusing-results) - [confusing-naming](#confusing-naming)
- [constant-logical-expr](#constant-logical-expr) - [confusing-results](#confusing-results)
- [context-as-argument](#context-as-argument) - [constant-logical-expr](#constant-logical-expr)
- [context-keys-type](#context-keys-type) - [context-as-argument](#context-as-argument)
- [cyclomatic](#cyclomatic) - [context-keys-type](#context-keys-type)
- [datarace](#datarace) - [cyclomatic](#cyclomatic)
- [deep-exit](#deep-exit) - [datarace](#datarace)
- [defer](#defer) - [deep-exit](#deep-exit)
- [dot-imports](#dot-imports) - [defer](#defer)
- [duplicated-imports](#duplicated-imports) - [dot-imports](#dot-imports)
- [early-return](#early-return) - [duplicated-imports](#duplicated-imports)
- [empty-block](#empty-block) - [early-return](#early-return)
- [empty-lines](#empty-lines) - [empty-block](#empty-block)
- [enforce-map-style](#enforce-map-style) - [empty-lines](#empty-lines)
- [enforce-repeated-arg-type-style](#enforce-repeated-arg-type-style) - [enforce-map-style](#enforce-map-style)
- [enforce-slice-style](#enforce-slice-style) - [enforce-repeated-arg-type-style](#enforce-repeated-arg-type-style)
- [enforce-switch-style](#enforce-switch-style) - [enforce-slice-style](#enforce-slice-style)
- [error-naming](#error-naming) - [enforce-switch-style](#enforce-switch-style)
- [error-return](#error-return) - [error-naming](#error-naming)
- [error-strings](#error-strings) - [error-return](#error-return)
- [errorf](#errorf) - [error-strings](#error-strings)
- [exported](#exported) - [errorf](#errorf)
- [file-header](#file-header) - [exported](#exported)
- [file-length-limit](#file-length-limit) - [file-header](#file-header)
- [filename-format](#filename-format) - [file-length-limit](#file-length-limit)
- [flag-parameter](#flag-parameter) - [filename-format](#filename-format)
- [function-length](#function-length) - [flag-parameter](#flag-parameter)
- [function-result-limit](#function-result-limit) - [function-length](#function-length)
- [get-return](#get-return) - [function-result-limit](#function-result-limit)
- [identical-branches](#identical-branches) - [get-return](#get-return)
- [identical-ifelseif-branches](#identical-ifelseif-branches) - [identical-branches](#identical-branches)
- [identical-ifelseif-conditions](#identical-ifelseif-conditions) - [identical-ifelseif-branches](#identical-ifelseif-branches)
- [identical-switch-branches](#identical-switch-branches) - [identical-ifelseif-conditions](#identical-ifelseif-conditions)
- [identical-switch-conditions](#identical-switch-conditions) - [identical-switch-branches](#identical-switch-branches)
- [if-return](#if-return) - [identical-switch-conditions](#identical-switch-conditions)
- [import-alias-naming](#import-alias-naming) - [if-return](#if-return)
- [import-shadowing](#import-shadowing) - [import-alias-naming](#import-alias-naming)
- [imports-blocklist](#imports-blocklist) - [import-shadowing](#import-shadowing)
- [increment-decrement](#increment-decrement) - [imports-blocklist](#imports-blocklist)
- [indent-error-flow](#indent-error-flow) - [increment-decrement](#increment-decrement)
- [line-length-limit](#line-length-limit) - [indent-error-flow](#indent-error-flow)
- [max-control-nesting](#max-control-nesting) - [line-length-limit](#line-length-limit)
- [max-public-structs](#max-public-structs) - [max-control-nesting](#max-control-nesting)
- [modifies-parameter](#modifies-parameter) - [max-public-structs](#max-public-structs)
- [modifies-value-receiver](#modifies-value-receiver) - [modifies-parameter](#modifies-parameter)
- [nested-structs](#nested-structs) - [modifies-value-receiver](#modifies-value-receiver)
- [optimize-operands-order](#optimize-operands-order) - [nested-structs](#nested-structs)
- [package-comments](#package-comments) - [optimize-operands-order](#optimize-operands-order)
- [package-directory-mismatch](#package-directory-mismatch) - [package-comments](#package-comments)
- [range-val-address](#range-val-address) - [package-directory-mismatch](#package-directory-mismatch)
- [range-val-in-closure](#range-val-in-closure) - [range-val-address](#range-val-address)
- [range](#range) - [range-val-in-closure](#range-val-in-closure)
- [receiver-naming](#receiver-naming) - [range](#range)
- [redefines-builtin-id](#redefines-builtin-id) - [receiver-naming](#receiver-naming)
- [redundant-build-tag](#redundant-build-tag) - [redefines-builtin-id](#redefines-builtin-id)
- [redundant-import-alias](#redundant-import-alias) - [redundant-build-tag](#redundant-build-tag)
- [redundant-test-main-exit](#redundant-test-main-exit) - [redundant-import-alias](#redundant-import-alias)
- [string-format](#string-format) - [redundant-test-main-exit](#redundant-test-main-exit)
- [string-of-int](#string-of-int) - [string-format](#string-format)
- [struct-tag](#struct-tag) - [string-of-int](#string-of-int)
- [superfluous-else](#superfluous-else) - [struct-tag](#struct-tag)
- [time-date](#time-date) - [superfluous-else](#superfluous-else)
- [time-equal](#time-equal) - [time-date](#time-date)
- [time-naming](#time-naming) - [time-equal](#time-equal)
- [unchecked-type-assertion](#unchecked-type-assertion) - [time-naming](#time-naming)
- [unconditional-recursion](#unconditional-recursion) - [unchecked-type-assertion](#unchecked-type-assertion)
- [unexported-naming](#unexported-naming) - [unconditional-recursion](#unconditional-recursion)
- [unexported-return](#unexported-return) - [unexported-naming](#unexported-naming)
- [unhandled-error](#unhandled-error) - [unexported-return](#unexported-return)
- [unnecessary-format](#unnecessary-format) - [unhandled-error](#unhandled-error)
- [unnecessary-stmt](#unnecessary-stmt) - [unnecessary-format](#unnecessary-format)
- [unreachable-code](#unreachable-code) - [unnecessary-stmt](#unnecessary-stmt)
- [unsecure-url-scheme](#unsecure-url-scheme) - [unreachable-code](#unreachable-code)
- [unused-parameter](#unused-parameter) - [unsecure-url-scheme](#unsecure-url-scheme)
- [unused-receiver](#unused-receiver) - [unused-parameter](#unused-parameter)
- [use-any](#use-any) - [unused-receiver](#unused-receiver)
- [use-errors-new](#use-errors-new) - [use-any](#use-any)
- [use-fmt-print](#use-fmt-print) - [use-errors-new](#use-errors-new)
- [use-waitgroup-go](#use-waitgroup-go) - [use-fmt-print](#use-fmt-print)
- [useless-break](#useless-break) - [use-waitgroup-go](#use-waitgroup-go)
- [useless-fallthrough](#useless-fallthrough) - [useless-break](#useless-break)
- [var-declaration](#var-declaration) - [useless-fallthrough](#useless-fallthrough)
- [var-naming](#var-naming) - [var-declaration](#var-declaration)
- [waitgroup-by-value](#waitgroup-by-value) - [var-naming](#var-naming)
- [waitgroup-by-value](#waitgroup-by-value)
<!-- tocstop -->
## add-constant ## add-constant