solid_lints icon indicating copy to clipboard operation
solid_lints copied to clipboard

New rule: consider_making_a_member_private (if its not used outside)

Open danylo-safonov-solid opened this issue 2 years ago • 2 comments

This'll help with dead_code

BAD:

class X {
  // only used internally 
  void x() {
    ...
  }
}

GOOD:

class X {
  // only used internally 
  void _x() {
    ...
  }
}

danylo-safonov-solid avatar Dec 15 '23 16:12 danylo-safonov-solid

I'm very excited for this one! I could see it being very valuable for any class members. For some reason, Dart doesn't recognize that a member is unused unless it's private. So this would be a double whammy if it enforced all members that could be public were public.

kvenn avatar Apr 30 '24 01:04 kvenn

Should this only be applied to class members? What about top-level ones and class definitions themselves? I think it would be worth having it to all definitions, because top-level functions that are only used internally also add noise to code completion. As a bonus, it could help us identify unused definitions (something that I used to do with dart code metrics).

gbassisp avatar Jun 19 '24 12:06 gbassisp