-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore legitimately out-of-order visibility sections in VisibilitySectionOrder #44
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was some offline design review on this one that basically boiled down to:
- the "single type section or const section" heuristic is fine, but could have a lot of false negatives
- a more appropriate solution (with its own set of false negatives) would be to exclude any visibility section that we can verify contains a declaration with a usage further down in the type declaration
d4d03bb
to
048caef
Compare
Reimplemented with new design considerations. |
delphi-checks/src/main/java/au/com/integradev/delphi/checks/VisibilitySectionOrderCheck.java
Outdated
Show resolved
Hide resolved
delphi-checks/src/main/java/au/com/integradev/delphi/checks/VisibilitySectionOrderCheck.java
Show resolved
Hide resolved
.../src/main/resources/org/sonar/l10n/delphi/rules/community-delphi/VisibilitySectionOrder.html
Show resolved
Hide resolved
048caef
to
243a1ea
Compare
Reimplemented: As the check loops over the sequential visibility sections, it maintains a stack of previous sections. When the current section has a lower visibility than the section before it, the stack is popped until the top element is not excluded. If the stack is now empty, does not raise an issue. If the current section has a lower visibility than the new "previous section", raises an issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
The VisibilitySectionOrder check currently requires that visibility sections be exactly in ascending order of visibility. There are times in which this is impractical, particularly when public types or constants are then used in later declarations:
This PR excludes visibility sections with only a single
type
orconst
from being checked by the ordering rule.