-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
please reconsider ignoring missing doc comments #456
Comments
+1 |
This comment was marked as off-topic.
This comment was marked as off-topic.
I managed to enable it using these parameters: |
that turns back on more than just the doc comment requirements. It would be nice if this particular one was more configurable. |
Hi! So, let's talk about numbers. If you are really interested in changing the default behavior please help with calculating the following metrics:
|
Even if we ever consider doing this, IMHO this is a "breaking" change, so I would delay it to 2.0. |
Or maybe we could postpone this issue until we have (if we have...) warning level severity and report these errors as warnings. |
Where'd 80% of users come from? Given
By that rationale one could never introduce a new linter to golangci-lint that identifies common problems, nor could any additional checks introduced by updating an existing linter be enabled by default. |
I think that we can make it opt-in, no breaking changes are needed. Disabling all defaults is pretty annoying, seems like we can be more granular in such things, like govet analyzers settings or exclude-rules :) I want that feature too and will take a look what we can do (of course without breaking changes and enabling it by default until v2). |
I'd like to ++ being able to opt in to godoc enforcement without also re-enabling other pragmatic exclusion rules. Even though we may be in the long tail of projects that will hold themselves to writing docstrings for everything, it's still something we'd like to do. |
This comment was marked as off-topic.
This comment was marked as off-topic.
As per great comment, you can enable it back via issues:
exclude-use-default: false
exclude:
# errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
# golint: False positive when tests are defined in package 'test'
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
# govet: Common false positives
- (possible misuse of unsafe.Pointer|should have signature)
# staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
- ineffective break statement. Did you mean to break out of the outer loop
# gosec: Too many false-positives on 'unsafe' usage
- Use of unsafe calls should be audited
# gosec: Too many false-positives for parametrized shell calls
- Subprocess launch(ed with variable|ing should be audited)
# gosec: Duplicated errcheck checks
- G104
# gosec: Too many issues in popular repos
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
# gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
- Potential file inclusion via variable It is too late to change defaults, but PR that will allow granularity for |
@ernado Is it too late for v2 to change the default? My issue with the above solution is it's cumbersome to disable all default exclusions and re-enable all but one in all (30+) of my projects. Though it's easy to copy-paste everywhere, I think re-enabling a single default exclusion may be more effective. |
Perhaps a new field can be added to v1 to re-enable default excludes? issues:
include:
- (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
- EXC0001 # exclusion ID perhaps? |
You are right, but we can't enable this now because this will lead to new unexpected linting issues on minor version update, which is kinda breaking and annoying.
What do you think about something like that? linters-settings:
golint:
report-comments: true But I like your idea about more generic way of enabling back such things: issues:
include: [EXC01, EXC02] But it looks like implementation will be more complicated. |
Totally understand, I was suggesting the default could maybe change in v2 as a major version update. I do like the individual config option for I think the general approach may be more useful for other rules folks want to include. For the generic approach, could we add IDs for each default exclude pattern? golangci-lint/pkg/config/config.go Lines 38 to 44 in 898bbb1
Perhaps a new field, like so? var DefaultExcludePatterns = []ExcludePattern{
{
id: "EXC0001",
Pattern: "Error return value of .((os\\.)?std(out|err)\\..*|.*Close" +
"|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked",
Linter: "errcheck",
Why: "Almost all programs ignore errors on these functions and in most cases it's ok",
}, Then the |
I'd be happy to work up a PR once we settle on a design |
Looks good to me. |
.golangci-lint excludes linter errors around doc comments. Re-enable them relates to golangci/golangci-lint#456
.golangci-lint excludes linter errors around doc comments. Re-enable them relates to golangci/golangci-lint#456
.golangci-lint excludes linter errors around doc comments. Re-enable them relates to golangci/golangci-lint#456
Checks for missing Go documentation used to be covered by the now defunct project `golint`. Revive is a replacement for golint that is used by `golangci-lint`. However, `golangci-lint` disables checks for missing Go documentation by default[0]. The only way to re-enable them is apparently to suppress golangci-lint's default rules, which is what this commit does. Rules that triggered false-positive on this codebase have been manually added. The list of default exclude rules can be found by running `golangci-lint run --help`. [0]: golangci/golangci-lint#456 Signed-off-by: Robin Hahling <[email protected]>
Checks for missing Go documentation used to be covered by the now defunct project `golint`. Revive is a replacement for golint that is used by `golangci-lint`. However, `golangci-lint` disables checks for missing Go documentation by default[0]. The only way to re-enable them is apparently to suppress golangci-lint's default rules, which is what this commit does. Rules that triggered false-positive on this codebase have been manually added. The list of default exclude rules can be found by running `golangci-lint run --help`. [0]: golangci/golangci-lint#456 Signed-off-by: Robin Hahling <[email protected]>
Checks for missing Go documentation used to be covered by the now defunct project `golint`. Revive is a replacement for golint that is used by `golangci-lint`. However, `golangci-lint` disables checks for missing Go documentation by default[0]. The only way to re-enable them is apparently to suppress golangci-lint's default rules, which is what this commit does. Rules that triggered false-positive on this codebase have been manually added. The list of default exclude rules can be found by running `golangci-lint run --help`. [0]: golangci/golangci-lint#456 Signed-off-by: Robin Hahling <[email protected]>
This is bad for the go community and goes against the recommendations of Effective Go. You can default this to false, and all people will have to do is set it to true in CI if they don't care about it. That's minor. Or you can mark it as deprecated and print a warning for one release cycle, and then default it to false. |
Strongly agree with @natefinch here. Making this rule ignored by default doesn't serve well the Go community. It took me almost an hour to understand why the revive linter was working fine separately but not from within the golangci-lint until I learned about the default exclude concept. It's too hard to enable this rule back. Considering that no default linter enabled by golang-ci has this rule, maybe it's not worth having it ignored this hard. People that enable revive will probably want to lint this rule, or could opt-out if they want to. From my experience writing Go for almost 8 years, I've seen how this rule used to be universally applied by people and complains about the annoyances were mostly from newcomers. But then after golint was archived, I started to see more and more how people started ignoring this Effective Go recommendation. And I strongly believe that it didn't help raising the quality of the Go code out there. I was still obeying the rule personally, but enforcing it inside a team was always a struggle. I believe golangci-lint shouldn't hard-exclude those issues by default. |
As it has already been said, we cannot change that in the v1 because it's breaking, we will change that in the v2 of golangci-lint. To disable all the exclusions: issues:
exclude-use-default: false |
We are in the process of adding support to vim-go for
golangci-lint
and plan to very soon make it the default to replacegometaliner
when running vim-go's:GoMetaLinter
.Please reconsider excluding missing doc comments from golint by default. The README.md justifies the decision with
But that rationale is false and goes against Go recommended best practices. Even if the rationale were true, appealing to such a common situation alone is insufficient to justify perpetuating bad practices.
Effective Go specifically states
And the only reason we have such great tools as godoc.org is because so many packages implement that guideline.
The text was updated successfully, but these errors were encountered: