blizzy78 / varnamelen

Go analyzer checking that the length of a variable's name matches its usage scope

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Linter raises issues about actual words, for i loops, and range loops for being too short for the scope of usage

viktormatrai opened this issue · comments

Hi!

I just updated a service from go 1.16 to 1.18 and unfortunately recently I have to disable this linter because it is deciding to raise issues of scope of usage, for such things as:

var ad Ad

Ad is an actual noun, which has two characters in it.

For i loop:

Raises the same issue for the "i". I think the iterator's naming is being "i" since the beginning of time, maybe it should be an exception.

Range loop:

For example if you're having a slice named Ads, for which you create a range loop the element will be ad (which is the singular version of ads).

This is working as intended. You can use the -ignoreNames and -ignoreDecls flags (or ignore-names and ignore-decls settings in golangci-lint) to ignore special cases. Alternatively, change -minNameLength/min-name-length, or use a nolint:varnamelen directive in the source line.