SONARJAVA-5719 S1176 Should have a separate message for undocumented type parameters.#5575
Open
NoemieBenard wants to merge 3 commits intomasterfrom
Open
SONARJAVA-5719 S1176 Should have a separate message for undocumented type parameters.#5575NoemieBenard wants to merge 3 commits intomasterfrom
NoemieBenard wants to merge 3 commits intomasterfrom
Conversation
Contributor
Contributor
SummaryThis PR improves the error messages in S1176 (undocumented API) to distinguish between type parameters and regular method parameters. What changed:
Additional refactoring:
This makes error messages clearer and more accurate about what needs to be documented. What reviewers should knowStart here:
What to verify:
|
| if (!undocumentedParameters.isEmpty()) { | ||
| context.reportIssue(this, reportTree, "Document the parameter(s): " + undocumentedParameters.stream().collect(Collectors.joining(", "))); | ||
| String label = getParamLabel(tree); | ||
| context.reportIssue(this, reportTree, "Document the " + label + undocumentedParameters.stream().collect(Collectors.joining(", "))); |
Contributor
There was a problem hiding this comment.
We can try to improve existing code: String.join(", ", undocumentedParameters) should do the same as the long expression with a stream.
| * This is a Javadoc comment | ||
| */ | ||
| public class MyClass<T> implements Runnable { // Noncompliant {{Document the parameter(s): <T>}} | ||
| public class MyClass<T> implements Runnable { // Noncompliant {{Document the type parameter(s): <T>}} |
Contributor
There was a problem hiding this comment.
How about something like this?
/**
* Description.
*/
public record MyRecord<U>(U a, int b) {
}
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Add separate message for type parameters in rule S1176.