Skip to content
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

Disable funlen for *_test.go files #5

Closed
renkam opened this issue Jan 23, 2020 · 6 comments
Closed

Disable funlen for *_test.go files #5

renkam opened this issue Jan 23, 2020 · 6 comments

Comments

@renkam
Copy link

renkam commented Jan 23, 2020

Is there any option to disable this linter for all test files?
Often table tests have input tables very long and it is not a problem for reading test function.

@NiseVoid
Copy link
Contributor

Hello,

When we wish to disable linters in tests we add a rule to exclude-rules under issues in the .golangci.yml like this:

issues:
  exclude-rules:
    - path: _test.go
      linters:
        - funlen

Would this be an acceptable solution?

@renkam
Copy link
Author

renkam commented Jan 24, 2020

This would probably solve the case.
It would be nice to have such comment in readme.

Is there option to apply this per func name like Test*?

@NiseVoid
Copy link
Contributor

Sorry for the late reply.

I'm not completely sure if there's a pretty way to do that. All I could find is using the source regex, something like this:

issues:
  exclude-rules:
    - linters:
        - funlen
      source: "^func Test"

This would disable the rule on any line that matches the regex. This would work because the error funlen gives is on the line where the function starts, however it wouldn't work for most other linters.

@robinknaapen
Copy link
Contributor

@renkam

First if all sorry for the late reply.

Was the snippet provided by @NiseVoid sufficient?
If so would it be fine to close the issue?

@martialblog
Copy link
Contributor

Maybe there could be a small hint in the README, with reference to the golangci config

@robinknaapen
Copy link
Contributor

Fixed in #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants