mirror of
				https://github.com/mgechev/revive.git
				synced 2025-10-30 23:37:49 +02:00 
			
		
		
		
	docs: update TOC; check for TOC consistency in GHA (#1493)
This commit is contained in:
		
							
								
								
									
										13
									
								
								.github/workflows/lint.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								.github/workflows/lint.yaml
									
									
									
									
										vendored
									
									
								
							| @@ -72,11 +72,24 @@ jobs: | ||||
|         # 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 | ||||
|  | ||||
|       - 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 | ||||
|         uses: DavidAnson/markdownlint-cli2-action@v20 | ||||
|         with: | ||||
|           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 | ||||
|         id: verify_snippets | ||||
|         run: mdsf verify --on-missing-language-definition ignore --on-missing-tool-binary fail-fast . | ||||
|   | ||||
| @@ -93,15 +93,20 @@ type Formatter interface { | ||||
|  | ||||
| ### Lint Markdown files | ||||
|  | ||||
| We use [markdownlint](https://github.com/DavidAnson/markdownlint) and [mdsf](https://github.com/hougesen/mdsf) to check Markdown files. | ||||
| `markdownlint` verifies document formatting, such as line length and empty lines, while `mdsf` is responsible for formatting code snippets. | ||||
| We use [markdownlint](https://github.com/DavidAnson/markdownlint), | ||||
| [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). | ||||
| 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` | ||||
|     - [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` | ||||
| 3. Run the following command to check formatting: | ||||
| 4. Run the following command to check formatting: | ||||
|  | ||||
| ```shellsession | ||||
| $ 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)._ | ||||
| \ | ||||
| 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 | ||||
| mdsf verify . | ||||
|   | ||||
							
								
								
									
										97
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										97
									
								
								README.md
									
									
									
									
									
								
							| @@ -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"> | ||||
| </p> | ||||
|  | ||||
| <!-- TOC --> | ||||
| <!-- toc --> | ||||
|  | ||||
| - [revive](#revive) | ||||
|   - [Installation](#installation) | ||||
|     - [Homebrew](#homebrew) | ||||
|     - [Install from Sources](#install-from-sources) | ||||
|     - [Docker](#docker) | ||||
|     - [Manual Binary Download](#manual-binary-download) | ||||
|   - [Usage](#usage) | ||||
|     - [Bazel](#bazel) | ||||
|     - [Text Editors](#text-editors) | ||||
|     - [GitHub Actions](#github-actions) | ||||
|     - [Continuous Integration](#continuous-integration) | ||||
|     - [Linter aggregators](#linter-aggregators) | ||||
|       - [golangci-lint](#golangci-lint) | ||||
|     - [Command Line Flags](#command-line-flags) | ||||
|     - [Sample Invocations](#sample-invocations) | ||||
|     - [Comment Directives](#comment-directives) | ||||
|     - [Configuration](#configuration) | ||||
|     - [Default Configuration](#default-configuration) | ||||
|     - [Custom Configuration](#custom-configuration) | ||||
|     - [Recommended Configuration](#recommended-configuration) | ||||
|     - [Rule-level file excludes](#rule-level-file-excludes) | ||||
|   - [Available Rules](#available-rules) | ||||
|   - [Configurable rules](#configurable-rules) | ||||
|     - [`var-naming`](#var-naming) | ||||
|   - [Available Formatters](#available-formatters) | ||||
|     - [Friendly](#friendly) | ||||
|     - [Stylish](#stylish) | ||||
|     - [Default](#default) | ||||
|     - [Plain](#plain) | ||||
|     - [Unix](#unix) | ||||
|     - [JSON](#json) | ||||
|     - [NDJSON](#ndjson) | ||||
|     - [Checkstyle](#checkstyle) | ||||
|     - [SARIF](#sarif) | ||||
|   - [Extensibility](#extensibility) | ||||
|     - [Writing a Custom Rule](#writing-a-custom-rule) | ||||
|       - [Using `revive` as a library](#using-revive-as-a-library) | ||||
|     - [Custom Formatter](#custom-formatter) | ||||
|   - [Speed Comparison](#speed-comparison) | ||||
|     - [golint](#golint) | ||||
|     - [revive's speed](#revives-speed) | ||||
|   - [Overriding colorization detection](#overriding-colorization-detection) | ||||
|   - [Who uses Revive](#who-uses-revive) | ||||
|   - [Contributors](#contributors) | ||||
|     - [Maintainers](#maintainers) | ||||
|     - [All](#all) | ||||
|   - [License](#license) | ||||
| - [Installation](#installation) | ||||
|   - [Homebrew](#homebrew) | ||||
|   - [Install from Sources](#install-from-sources) | ||||
|   - [Docker](#docker) | ||||
|   - [Manual Binary Download](#manual-binary-download) | ||||
| - [Usage](#usage) | ||||
|   - [Bazel](#bazel) | ||||
|   - [Text Editors](#text-editors) | ||||
|   - [GitHub Actions](#github-actions) | ||||
|   - [Continuous Integration](#continuous-integration) | ||||
|   - [Linter aggregators](#linter-aggregators) | ||||
|     - [golangci-lint](#golangci-lint) | ||||
|   - [Command Line Flags](#command-line-flags) | ||||
|   - [Sample Invocations](#sample-invocations) | ||||
|   - [Comment Directives](#comment-directives) | ||||
|   - [Configuration](#configuration) | ||||
|   - [Default Configuration](#default-configuration) | ||||
|   - [Custom Configuration](#custom-configuration) | ||||
|   - [Recommended Configuration](#recommended-configuration) | ||||
|   - [Rule-level file excludes](#rule-level-file-excludes) | ||||
| - [Available Rules](#available-rules) | ||||
| - [Configurable rules](#configurable-rules) | ||||
|   - [`var-naming`](#var-naming) | ||||
| - [Available Formatters](#available-formatters) | ||||
|   - [Friendly](#friendly) | ||||
|   - [Stylish](#stylish) | ||||
|   - [Default](#default) | ||||
|   - [Plain](#plain) | ||||
|   - [Unix](#unix) | ||||
|   - [JSON](#json) | ||||
|   - [NDJSON](#ndjson) | ||||
|   - [Checkstyle](#checkstyle) | ||||
|   - [SARIF](#sarif) | ||||
| - [Extensibility](#extensibility) | ||||
|   - [Writing a Custom Rule](#writing-a-custom-rule) | ||||
|     - [Using `revive` as a library](#using-revive-as-a-library) | ||||
|   - [Custom Formatter](#custom-formatter) | ||||
| - [Speed Comparison](#speed-comparison) | ||||
|   - [golint](#golint) | ||||
|   - [revive's speed](#revives-speed) | ||||
| - [Overriding colorization detection](#overriding-colorization-detection) | ||||
| - [Who uses Revive](#who-uses-revive) | ||||
| - [Contributors](#contributors) | ||||
|   - [Maintainers](#maintainers) | ||||
|   - [All](#all) | ||||
| - [License](#license) | ||||
|  | ||||
| <!-- /TOC --> | ||||
| <!-- tocstop --> | ||||
|  | ||||
| ## Installation | ||||
|  | ||||
|   | ||||
| @@ -2,103 +2,106 @@ | ||||
|  | ||||
| List of all available rules. | ||||
|  | ||||
| - [Description of available rules](#description-of-available-rules) | ||||
|   - [add-constant](#add-constant) | ||||
|   - [argument-limit](#argument-limit) | ||||
|   - [atomic](#atomic) | ||||
|   - [banned-characters](#banned-characters) | ||||
|   - [bare-return](#bare-return) | ||||
|   - [blank-imports](#blank-imports) | ||||
|   - [bool-literal-in-expr](#bool-literal-in-expr) | ||||
|   - [call-to-gc](#call-to-gc) | ||||
|   - [cognitive-complexity](#cognitive-complexity) | ||||
|   - [comment-spacings](#comment-spacings) | ||||
|   - [comments-density](#comments-density) | ||||
|   - [confusing-naming](#confusing-naming) | ||||
|   - [confusing-results](#confusing-results) | ||||
|   - [constant-logical-expr](#constant-logical-expr) | ||||
|   - [context-as-argument](#context-as-argument) | ||||
|   - [context-keys-type](#context-keys-type) | ||||
|   - [cyclomatic](#cyclomatic) | ||||
|   - [datarace](#datarace) | ||||
|   - [deep-exit](#deep-exit) | ||||
|   - [defer](#defer) | ||||
|   - [dot-imports](#dot-imports) | ||||
|   - [duplicated-imports](#duplicated-imports) | ||||
|   - [early-return](#early-return) | ||||
|   - [empty-block](#empty-block) | ||||
|   - [empty-lines](#empty-lines) | ||||
|   - [enforce-map-style](#enforce-map-style) | ||||
|   - [enforce-repeated-arg-type-style](#enforce-repeated-arg-type-style) | ||||
|   - [enforce-slice-style](#enforce-slice-style) | ||||
|   - [enforce-switch-style](#enforce-switch-style) | ||||
|   - [error-naming](#error-naming) | ||||
|   - [error-return](#error-return) | ||||
|   - [error-strings](#error-strings) | ||||
|   - [errorf](#errorf) | ||||
|   - [exported](#exported) | ||||
|   - [file-header](#file-header) | ||||
|   - [file-length-limit](#file-length-limit) | ||||
|   - [filename-format](#filename-format) | ||||
|   - [flag-parameter](#flag-parameter) | ||||
|   - [function-length](#function-length) | ||||
|   - [function-result-limit](#function-result-limit) | ||||
|   - [get-return](#get-return) | ||||
|   - [identical-branches](#identical-branches) | ||||
|   - [identical-ifelseif-branches](#identical-ifelseif-branches) | ||||
|   - [identical-ifelseif-conditions](#identical-ifelseif-conditions) | ||||
|   - [identical-switch-branches](#identical-switch-branches) | ||||
|   - [identical-switch-conditions](#identical-switch-conditions) | ||||
|   - [if-return](#if-return) | ||||
|   - [import-alias-naming](#import-alias-naming) | ||||
|   - [import-shadowing](#import-shadowing) | ||||
|   - [imports-blocklist](#imports-blocklist) | ||||
|   - [increment-decrement](#increment-decrement) | ||||
|   - [indent-error-flow](#indent-error-flow) | ||||
|   - [line-length-limit](#line-length-limit) | ||||
|   - [max-control-nesting](#max-control-nesting) | ||||
|   - [max-public-structs](#max-public-structs) | ||||
|   - [modifies-parameter](#modifies-parameter) | ||||
|   - [modifies-value-receiver](#modifies-value-receiver) | ||||
|   - [nested-structs](#nested-structs) | ||||
|   - [optimize-operands-order](#optimize-operands-order) | ||||
|   - [package-comments](#package-comments) | ||||
|   - [package-directory-mismatch](#package-directory-mismatch) | ||||
|   - [range-val-address](#range-val-address) | ||||
|   - [range-val-in-closure](#range-val-in-closure) | ||||
|   - [range](#range) | ||||
|   - [receiver-naming](#receiver-naming) | ||||
|   - [redefines-builtin-id](#redefines-builtin-id) | ||||
|   - [redundant-build-tag](#redundant-build-tag) | ||||
|   - [redundant-import-alias](#redundant-import-alias) | ||||
|   - [redundant-test-main-exit](#redundant-test-main-exit) | ||||
|   - [string-format](#string-format) | ||||
|   - [string-of-int](#string-of-int) | ||||
|   - [struct-tag](#struct-tag) | ||||
|   - [superfluous-else](#superfluous-else) | ||||
|   - [time-date](#time-date) | ||||
|   - [time-equal](#time-equal) | ||||
|   - [time-naming](#time-naming) | ||||
|   - [unchecked-type-assertion](#unchecked-type-assertion) | ||||
|   - [unconditional-recursion](#unconditional-recursion) | ||||
|   - [unexported-naming](#unexported-naming) | ||||
|   - [unexported-return](#unexported-return) | ||||
|   - [unhandled-error](#unhandled-error) | ||||
|   - [unnecessary-format](#unnecessary-format) | ||||
|   - [unnecessary-stmt](#unnecessary-stmt) | ||||
|   - [unreachable-code](#unreachable-code) | ||||
|   - [unsecure-url-scheme](#unsecure-url-scheme) | ||||
|   - [unused-parameter](#unused-parameter) | ||||
|   - [unused-receiver](#unused-receiver) | ||||
|   - [use-any](#use-any) | ||||
|   - [use-errors-new](#use-errors-new) | ||||
|   - [use-fmt-print](#use-fmt-print) | ||||
|   - [use-waitgroup-go](#use-waitgroup-go) | ||||
|   - [useless-break](#useless-break) | ||||
|   - [useless-fallthrough](#useless-fallthrough) | ||||
|   - [var-declaration](#var-declaration) | ||||
|   - [var-naming](#var-naming) | ||||
|   - [waitgroup-by-value](#waitgroup-by-value) | ||||
| <!-- toc --> | ||||
|  | ||||
| - [add-constant](#add-constant) | ||||
| - [argument-limit](#argument-limit) | ||||
| - [atomic](#atomic) | ||||
| - [banned-characters](#banned-characters) | ||||
| - [bare-return](#bare-return) | ||||
| - [blank-imports](#blank-imports) | ||||
| - [bool-literal-in-expr](#bool-literal-in-expr) | ||||
| - [call-to-gc](#call-to-gc) | ||||
| - [cognitive-complexity](#cognitive-complexity) | ||||
| - [comment-spacings](#comment-spacings) | ||||
| - [comments-density](#comments-density) | ||||
| - [confusing-naming](#confusing-naming) | ||||
| - [confusing-results](#confusing-results) | ||||
| - [constant-logical-expr](#constant-logical-expr) | ||||
| - [context-as-argument](#context-as-argument) | ||||
| - [context-keys-type](#context-keys-type) | ||||
| - [cyclomatic](#cyclomatic) | ||||
| - [datarace](#datarace) | ||||
| - [deep-exit](#deep-exit) | ||||
| - [defer](#defer) | ||||
| - [dot-imports](#dot-imports) | ||||
| - [duplicated-imports](#duplicated-imports) | ||||
| - [early-return](#early-return) | ||||
| - [empty-block](#empty-block) | ||||
| - [empty-lines](#empty-lines) | ||||
| - [enforce-map-style](#enforce-map-style) | ||||
| - [enforce-repeated-arg-type-style](#enforce-repeated-arg-type-style) | ||||
| - [enforce-slice-style](#enforce-slice-style) | ||||
| - [enforce-switch-style](#enforce-switch-style) | ||||
| - [error-naming](#error-naming) | ||||
| - [error-return](#error-return) | ||||
| - [error-strings](#error-strings) | ||||
| - [errorf](#errorf) | ||||
| - [exported](#exported) | ||||
| - [file-header](#file-header) | ||||
| - [file-length-limit](#file-length-limit) | ||||
| - [filename-format](#filename-format) | ||||
| - [flag-parameter](#flag-parameter) | ||||
| - [function-length](#function-length) | ||||
| - [function-result-limit](#function-result-limit) | ||||
| - [get-return](#get-return) | ||||
| - [identical-branches](#identical-branches) | ||||
| - [identical-ifelseif-branches](#identical-ifelseif-branches) | ||||
| - [identical-ifelseif-conditions](#identical-ifelseif-conditions) | ||||
| - [identical-switch-branches](#identical-switch-branches) | ||||
| - [identical-switch-conditions](#identical-switch-conditions) | ||||
| - [if-return](#if-return) | ||||
| - [import-alias-naming](#import-alias-naming) | ||||
| - [import-shadowing](#import-shadowing) | ||||
| - [imports-blocklist](#imports-blocklist) | ||||
| - [increment-decrement](#increment-decrement) | ||||
| - [indent-error-flow](#indent-error-flow) | ||||
| - [line-length-limit](#line-length-limit) | ||||
| - [max-control-nesting](#max-control-nesting) | ||||
| - [max-public-structs](#max-public-structs) | ||||
| - [modifies-parameter](#modifies-parameter) | ||||
| - [modifies-value-receiver](#modifies-value-receiver) | ||||
| - [nested-structs](#nested-structs) | ||||
| - [optimize-operands-order](#optimize-operands-order) | ||||
| - [package-comments](#package-comments) | ||||
| - [package-directory-mismatch](#package-directory-mismatch) | ||||
| - [range-val-address](#range-val-address) | ||||
| - [range-val-in-closure](#range-val-in-closure) | ||||
| - [range](#range) | ||||
| - [receiver-naming](#receiver-naming) | ||||
| - [redefines-builtin-id](#redefines-builtin-id) | ||||
| - [redundant-build-tag](#redundant-build-tag) | ||||
| - [redundant-import-alias](#redundant-import-alias) | ||||
| - [redundant-test-main-exit](#redundant-test-main-exit) | ||||
| - [string-format](#string-format) | ||||
| - [string-of-int](#string-of-int) | ||||
| - [struct-tag](#struct-tag) | ||||
| - [superfluous-else](#superfluous-else) | ||||
| - [time-date](#time-date) | ||||
| - [time-equal](#time-equal) | ||||
| - [time-naming](#time-naming) | ||||
| - [unchecked-type-assertion](#unchecked-type-assertion) | ||||
| - [unconditional-recursion](#unconditional-recursion) | ||||
| - [unexported-naming](#unexported-naming) | ||||
| - [unexported-return](#unexported-return) | ||||
| - [unhandled-error](#unhandled-error) | ||||
| - [unnecessary-format](#unnecessary-format) | ||||
| - [unnecessary-stmt](#unnecessary-stmt) | ||||
| - [unreachable-code](#unreachable-code) | ||||
| - [unsecure-url-scheme](#unsecure-url-scheme) | ||||
| - [unused-parameter](#unused-parameter) | ||||
| - [unused-receiver](#unused-receiver) | ||||
| - [use-any](#use-any) | ||||
| - [use-errors-new](#use-errors-new) | ||||
| - [use-fmt-print](#use-fmt-print) | ||||
| - [use-waitgroup-go](#use-waitgroup-go) | ||||
| - [useless-break](#useless-break) | ||||
| - [useless-fallthrough](#useless-fallthrough) | ||||
| - [var-declaration](#var-declaration) | ||||
| - [var-naming](#var-naming) | ||||
| - [waitgroup-by-value](#waitgroup-by-value) | ||||
|  | ||||
| <!-- tocstop --> | ||||
|  | ||||
| ## add-constant | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user