Skip to content

Commit f3c3b3c

Browse files
committed
merged pull request code from main
1 parent 195533f commit f3c3b3c

File tree

7 files changed

+63
-23
lines changed

7 files changed

+63
-23
lines changed

docs/sonarqube-fastlane.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Then add the following lane.
99
lane :metrics do
1010
scan(scheme: "[SCHEME]", code_coverage: true, derived_data_path: "./DerivedData", output_directory: "./reports")
1111
slather(cobertura_xml: true, jenkins: true, scheme: "[SCHEME]", build_directory: "./DerivedData", output_directory: "./reports", proj: "./[PROJECT].xcodeproj")
12-
lizard(source_folder: "[SOURCE_FOLDER]", language: "swift", export_type: "xml", report_file: "report/lizard-report.xml")
12+
lizard(source_folder: "[SOURCE_FOLDER]", language: "swift", export_type: "xml", report_file: "reports/lizard-report.xml")
1313
swiftlint(output_file: "./reports/swiftlint.txt", ignore_exit_status: true)
1414
sonar
1515
end

objclang/src/main/java/com/backelite/sonarqube/objectivec/issues/oclint/OCLintParser.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ private void collectFileViolations(String filePath, NodeList nodeList) {
8888
FilePredicate fp = context.fileSystem().predicates().hasAbsolutePath(file.getAbsolutePath());
8989
if(!context.fileSystem().hasFiles(fp)){
9090
LOGGER.warn("file not included in sonar {}", filePath);
91+
return;
9192
}
9293
InputFile inputFile = context.fileSystem().inputFile(fp);
9394
for (int i = 0; i < nodeList.getLength(); i++) {

objclang/src/main/resources/org/sonar/plugins/oclint/profile-oclint.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
<repositoryKey>OCLint</repositoryKey>
2828
<key>collapsible if statements</key>
2929
</rule>
30+
<rule>
31+
<repositoryKey>OCLint</repositoryKey>
32+
<key>compiler error</key>
33+
</rule>
34+
<rule>
35+
<repositoryKey>OCLint</repositoryKey>
36+
<key>compiler warning</key>
37+
</rule>
38+
<rule>
39+
<repositoryKey>OCLint</repositoryKey>
40+
<key>clang static analyzer</key>
41+
</rule>
3042
<rule>
3143
<repositoryKey>OCLint</repositoryKey>
3244
<key>constant conditional operator</key>

objclang/src/main/resources/org/sonar/plugins/oclint/rules.txt

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,30 @@ Category: OCLint
5454
constant conditional operator
5555
----------
5656

57+
Summary: Name: compiler error
58+
59+
Severity: 2
60+
Category: OCLint
61+
62+
compiler error
63+
----------
64+
65+
Summary: Name: compiler warning
66+
67+
Severity: 3
68+
Category: OCLint
69+
70+
compiler warning
71+
----------
72+
73+
Summary: Name: clang static analyzer
74+
75+
Severity: 3
76+
Category: OCLint
77+
78+
clang static analyzer
79+
----------
80+
5781
Summary: Name: constant conditional operator
5882

5983
Severity: 3
@@ -70,7 +94,7 @@ Category: OCLint
7094
high cyclomatic complexity
7195
----------
7296

73-
Summary:
97+
Summary:
7498

7599
Severity: 2
76100
Category: OCLint
@@ -158,15 +182,15 @@ Category: OCLint
158182
empty while statement
159183
----------
160184

161-
Summary:
185+
Summary:
162186

163187
Severity: 3
164188
Category: OCLint
165189

166190
feature envy
167191
----------
168192

169-
Summary:
193+
Summary:
170194

171195
Severity: 3
172196
Category: OCLint
@@ -182,7 +206,7 @@ Category: OCLint
182206
goto statement
183207
----------
184208

185-
Summary:
209+
Summary:
186210

187211
Severity: 3
188212
Category: OCLint
@@ -246,7 +270,7 @@ Category: OCLint
246270
misplaced nil check
247271
----------
248272

249-
Summary:
273+
Summary:
250274

251275
Severity: 4
252276
Category: OCLint
@@ -270,7 +294,7 @@ Category: OCLint
270294
must override hash with isEqual
271295
----------
272296

273-
Summary:
297+
Summary:
274298

275299
Severity: 1
276300
Category: OCLint
@@ -302,7 +326,7 @@ Category: OCLint
302326
high npath complexity
303327
----------
304328

305-
Summary:
329+
Summary:
306330

307331
Severity: 2
308332
Category: OCLint
@@ -358,31 +382,31 @@ Category: OCLint
358382
short variable name
359383
----------
360384

361-
Summary:
385+
Summary:
362386

363387
Severity: 2
364388
Category: OCLint
365389

366390
switch statements don't need default when fully covered
367391
----------
368392

369-
Summary:
393+
Summary:
370394

371395
Severity: 3
372396
Category: OCLint
373397

374398
throw exception from finally block
375399
----------
376400

377-
Summary:
401+
Summary:
378402

379403
Severity: 3
380404
Category: OCLint
381405

382406
too few branches in switch statement
383407
----------
384408

385-
Summary:
409+
Summary:
386410

387411
Severity: 2
388412
Category: OCLint
@@ -406,7 +430,7 @@ Category: OCLint
406430
too many parameters
407431
----------
408432

409-
Summary:
433+
Summary:
410434

411435
Severity: 3
412436
Category: OCLint
@@ -430,15 +454,15 @@ Category: OCLint
430454
unused method parameter
431455
----------
432456

433-
Summary:
457+
Summary:
434458

435459
Severity: 0
436460
Category: OCLint
437461

438462
useless parentheses
439463
----------
440464

441-
Summary:
465+
Summary:
442466

443467
Severity: 1
444468
Category: OCLint
@@ -526,7 +550,7 @@ Category: OCLint
526550
use object subscripting
527551
----------
528552

529-
Summary:
553+
Summary:
530554

531555
Severity: 1
532556
Category: OCLint
@@ -561,5 +585,4 @@ missing abstract method implementation
561585
Summary: Name: missing abstract method implementation
562586

563587
Severity: 1
564-
Category: OCLint
565-
588+
Category: OCLint

sonar-swift-plugin/src/main/java/com/backelite/sonarqube/swift/complexity/LizardReportParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private static class SwiftFunction implements InputModule {
178178

179179
public SwiftFunction(String name) {
180180
String[] vals = name.split(" at ");
181-
if (vals.length == 2) {
181+
if (vals.length >= 2) {
182182
this.name = vals[0].replaceAll("\\W","");
183183

184184
if (vals[1].contains(":")) {

sonar-swift-plugin/src/main/java/com/backelite/sonarqube/swift/complexity/LizardSensor.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,14 @@ public void describe(SensorDescriptor descriptor) {
5656

5757
@Override
5858
public void execute(SensorContext context) {
59-
String reportFileName = context.fileSystem().baseDir().getPath() + File.separator + reportPath();
60-
LOGGER.info("Processing complexity report: {}",reportFileName);
59+
File reportFile = new File(context.fileSystem().baseDir(), reportPath());
60+
if (!reportFile.isFile()) {
61+
LOGGER.warn("Lizard report file not found at {}", reportFile.getAbsolutePath());
62+
return;
63+
}
6164

65+
LOGGER.info("Processing complexity report: {}", reportFile.getAbsolutePath());
6266
LizardReportParser parser = new LizardReportParser(context);
63-
parser.parseReport(new File(reportFileName));
67+
parser.parseReport(reportFile);
6468
}
6569
}

sonar-swift-plugin/src/main/java/com/backelite/sonarqube/swift/coverage/CoberturaReportParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ private void collectClassMeasures(NodeList nodeList) {
9595

9696
private void collectFileData(String filePath, NodeList nodeList) {
9797
InputFile resource = getFile(filePath);
98-
LOGGER.info("Collect file data: {}",resource.toString());
9998
if (resource != null) {
99+
LOGGER.info("Collect file data: {}",resource.toString());
100100
boolean lineAdded = false;
101101
NewCoverage coverage = context.newCoverage();
102102
coverage.onFile(resource);

0 commit comments

Comments
 (0)