Skip to content

Commit 6e34f8c

Browse files
authored
chore: new workflow to add a linter (#6497)
1 parent 479e560 commit 6e34f8c

4 files changed

Lines changed: 157 additions & 7 deletions

File tree

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
title: Add XXX linter
2+
body:
3+
- type: markdown
4+
attributes:
5+
value: |
6+
Inside `golangci-lint`, we differentiate two types of analyzers:
7+
- the linters (find problems with nearly zero false positives)
8+
- the detectors (detect potential problems and thus produce a majority of false positives)
9+
10+
The detectors are not allowed because of the number of false positives.
11+
- type: input
12+
id: repo-url
13+
attributes:
14+
label: Repository URL
15+
description: Add a link to the repository of the analyzer.
16+
validations:
17+
required: true
18+
- type: checkboxes
19+
id: analyzer-requirements
20+
attributes:
21+
label: Analyzer Requirements
22+
options:
23+
- label: The analyzer must be more than one month old.
24+
required: true
25+
- label: The usage of AI must be explicitly expressed inside the readme.
26+
required: true
27+
- label: It must use [`go/analysis`](https://golangci-lint.run/docs/contributing/new-linters/).
28+
required: true
29+
- label: It must not be a duplicate or too close to an existing analyzer.
30+
required: true
31+
- label: It must have a Go version inside the `go.mod` <= 1.25.0.
32+
required: true
33+
- label: The dependencies must be minimal.
34+
required: true
35+
- label: It must be available as a plugin.
36+
required: true
37+
- type: dropdown
38+
id: analyzer-goal
39+
attributes:
40+
label: Analyzer Goal
41+
description: What is the goal of the analyzer?
42+
options:
43+
- No goal
44+
- Finds bugs
45+
- Style
46+
- Other
47+
validations:
48+
required: true
49+
- type: textarea
50+
id: analyzer-description
51+
attributes:
52+
label: Analyzer Description
53+
description: A short description, no more than one or two lines.
54+
placeholder: Add the description here.
55+
validations:
56+
required: true
57+
- type: checkboxes
58+
id: license
59+
attributes:
60+
label: Analyzer License
61+
options:
62+
- label: AGPL is not allowed.
63+
required: true
64+
- label: The file must start with `LICENSE` (capitalized).
65+
required: true
66+
- label: 'The file must contain the required information by the license, e.g.: author, year, etc.'
67+
required: true
68+
- type: checkboxes
69+
id: analyzer-info
70+
attributes:
71+
label: Analyzer Details
72+
options:
73+
- label: It must have tests.
74+
required: true
75+
- label: It must not contain `init()`.
76+
required: true
77+
- label: It must not contain `panic()`.
78+
required: true
79+
- label: It must not contain `log.Fatal()`.
80+
required: true
81+
- label: It must not contain `os.Exit()`.
82+
required: true
83+
- label: It must not modify the AST.
84+
required: true
85+
- label: The configuration must not rely on external files.
86+
required: true
87+
- type: checkboxes
88+
id: repo-info
89+
attributes:
90+
label: Repository Details
91+
options:
92+
- label: 'It must have a [semver](https://semver.org/) tag, e.g.: `v1.0.0`, `v0.1.0` (`0.0.x` are not valid).'
93+
required: true
94+
- label: A tag must never be deleted or recreated.
95+
required: false
96+
- label: It must have a readme.
97+
required: true
98+
- label: The repository must have a CI.
99+
required: true
100+
- label: The CI must run on PR.
101+
required: true
102+
- label: The CI must run on the default branch.
103+
required: true
104+
- type: checkboxes
105+
id: repo-recommendations
106+
attributes:
107+
label: Repository Recommendations
108+
options:
109+
- label: It should have linting.
110+
required: false
111+
- label: It should have a `.gitignore` (IDE files, binaries, OS files, etc. should not be committed).
112+
required: false
113+
- label: Use `main` as the default branch name.
114+
required: false
115+
- type: checkboxes
116+
id: pr
117+
attributes:
118+
label: Pull Request
119+
description: You should not open a PR to add the analyzer before a maintainer approves your suggestion.
120+
options:
121+
- label: Yes, I will wait for the approval of a maintainer before creating a PR.
122+
required: true
123+
124+
- type: markdown
125+
attributes:
126+
value: |
127+
**This checklist does not imply that we will accept the linter.**

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<!--
22
3-
WARNING:
3+
WARNING: If you don't follow the rules, the pull request will be closed.
4+
5+
-->
6+
7+
<!--
8+
Please keep the description brief.
9+
-->
10+
11+
<!--
412
513
We use Dependabot to update dependencies (linters included).
614
The updates happen at least automatically once a week (Sunday 11am UTC).
@@ -14,7 +22,14 @@ you are the original author of the linter, AND there are important changes requi
1422

1523
<!--
1624
17-
WARNING:
25+
If you want to add a new linter, you MUST open a discussion in the category "New Linter Proposals" and
26+
wait for a maintainer to approve it BEFORE opening a pull request.
27+
28+
If you don't follow the previous rule, the pull request will be closed.
29+
30+
-->
31+
32+
<!--
1833
1934
Pull requests from a fork inside a GitHub organization are not allowed.
2035
Only pull requests from personal forks are allowed.

docs/content/docs/contributing/new-linters.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ After that:
2626
list of all supported linters in [`pkg/lint/lintersdb/builder_linter.go`](https://github.com/golangci/golangci-lint/blob/HEAD/pkg/lint/lintersdb/builder_linter.go)
2727
to the method `LinterBuilder.Build`.
2828
- Add `WithSince("next_version")`, where `next_version` must be replaced by the next minor version. (ex: v1.2.0 if the current version is v1.1.0)
29-
4. Find out what options do you need to configure for the linter.
30-
For example, `nakedret` has only 1 option: [`max-func-lines`](https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.reference.yml).
29+
4. Find out what options you need to configure for the linter.
30+
For example, `nakedret` has only one option: [`max-func-lines`](https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.reference.yml).
3131
Choose default values to not be annoying for users of golangci-lint. Add configuration options to:
3232
- [.golangci.next.reference.yml](https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.next.reference.yml): the example of a configuration file.
3333
You can also add them to [.golangci.yml](https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.yml)
34-
if you think that this project needs not default values.
34+
if you think that this project needs no default values.
3535
- [config struct](https://github.com/golangci/golangci-lint/blob/HEAD/pkg/config/config.go):
3636
don't forget about `mapstructure` tags for proper configuration files parsing.
3737
5. Take a look at the example of [pull requests with new linter support](https://github.com/golangci/golangci-lint/pulls?q=is%3Apr+is%3Amerged+label%3A%22linter%3A+new%22).
@@ -45,7 +45,7 @@ After that:
4545
Some people and organizations may choose to have custom-made linters run as a part of `golangci-lint`.
4646
Typically, these linters can't be open-sourced or too specific.
4747
48-
Such linters can be added through 2 plugin systems:
48+
Such linters can be added through two plugin systems:
4949
5050
{{< cards cols=2 >}}
5151
{{< card link="/docs/plugins/module-plugins" title="Module Plugin System" icon="puzzle" tag="Recommended" >}}

docs/content/docs/contributing/workflow.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ aliases:
55
- /contributing/workflow/
66
---
77

8-
By participating in this project, you agree to abide our [code of conduct](https://github.com/golangci/golangci-lint?tab=coc-ov-file).
8+
By participating in this project, you agree to abide by our [code of conduct](https://github.com/golangci/golangci-lint?tab=coc-ov-file).
99

1010
## Set up your machine
1111

@@ -39,8 +39,16 @@ Which runs all the linters and tests.
3939

4040
Add your new or updated parameters to [.golangci.next.reference.yml](https://github.com/golangci/golangci-lint/blob/HEAD/.golangci.next.reference.yml) so they will be shown in the docs
4141

42+
## Create a discussion
43+
44+
You must create a discussion **before** opening a pull request.
45+
46+
There is a dedicated category for new linters: [New Linter Proposals](https://github.com/golangci/golangci-lint/discussions/categories/new-linter-proposals).
47+
4248
## Submit a pull request
4349

50+
Once the maintainers have approved your linter proposal in the discussion.
51+
4452
Push your branch to your golangci-lint fork and open a pull request against the
4553
`main` branch.
4654

0 commit comments

Comments
 (0)