golangci / golangci-lint

Fast linters runner for Go
https://golangci-lint.run
GNU General Public License v3.0
15.77k stars 1.39k forks source link

Add docenv linter #5143

Closed g4s8 closed 1 week ago

g4s8 commented 1 week ago

Add new docenv linter to validate that struct fields with env tags are documented: https://github.com/g4s8/envdoc/blob/master/docenv/README.md

Linter source code: https://github.com/g4s8/envdoc/tree/master/linter

boring-cyborg[bot] commented 1 week ago

Hey, thank you for opening your first Pull Request !

CLAassistant commented 1 week ago

CLA assistant check
All committers have signed the CLA.

ldez commented 1 week ago

In order for a pull request adding a linter to be reviewed, the linter and the PR must follow some requirements.

Pull Request Description

Linter

The Linter Tests Inside Golangci-lint

.golangci.next.reference.yml

Others Requirements

Recommendations


The golangci-lint team will edit this comment to check the boxes before and during the review.

The code review will start after the completion of those checkboxes (except for the specific items that the team will help to verify).

The reviews should be addressed as commits (no squash).

If the author of the PR is a member of the golangci-lint team, he should not edit this message.

This checklist does not imply that we will accept the linter.

ldez commented 1 week ago

Hello,

The checklist is not completed but I already have some problems with this linter:

Everything feels extremely niche and related to the promotion of your tool: envdoc to generate the comments on env struct tag.

I will sleep on that but, for now, I think this linter will not be accepted.

g4s8 commented 1 week ago

Hello @ldez, I see your point. The goal of both tools envdoc and the linter is to solve the problem of undocumented env vars, because I've seen this problem many times in my experience. The linter does no directly promote original tool, rather both tools "promotes" writing documentation for env vars. I will understand if you decide that this linter is niche and close PR. If not, please let me know what should be fixed.

alexandear commented 1 week ago

@g4s8 maybe it's better to create a doctag linter that will warn about any undocumented tags? This linter will be in a separate repository and not inside envdoc.

g4s8 commented 1 week ago

@alexandear thanks, sounds like a good idea

ldez commented 1 week ago

Sorry, but a linter about "undocumented" tags will have the same problem: why fields with struct tags should be more documented than other fields? This will lead to a large amount of false positives.

Based on my previous comment, for now, I closed this PR.

I recommend modifying your linter to be usable as a plugin: https://golangci-lint.run/contributing/new-linters/#how-to-add-a-private-linter-to-golangci-lint