Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public final class MultiLineCommentCheck extends AbstractCheck {
* during the class under test and the field is reinitialized with a new object.
*/
@SuppressWarnings("PMD.AvoidStringBufferField")
private StringBuilder text;
private final StringBuilder text = new StringBuilder();

@Override
public boolean isCommentNodesRequired() {
Expand Down Expand Up @@ -63,7 +63,8 @@ public int[] getRequiredTokens() {
@Override
public void visitToken(final DetailAST ast) {
if (ast.getType() == TokenTypes.BLOCK_COMMENT_BEGIN) {
this.text = new StringBuilder(ast.getText());
this.text.setLength(0);
this.text.append(ast.getText());
} else if (ast.getType() == TokenTypes.COMMENT_CONTENT) {
this.text.append(ast.getText());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public final class SingleLineCommentCheck extends AbstractCheck {
* during the class under test and the field is reinitialized with a new object.
*/
@SuppressWarnings("PMD.AvoidStringBufferField")
private StringBuilder line;
private final StringBuilder line = new StringBuilder();

/**
* When inside a block comment, holds begin line number.
Expand Down Expand Up @@ -69,7 +69,8 @@ public int[] getRequiredTokens() {
@Override
public void visitToken(final DetailAST ast) {
if (ast.getType() == TokenTypes.BLOCK_COMMENT_BEGIN) {
this.line = new StringBuilder(ast.getText());
this.line.setLength(0);
this.line.append(ast.getText());
this.begin = ast.getLineNo();
} else if (ast.getType() == TokenTypes.COMMENT_CONTENT) {
this.line.append(ast.getText());
Expand Down