golangci / golangci-lint

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

detects whether declarations of exported variables, constants, functions, etc. have comments. #4828

Closed cold-bin closed 1 week ago

cold-bin commented 1 week ago

Welcome

Your feature request related to a problem? Please describe

When a new person takes over a large project, it will be painful if there are no comments. This is how I feel that necessary comments need to be provided for public types, variables, functions or methods to facilitate the new person to quickly familiarize themselves with the project.

Describe the solution you'd like

use go/analyze package to recursive traversal ast comment or documention node. if empty the comment and documention node, then call reportf. the link of https://github.com/cold-bin/declaration-comment is my implement

Describe alternatives you've considered

nothing, this way can solve no comments of many complex type

Additional context

No response

Supporter

boring-cyborg[bot] commented 1 week ago

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

ldez commented 1 week ago

Hello,

this already exists inside golangci-lint: revive, stylecheck, etc.

ccoVeille commented 1 week ago

The only existing linter I know that looks like what is requested would be revive:comment-density

https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#comments-density

cold-bin commented 1 week ago

thank for your reply

ldez commented 1 week ago

The only existing linter I know that looks like what is requested would be revive:comment-density

This issue is about comments, so there several rules inside revive and stylecheck.

But remember that by default, golangci-lint skips those reports.

https://golangci-lint.run/usage/false-positives/#default-exclusions

To disable those exclusions:

issues:
  exclude-use-default: false
ccoVeille commented 1 week ago

Thanks for providing this information. I totally missed that parameter even I'm using golangci-lint for a while.

I'll have a look, thanks