ultraware / funlen

MIT License
37 stars 8 forks source link

funlen fails on variadic args #10

Closed eccles closed 2 years ago

eccles commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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.