Skip to content

Commit 1da8d2b

Browse files
committed
Issue checkstyle#13809: kill mutation for AuditEventDefaultFormatter
1 parent a7fa83a commit 1da8d2b

File tree

2 files changed

+1
-45
lines changed

2 files changed

+1
-45
lines changed

config/pitest-suppressions/pitest-common-suppressions.xml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<suppressedMutations>
3-
<mutation unstable="false">
4-
<sourceFile>AuditEventDefaultFormatter.java</sourceFile>
5-
<mutatedClass>com.puppycrawl.tools.checkstyle.AuditEventDefaultFormatter</mutatedClass>
6-
<mutatedMethod>format</mutatedMethod>
7-
<mutator>org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator</mutator>
8-
<description>removed call to com/puppycrawl/tools/checkstyle/AuditEventDefaultFormatter::calculateBufferLength</description>
9-
<lineContent>final int bufLen = calculateBufferLength(event, severityLevelName.length());</lineContent>
10-
</mutation>
11-
12-
<mutation unstable="false">
13-
<sourceFile>AuditEventDefaultFormatter.java</sourceFile>
14-
<mutatedClass>com.puppycrawl.tools.checkstyle.AuditEventDefaultFormatter</mutatedClass>
15-
<mutatedMethod>format</mutatedMethod>
16-
<mutator>org.pitest.mutationtest.engine.gregor.mutators.NonVoidMethodCallMutator</mutator>
17-
<description>removed call to java/lang/String::length</description>
18-
<lineContent>final int bufLen = calculateBufferLength(event, severityLevelName.length());</lineContent>
19-
</mutation>
20-
21-
<mutation unstable="false">
22-
<sourceFile>AuditEventDefaultFormatter.java</sourceFile>
23-
<mutatedClass>com.puppycrawl.tools.checkstyle.AuditEventDefaultFormatter</mutatedClass>
24-
<mutatedMethod>format</mutatedMethod>
25-
<mutator>org.pitest.mutationtest.engine.gregor.mutators.experimental.ArgumentPropagationMutator</mutator>
26-
<description>replaced call to com/puppycrawl/tools/checkstyle/AuditEventDefaultFormatter::calculateBufferLength with argument</description>
27-
<lineContent>final int bufLen = calculateBufferLength(event, severityLevelName.length());</lineContent>
28-
</mutation>
29-
303
<mutation unstable="false">
314
<sourceFile>Checker.java</sourceFile>
325
<mutatedClass>com.puppycrawl.tools.checkstyle.Checker</mutatedClass>

src/main/java/com/puppycrawl/tools/checkstyle/AuditEventDefaultFormatter.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ public String format(AuditEvent event) {
5555
severityLevelName = severityLevel.getName().toUpperCase(Locale.US);
5656
}
5757

58-
// Avoid StringBuffer.expandCapacity
59-
final int bufLen = calculateBufferLength(event, severityLevelName.length());
60-
final StringBuilder sb = new StringBuilder(bufLen);
58+
final StringBuilder sb = new StringBuilder();
6159

6260
sb.append('[').append(severityLevelName).append("] ")
6361
.append(fileName).append(':').append(event.getLine());
@@ -77,21 +75,6 @@ public String format(AuditEvent event) {
7775
return sb.toString();
7876
}
7977

80-
/**
81-
* Returns the length of the buffer for StringBuilder.
82-
* bufferLength = fileNameLength + messageLength + lengthOfAllSeparators +
83-
* + severityNameLength + checkNameLength.
84-
*
85-
* @param event audit event.
86-
* @param severityLevelNameLength length of severity level name.
87-
* @return the length of the buffer for StringBuilder.
88-
*/
89-
private static int calculateBufferLength(AuditEvent event, int severityLevelNameLength) {
90-
return LENGTH_OF_ALL_SEPARATORS + event.getFileName().length()
91-
+ event.getMessage().length() + severityLevelNameLength
92-
+ getCheckShortName(event).length();
93-
}
94-
9578
/**
9679
* Returns check name without 'Check' suffix.
9780
*

0 commit comments

Comments
 (0)