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

review: fix: get correct descriptions from CtJavaDocImpl #4061

Merged
merged 2 commits into from
Aug 10, 2021

Conversation

andrewbwogi
Copy link
Contributor

closes #4059

Copy link
Collaborator

@slarse slarse left a comment

Choose a reason for hiding this comment

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

@andrewbwogi thanks for the PR, could you have a look at my comment?

Comment on lines 89 to 93
while (this.getContent().length() > indexEndSentence + 1
&& !Character.isWhitespace(this.getContent().charAt(indexEndSentence + 1))
&& indexEndSentence != -1) {
indexEndSentence = this.getContent().indexOf('.', indexEndSentence + 1);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks rather complicated to me. Could you extract searching for the end-sentence index to a separate method (something like int indexOfFirstSentenceEnd(String content))?

Also, in comparisons, I'd strongly recommend putting the "dynamic" element (the value that changes) on the left, and only that. For example:

// not ideal IMO, as the key variable of the comparison is on the right (less evident)
// and part of a subexpression (+)
this.getContent().length() > indexEndSentence + 1

// better, they key variable is now on the left (immediately catches the eye) and stands on its own
indexEndSentence < this.getContent().length() - 1

I'd argue that's the standard for out-of-bounds checks at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @slarse, a new commit coming up.

@monperrus
Copy link
Collaborator

ping @andrewbwogi to complete this one?

@slarse
Copy link
Collaborator

slarse commented Aug 10, 2021

Thanks @andrewbwogi, that's nice and easy to read!

@slarse slarse merged commit 55db471 into INRIA:master Aug 10, 2021
@monperrus monperrus mentioned this pull request Aug 19, 2021
woutersmeenk pushed a commit to woutersmeenk/spoon that referenced this pull request Aug 29, 2021
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.

bug: Spoon's "getShortDescription" and "getLongDescription" handling is too primitive
3 participants