Commit e1394a6
abacus_fixer
fix(code_quality): do not deduct for public members in struct bodies
The public_member_variable rule previously applied uniformly to both
class and struct bodies, treating any public data member as a
code-quality finding regardless of the enclosing type. In C++ a struct
has public access by default and public data members are the idiomatic
shape for POD aggregates, value types, configuration data, and mixin
tags; penalising them charges the author for writing legitimate,
intended C++.
Gate the finding in analyze_class_blocks on kind == 'class'. struct
bodies — including struct members that appear inside an explicit
'public:' access block — no longer produce public_member_variable
findings. class bodies keep the existing behaviour: public data members
in a class continue to be deducted because the author of a class is
expected to encapsulate state.
Update the inline comment to explain the rationale so future readers
understand why struct and class are treated differently.
Reproducer:
struct A { int counter; double value; };
used to report 2 findings (counter, value); now 0.
class B { public: int counter; double value; };
still reports 2 findings.1 parent 7f237b2 commit e1394a6
1 file changed
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1390 | 1390 | | |
1391 | 1391 | | |
1392 | 1392 | | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
1393 | 1398 | | |
| 1399 | + | |
1394 | 1400 | | |
1395 | 1401 | | |
1396 | 1402 | | |
| |||
0 commit comments