erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.61k stars 53 forks source link

Linter: add "too many instance attributes" warning #500

Closed mtshiba closed 1 month ago

mtshiba commented 3 months ago

Tracking issue: #501

We would like to warn code like:

C = Class {
    .foo1 = Int;
    .foo2 = Int;
    .foo3 = Int;
    ...
    .foo36 = Int;
}

The "too many parameters" warning is already implemented. I think it is easy to implement this using that as a reference.

For now, I would like to set the threshold to 36 or higher.

Also, it would be nice to be able to warn about sequentially numbered instance attributes (foo1, foo2, ...), but this will be assigned in the next issue.