Skip to content
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

[apex] ExcessiveClassLength multiple warning on the same class #3156

Merged
merged 2 commits into from
Mar 27, 2021

Conversation

adangel
Copy link
Member

@adangel adangel commented Mar 4, 2021

Not perfect, but better than before. The classes at least look ok, but the synthetic methods/nodes (like UserClassMethods, BridgeMethodCreator) look still weird.

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by travis)
  • Added (in-code) documentation (if needed)

@adangel adangel added this to the 6.33.0 milestone Mar 4, 2021
@pmd-test
Copy link

pmd-test commented Mar 4, 2021

1 Message
📖 No java rules are changed!

Generated by 🚫 Danger

@@ -191,8 +228,6 @@ private int visitPosition(Node node, int count) {
return result;
}

// TEST HELPER

private static void assertPosition(Node node, int beginLine, int beginColumn, int endLine, int endColumn) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just something to care about while merging into pmd 7, this method has been moved to pmd-lang-test IIRC

// this is a synthetic method, only in the AST, not in the source
// search for the last sibling with real location from the end
// and place this synthetic method after it.
for (int i = getParent().getNumChildren() - 1; i >= 0; i--) {
Copy link
Member

@oowekyala oowekyala Mar 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So synthetic methods have the coordinates of the last real method of the class. This makes sense, but this may break some assumptions we make on line/column positions. Namely that if a node is-before another in a prefix traversal of the tree, then their positions are also <=. The designer relies on this for instance.

(I think those assumptions are already broken by the apex module anyway, because the designer's node finding methods malfunction)

Maybe we should move those synthetic nodes around when we do the traversal that resolve text coordinates (though since it's already broken we could do that later).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to do that later. It would be useful to have an explicit test for the condition that the positions of a node is always <= than the position of the next node. Don't we have some test like that in pmd7?

About reordering the nodes: Not sure if we should do that. Currently I think, we use the visit order of the apex jorje parser.

So maybe we should make sure, that the condition is true no matter where the synthetic methods are. That means, we would place them just after the previous (real) sibling and before the next (real) sibling, if there is a next.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #3174

@adangel adangel merged commit bbac216 into pmd:master Mar 27, 2021
@adangel adangel deleted the issue-3142-apex-excessive-class-length branch March 27, 2021 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[apex] ExcessiveClassLength multiple warning on the same class
3 participants