Skip to content

Commit 84dba51

Browse files
committed
fix technical debt
1 parent 9b7c2c2 commit 84dba51

File tree

59 files changed

+217
-225
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+217
-225
lines changed

cxx-checks/src/main/java/org/sonar/cxx/checks/metrics/CxxCyclomaticComplexityCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void visitFile(@Nullable AstNode astNode) {
6767
}
6868

6969
@Override
70-
public void leaveFile(AstNode astNode) {
70+
public void leaveFile(@Nullable AstNode astNode) {
7171
if (!getScopeType().isPresent()) {
7272
analyzeScopeComplexity();
7373
}

cxx-checks/src/main/java/org/sonar/cxx/checks/metrics/TooManyLinesOfCodeInFileCheck.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import com.sonar.cxx.sslr.api.AstNode;
2323
import com.sonar.cxx.sslr.api.Grammar;
24+
import javax.annotation.Nullable;
2425
import org.sonar.check.Priority;
2526
import org.sonar.check.Rule;
2627
import org.sonar.check.RuleProperty;
@@ -54,7 +55,7 @@ public void setMax(int max) {
5455
}
5556

5657
@Override
57-
public void leaveFile(AstNode astNode) {
58+
public void leaveFile(@Nullable AstNode astNode) {
5859
var linesOfCode = ChecksHelper.getRecursiveMeasureInt(getContext().peekSourceCode(), CxxMetric.LINES_OF_CODE);
5960
if (linesOfCode > max) {
6061
getContext().createFileViolation(this,

cxx-checks/src/main/java/org/sonar/cxx/checks/regex/FileRegularExpressionCheck.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.sonar.cxx.sslr.api.AstNode;
2323
import com.sonar.cxx.sslr.api.Grammar;
2424
import java.util.regex.Pattern;
25+
import javax.annotation.Nullable;
2526
import org.sonar.api.utils.PathUtils;
2627
import org.sonar.api.utils.WildcardPattern;
2728
import org.sonar.check.Priority;
@@ -106,7 +107,7 @@ public void init() {
106107
}
107108

108109
@Override
109-
public void visitFile(AstNode fileNode) {
110+
public void visitFile(@Nullable AstNode fileNode) {
110111
if (!compare(invertFilePattern, matchFile())) {
111112
return;
112113
}

cxx-checks/src/main/java/org/sonar/cxx/checks/regex/LineRegularExpressionCheck.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.sonar.cxx.sslr.api.AstNode;
2323
import com.sonar.cxx.sslr.api.Grammar;
2424
import java.util.regex.Pattern;
25+
import javax.annotation.Nullable;
2526
import org.sonar.api.utils.PathUtils;
2627
import org.sonar.api.utils.WildcardPattern;
2728
import org.sonar.check.Priority;
@@ -106,7 +107,7 @@ public void init() {
106107
}
107108

108109
@Override
109-
public void visitFile(AstNode fileNode) {
110+
public void visitFile(@Nullable AstNode fileNode) {
110111
if (compare(invertFilePattern, matchFile())) {
111112
var nr = 0;
112113
for (var line : getContext().getInputFileLines()) {

cxx-checks/src/main/java/org/sonar/cxx/checks/xpath/XPathCheck.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import com.sonar.cxx.sslr.api.AstNode;
2323
import com.sonar.cxx.sslr.api.Grammar;
24+
import javax.annotation.Nullable;
2425
import org.sonar.api.utils.PathUtils;
2526
import org.sonar.api.utils.WildcardPattern;
2627
import org.sonar.check.Priority;
@@ -83,7 +84,7 @@ public String getMessage() {
8384
}
8485

8586
@Override
86-
public void visitFile(AstNode fileNode) {
87+
public void visitFile(@Nullable AstNode fileNode) {
8788
if (!matchFilePattern.isEmpty()) {
8889
var pattern = WildcardPattern.create(matchFilePattern);
8990
String path = PathUtils.sanitize(getContext().getFile().getPath());

cxx-checks/src/test/java/org/sonar/cxx/checks/metrics/ClassComplexityCheckTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ void test() throws IOException {
4444
Set<CxxReportIssue> issues = MultiLocatitionSquidCheck.getMultiLocationCheckMessages(file);
4545
assertThat(issues).isNotNull();
4646
var softly = new SoftAssertions();
47-
softly.assertThat(issues).hasSize(3);
48-
softly.assertThat(issues).allSatisfy(issue -> assertThat(issue.getRuleId()).isEqualTo("ClassComplexity"));
47+
softly.assertThat(issues)
48+
.hasSize(3)
49+
.allSatisfy(issue -> assertThat(issue.getRuleId()).isEqualTo("ClassComplexity"));
4950

5051
CxxReportIssue issue0 = issues.stream().filter(issue -> issue.getLocations().get(0).getLine().equals("9"))
5152
.findFirst().orElseThrow(() -> new AssertionError("No issue at line 9"));

cxx-checks/src/test/java/org/sonar/cxx/checks/metrics/FunctionCognitiveComplexityCheckTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ void check() throws IOException {
4343
assertThat(issues).isNotNull();
4444

4545
var softly = new SoftAssertions();
46-
softly.assertThat(issues).hasSize(5);
4746
softly.assertThat(issues)
47+
.hasSize(5)
4848
.allSatisfy(issue -> assertThat(issue.getRuleId()).isEqualTo("FunctionCognitiveComplexity"));
4949

5050
CxxReportIssue issue0 = issues.stream().filter(issue -> issue.getLocations().get(0).getLine().equals("13"))

cxx-checks/src/test/java/org/sonar/cxx/checks/metrics/FunctionComplexityCheckTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ void check() throws IOException {
3939
var issues = MultiLocatitionSquidCheck.getMultiLocationCheckMessages(file);
4040
assertThat(issues).isNotNull();
4141
var softly = new SoftAssertions();
42-
softly.assertThat(issues).hasSize(5);
43-
softly.assertThat(issues).allSatisfy(issue -> assertThat(issue.getRuleId()).isEqualTo("FunctionComplexity"));
42+
softly.assertThat(issues)
43+
.hasSize(5)
44+
.allSatisfy(issue -> assertThat(issue.getRuleId()).isEqualTo("FunctionComplexity"));
4445

4546
var issue0 = issues.stream()
4647
.filter(issue -> issue.getLocations().get(0).getLine().equals("13"))

cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerSensor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected void processReport(File report) {
6060
try (var scanner = new TextScanner(report, reportEncoding)) {
6161
var pattern = Pattern.compile(reportRegEx);
6262
LOG.debug("Processing '{}' report '{}', Encoding='{}', Pattern='{}'",
63-
getCompilerKey(), report, scanner.encoding(), pattern);
63+
getCompilerKey(), report, scanner.encoding(), pattern);
6464

6565
while (scanner.hasNextLine()) {
6666
var matcher = pattern.matcher(scanner.nextLine());
@@ -117,8 +117,8 @@ protected void processReport(File report) {
117117
* @return true, if valid
118118
*/
119119
protected boolean isInputValid(@Nullable String filename,
120-
@Nullable String line, @Nullable String column,
121-
@Nullable String id, String msg) {
120+
@Nullable String line, @Nullable String column,
121+
@Nullable String id, String msg) {
122122
if ((id == null) || id.isEmpty()) {
123123
return false;
124124
}
@@ -193,7 +193,7 @@ private String getSubSequence(Matcher matcher, String groupName) {
193193
}
194194
} catch (IllegalArgumentException e) {
195195
notExistingGroupName.add(groupName);
196-
LOG.debug("named-capturing group '{}' is not used in regex.", groupName);
196+
LOG.debug("named-capturing group '{}' is not used in regex.", groupName, e);
197197
}
198198
return null;
199199
}

cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoverageMeasures.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Collection<CoverageMeasure> getCoverageMeasures() {
6262

6363
public Set<Integer> getCoveredLines() {
6464
var coveredLines = new HashSet<Integer>();
65-
lineMeasures.forEach((key, value) -> {
65+
lineMeasures.forEach((Integer key, CoverageMeasure value) -> {
6666
if (value.getHits() != 0) {
6767
coveredLines.add(value.getLine());
6868
}
@@ -72,7 +72,7 @@ public Set<Integer> getCoveredLines() {
7272

7373
public Set<Integer> getCoveredConditions() {
7474
var coveredConditionLines = new HashSet<Integer>();
75-
lineMeasures.forEach((key, value) -> {
75+
lineMeasures.forEach((Integer key, CoverageMeasure value) -> {
7676
if (value.getCoveredConditions() != 0) {
7777
coveredConditionLines.add(value.getLine());
7878
}

0 commit comments

Comments
 (0)