elvis_core icon indicating copy to clipboard operation
elvis_core copied to clipboard

max_function_length counts multiple function clauses as a single function

Open kivra-pauoli opened this issue 1 year ago • 5 comments

Bug Description

Note: might not be a bug.

max_function_length complains if a function definition spans over a given number of lines (by default: 30)...

... but it's also taking into account the multiple function clauses. So 15 clauses with 1 line each, in the body, would count for 30 lines. Is this expected?

To Reproduce

16 function clauses with 2 line (definition) each, 1 line for head, 1 line for body.

Expected Behavior

? no warning, maybe?

rebar3 Logs

Not applicable.

Additional Context

Not relevant.

kivra-pauoli avatar Feb 16 '24 11:02 kivra-pauoli

Yeah, this rule was always a bit… blunt. If we're going to adjust it, then it will need a rename as max_function_clause_length, I guess.

elbrujohalcon avatar Feb 16 '24 12:02 elbrujohalcon

Or similar, yes. For the time being I'm Ok with just adding an exception in my rules, ofc. This was mostly just me wondering if we got (from the parsing) the size of each clause or not...

kivra-pauoli avatar Feb 16 '24 12:02 kivra-pauoli

I'm interested in working on this one.

Maybe the best is to rename the existing function to max_function_clause_length as @elbrujohalcon suggested and make another one with the name max_function_length.

Do you agree?

bormilan avatar Sep 22 '24 14:09 bormilan

Yeah, go for it!!

elbrujohalcon avatar Sep 22 '24 14:09 elbrujohalcon

Since this is a breaking change (not sure how you're gonna deal with that) you should remember to update the MIGRATION guide.

paulo-ferraz-oliveira avatar Sep 23 '24 19:09 paulo-ferraz-oliveira