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

funlen fails on variadic args #10

Closed
eccles opened this issue Jan 3, 2022 · 2 comments
Closed

funlen fails on variadic args #10

eccles opened this issue Jan 3, 2022 · 2 comments

Comments

@eccles
Copy link

eccles commented Jan 3, 2022

I have a New() method which instantiates a Logger (based on the ubser zap logger.).

The following fails on funlen...

 func New(level string, opts ...interface{}) Logger {
         r := &Resource{}

         var zopts []zap.Option
         for _, iopt := range opts {
                 if opt, ok := iopt.(zap.Option); ok {
                         zopts = append(zopts, opt)
                 }
        }
       ...

which seems harsh as I have no control over the number of options in the zap logger. Also the args list to this method is simple and does not break the rule of being difficult to read.

This seems to be a bug in the funlen linter.

any thoughts?

@NiseVoid
Copy link
Contributor

NiseVoid commented Jan 3, 2022

Funlen looks at the number of lines and statements, so variadic args shouldn't be a problem. The above code does not seem to produce any errors for me, but I might be using different settings and a part of the function is missing (at least I assume that's what the ... means)

@eccles
Copy link
Author

eccles commented Jan 3, 2022

Hmm - I refactored some of the code to get rid of a=other warnings and the funlen failure went away - and now I cannot reproduce it.. Seems there must have been something else that was triggering this and I am now unable to reproduce it.

Sorry about the noise and thanx for the attention.

@eccles eccles closed this as completed Jan 3, 2022
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

2 participants