Skip to content

Commit c24b8e0

Browse files
author
Gilles Grousset
committed
Code reformatting
1 parent 065604d commit c24b8e0

File tree

77 files changed

+4145
-4213
lines changed

Some content is hidden

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

77 files changed

+4145
-4213
lines changed

commons/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
2020
-->
21-
<project xmlns="http://maven.apache.org/POM/4.0.0"
22-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xmlns="http://maven.apache.org/POM/4.0.0"
2323
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2424
<parent>
2525
<artifactId>backelite-swift</artifactId>

commons/src/main/java/com/backelite/sonarqube/commons/surefire/BaseSurefireParser.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ protected BaseSurefireParser(FileSystem fileSystem, ResourcePerspectives perspec
5353
this.context = context;
5454
}
5555

56+
private static void parseFiles(File[] reports, UnitTestIndex index) {
57+
SurefireStaxHandler staxParser = new SurefireStaxHandler(index);
58+
StaxParser parser = new StaxParser(staxParser, false);
59+
for (File report : reports) {
60+
try {
61+
parser.parse(report);
62+
} catch (XMLStreamException e) {
63+
throw new IllegalStateException("Fail to parse the Surefire report: " + report, e);
64+
}
65+
}
66+
}
67+
5668
public void collect(File reportsDir) {
5769

5870

@@ -89,18 +101,6 @@ private void parseFiles(File[] reports) {
89101
save(index);
90102
}
91103

92-
private static void parseFiles(File[] reports, UnitTestIndex index) {
93-
SurefireStaxHandler staxParser = new SurefireStaxHandler(index);
94-
StaxParser parser = new StaxParser(staxParser, false);
95-
for (File report : reports) {
96-
try {
97-
parser.parse(report);
98-
} catch (XMLStreamException e) {
99-
throw new IllegalStateException("Fail to parse the Surefire report: " + report, e);
100-
}
101-
}
102-
}
103-
104104
private void save(UnitTestIndex index) {
105105
long negativeTimeTestNumber = 0;
106106

commons/src/main/java/com/backelite/sonarqube/commons/surefire/BaseSurefireSensor.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package com.backelite.sonarqube.commons.surefire;
1919

2020
import com.backelite.sonarqube.commons.Constants;
21-
import org.apache.commons.lang.StringUtils;
2221
import org.slf4j.Logger;
2322
import org.slf4j.LoggerFactory;
2423
import org.sonar.api.batch.Sensor;
@@ -36,12 +35,9 @@
3635
*/
3736
public abstract class BaseSurefireSensor implements Sensor {
3837

39-
protected static final Logger LOGGER = LoggerFactory.getLogger(BaseSurefireSensor.class);
40-
4138
public static final String REPORTS_PATH_KEY = Constants.PROPERTY_PREFIX + ".surefire.junit.reportsPath";
4239
public static final String DEFAULT_REPORTS_PATH = "sonar-reports/";
43-
44-
40+
protected static final Logger LOGGER = LoggerFactory.getLogger(BaseSurefireSensor.class);
4541
protected final FileSystem fileSystem;
4642
protected final PathResolver pathResolver;
4743
protected final ResourcePerspectives resourcePerspectives;

commons/src/main/java/com/backelite/sonarqube/commons/surefire/SurefireStaxHandler.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,6 @@ public SurefireStaxHandler(UnitTestIndex index) {
3737
this.index = index;
3838
}
3939

40-
public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
41-
SMInputCursor testSuite = rootCursor.constructDescendantCursor(new ElementFilter("testsuite"));
42-
SMEvent testSuiteEvent;
43-
for (testSuiteEvent = testSuite.getNext(); testSuiteEvent != null; testSuiteEvent = testSuite.getNext()) {
44-
if (testSuiteEvent.compareTo(SMEvent.START_ELEMENT) == 0) {
45-
String testSuiteClassName = testSuite.getAttrValue("name");
46-
if (StringUtils.contains(testSuiteClassName, "$")) {
47-
// test suites for inner classes are ignored
48-
return;
49-
}
50-
SMInputCursor testCase = testSuite.childCursor(new ElementFilter("testcase"));
51-
SMEvent event;
52-
for (event = testCase.getNext(); event != null; event = testCase.getNext()) {
53-
if (event.compareTo(SMEvent.START_ELEMENT) == 0) {
54-
String testClassName = getClassname(testCase, testSuiteClassName);
55-
UnitTestClassReport classReport = index.index(testClassName);
56-
parseTestCase(testCase, classReport);
57-
}
58-
}
59-
}
60-
}
61-
}
62-
6340
private static String getClassname(SMInputCursor testCaseCursor,
6441
String defaultClassname) throws XMLStreamException {
6542
String testClassName = testCaseCursor.getAttrValue("classname");
@@ -136,4 +113,27 @@ private static String getTestCaseName(SMInputCursor testCaseCursor) throws XMLSt
136113
}
137114
return name;
138115
}
116+
117+
public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
118+
SMInputCursor testSuite = rootCursor.constructDescendantCursor(new ElementFilter("testsuite"));
119+
SMEvent testSuiteEvent;
120+
for (testSuiteEvent = testSuite.getNext(); testSuiteEvent != null; testSuiteEvent = testSuite.getNext()) {
121+
if (testSuiteEvent.compareTo(SMEvent.START_ELEMENT) == 0) {
122+
String testSuiteClassName = testSuite.getAttrValue("name");
123+
if (StringUtils.contains(testSuiteClassName, "$")) {
124+
// test suites for inner classes are ignored
125+
return;
126+
}
127+
SMInputCursor testCase = testSuite.childCursor(new ElementFilter("testcase"));
128+
SMEvent event;
129+
for (event = testCase.getNext(); event != null; event = testCase.getNext()) {
130+
if (event.compareTo(SMEvent.START_ELEMENT) == 0) {
131+
String testClassName = getClassname(testCase, testSuiteClassName);
132+
UnitTestClassReport classReport = index.index(testClassName);
133+
parseTestCase(testCase, classReport);
134+
}
135+
}
136+
}
137+
}
138+
}
139139
}

commons/src/main/java/com/backelite/sonarqube/commons/surefire/UnitTestIndex.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public int size() {
6161

6262
public UnitTestClassReport merge(String classname, String intoClassname) {
6363
UnitTestClassReport from = indexByClassname.get(classname);
64-
if (from!=null) {
64+
if (from != null) {
6565
UnitTestClassReport to = index(intoClassname);
6666
to.add(from);
6767
indexByClassname.remove(classname);

objclang/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
2020
-->
21-
<project xmlns="http://maven.apache.org/POM/4.0.0"
22-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xmlns="http://maven.apache.org/POM/4.0.0"
2323
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2424
<parent>
2525
<artifactId>backelite-swift</artifactId>

objclang/src/main/java/com/backelite/sonarqube/objectivec/ObjectiveCSquidSensor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
*/
1818
package com.backelite.sonarqube.objectivec;
1919

20+
import com.backelite.sonarqube.objectivec.lang.ObjectiveCAstScanner;
21+
import com.backelite.sonarqube.objectivec.lang.ObjectiveCConfiguration;
22+
import com.backelite.sonarqube.objectivec.lang.api.ObjectiveCGrammar;
23+
import com.backelite.sonarqube.objectivec.lang.api.ObjectiveCMetric;
24+
import com.backelite.sonarqube.objectivec.lang.checks.CheckList;
2025
import com.backelite.sonarqube.objectivec.lang.core.ObjectiveC;
2126
import com.google.common.collect.ImmutableList;
2227
import com.google.common.collect.Lists;
@@ -35,11 +40,6 @@
3540
import org.sonar.api.resources.Resource;
3641
import org.sonar.api.rule.RuleKey;
3742
import org.sonar.api.scan.filesystem.PathResolver;
38-
import com.backelite.sonarqube.objectivec.lang.ObjectiveCAstScanner;
39-
import com.backelite.sonarqube.objectivec.lang.ObjectiveCConfiguration;
40-
import com.backelite.sonarqube.objectivec.lang.api.ObjectiveCGrammar;
41-
import com.backelite.sonarqube.objectivec.lang.api.ObjectiveCMetric;
42-
import com.backelite.sonarqube.objectivec.lang.checks.CheckList;
4343
import org.sonar.squidbridge.AstScanner;
4444
import org.sonar.squidbridge.SquidAstVisitor;
4545
import org.sonar.squidbridge.api.CheckMessage;

objclang/src/main/java/com/backelite/sonarqube/objectivec/cpd/ObjectiveCCpdMapping.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717
*/
1818
package com.backelite.sonarqube.objectivec.cpd;
1919

20-
import java.nio.charset.Charset;
21-
2220
import com.backelite.sonarqube.objectivec.lang.core.ObjectiveC;
2321
import net.sourceforge.pmd.cpd.Tokenizer;
24-
2522
import org.sonar.api.batch.AbstractCpdMapping;
2623
import org.sonar.api.batch.fs.FileSystem;
2724
import org.sonar.api.resources.Language;
2825

26+
import java.nio.charset.Charset;
27+
2928
public class ObjectiveCCpdMapping extends AbstractCpdMapping {
3029

3130
private final ObjectiveC language;

objclang/src/main/java/com/backelite/sonarqube/objectivec/cpd/ObjectiveCTokenizer.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,19 @@
1717
*/
1818
package com.backelite.sonarqube.objectivec.cpd;
1919

20-
import java.io.File;
21-
import java.io.IOException;
22-
import java.nio.charset.Charset;
23-
import java.util.List;
24-
20+
import com.backelite.sonarqube.objectivec.lang.ObjectiveCConfiguration;
21+
import com.backelite.sonarqube.objectivec.lang.lexer.ObjectiveCLexer;
22+
import com.sonar.sslr.api.Token;
23+
import com.sonar.sslr.impl.Lexer;
2524
import net.sourceforge.pmd.cpd.SourceCode;
2625
import net.sourceforge.pmd.cpd.TokenEntry;
2726
import net.sourceforge.pmd.cpd.Tokenizer;
2827
import net.sourceforge.pmd.cpd.Tokens;
2928

30-
import com.backelite.sonarqube.objectivec.lang.ObjectiveCConfiguration;
31-
import com.backelite.sonarqube.objectivec.lang.lexer.ObjectiveCLexer;
32-
33-
import com.sonar.sslr.api.Token;
34-
import com.sonar.sslr.impl.Lexer;
29+
import java.io.File;
30+
import java.io.IOException;
31+
import java.nio.charset.Charset;
32+
import java.util.List;
3533

3634
public class ObjectiveCTokenizer implements Tokenizer {
3735

objclang/src/main/java/com/backelite/sonarqube/objectivec/issues/ObjectiveCProfile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
*/
1818
package com.backelite.sonarqube.objectivec.issues;
1919

20-
import com.backelite.sonarqube.objectivec.lang.core.ObjectiveC;
2120
import com.backelite.sonarqube.objectivec.issues.fauxpas.FauxPasProfile;
2221
import com.backelite.sonarqube.objectivec.issues.fauxpas.FauxPasProfileImporter;
2322
import com.backelite.sonarqube.objectivec.issues.oclint.OCLintProfile;
23+
import com.backelite.sonarqube.objectivec.issues.oclint.OCLintProfileImporter;
24+
import com.backelite.sonarqube.objectivec.lang.core.ObjectiveC;
2425
import com.google.common.io.Closeables;
2526
import org.slf4j.Logger;
2627
import org.slf4j.LoggerFactory;
2728
import org.sonar.api.profiles.ProfileDefinition;
2829
import org.sonar.api.profiles.RulesProfile;
2930
import org.sonar.api.rules.ActiveRule;
3031
import org.sonar.api.utils.ValidationMessages;
31-
import com.backelite.sonarqube.objectivec.issues.oclint.OCLintProfileImporter;
3232

3333
import java.io.InputStreamReader;
3434
import java.io.Reader;

0 commit comments

Comments
 (0)