Closed ldez closed 3 years ago
The linecount including newlines is intended. Since in many cases people wouldn't try to workaround by removing newlines, and newlines are usually there because there's a lot of different things happening and still make you scroll trough the function a lot.
If you don't want funlen to consider whitespace it would probably be best to disable the check on lines and instead use only the check on statements, which looks at the number of statements in a function rather than how many lines those statements take up.
An example, this is 2 statements but 5 lines.
func main() {
a := 1
fmt.Println(
`a:`, a,
)
}
I'm talking about an empty line, not a new line :wink:
func main() {
fmt.Println("foo")
fmt.Println("bar")
}
func main() {
fmt.Println("foo")
fmt.Println("bar")
}
:thinking: maybe I did a wrong analysis, I try to reproduce a real case.
main.go:5: Function 'main' is too long (80 > 60) (funlen)
func main() {
So it's related to lines
count not statements
count.
So now I understand your explanation, thank you :+1:
Note for other users: to disable lines
the value must a negative number.
funlen
counts lines, but if you 2 functions with the same effective lines of code, one can produce a report and the other not, only because there are empty lines.By following this rule, you promote the fact to remove the empty lines, I'm not sure this is expected.
I will great if you can, at least, add an option to ignore empty line from the count or just don't add the empty lines to the counters.