blizzy78 / varnamelen

Go analyzer checking that the length of a variable's name matches its usage scope
MIT License
20 stars 2 forks source link

Support ignoring const declarations #4

Closed Seirdy closed 2 years ago

Seirdy commented 2 years ago

Constants such as physical values or well-known parameters of mathematical functions may have short names; however, the ignore-decls configs don't allow specifying allowed const declarations.

A code excerpt from one of my projects:

const (
    // C is the speed of light in a vacuum, m/s.
    C = 299792458
    // G is the gravitation constant, m^3/kg/s^2.
    G = 6.67408e-11
    // ...
)

As long as varnamelen checks constants, it should be possible to ignore them just like variables.

blizzy78 commented 2 years ago

The -ignoreDecls flag will now allow constant declarations in the form of const <name>.