File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
qulice-checkstyle/src/main/java/com/qulice/checkstyle Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public final class MultiLineCommentCheck extends AbstractCheck {
3434 * during the class under test and the field is reinitialized with a new object.
3535 */
3636 @ SuppressWarnings ("PMD.AvoidStringBufferField" )
37- private StringBuilder text ;
37+ private final StringBuilder text = new StringBuilder () ;
3838
3939 @ Override
4040 public boolean isCommentNodesRequired () {
@@ -63,7 +63,8 @@ public int[] getRequiredTokens() {
6363 @ Override
6464 public void visitToken (final DetailAST ast ) {
6565 if (ast .getType () == TokenTypes .BLOCK_COMMENT_BEGIN ) {
66- this .text = new StringBuilder (ast .getText ());
66+ this .text .setLength (0 );
67+ this .text .append (ast .getText ());
6768 } else if (ast .getType () == TokenTypes .COMMENT_CONTENT ) {
6869 this .text .append (ast .getText ());
6970 } else {
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public final class SingleLineCommentCheck extends AbstractCheck {
3535 * during the class under test and the field is reinitialized with a new object.
3636 */
3737 @ SuppressWarnings ("PMD.AvoidStringBufferField" )
38- private StringBuilder line ;
38+ private final StringBuilder line = new StringBuilder () ;
3939
4040 /**
4141 * When inside a block comment, holds begin line number.
@@ -69,7 +69,8 @@ public int[] getRequiredTokens() {
6969 @ Override
7070 public void visitToken (final DetailAST ast ) {
7171 if (ast .getType () == TokenTypes .BLOCK_COMMENT_BEGIN ) {
72- this .line = new StringBuilder (ast .getText ());
72+ this .line .setLength (0 );
73+ this .line .append (ast .getText ());
7374 this .begin = ast .getLineNo ();
7475 } else if (ast .getType () == TokenTypes .COMMENT_CONTENT ) {
7576 this .line .append (ast .getText ());
You can’t perform that action at this time.
0 commit comments