Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilles Grousset committed Feb 22, 2019
2 parents a6bdb73 + 541c14e commit f148bbb
Show file tree
Hide file tree
Showing 69 changed files with 1,238 additions and 2,237 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# _SonarQube Plugin for Swift_ Changelog

## v0.4.3
- Added support for SonarQube 7.3

## v0.4.2
- Fixed "rule does not exist" crash on Objective-C sensors

Expand Down
2 changes: 1 addition & 1 deletion README.md

Large diffs are not rendered by default.

28 changes: 6 additions & 22 deletions commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<parent>
<artifactId>backelite-swift</artifactId>
<groupId>com.backelite.sonarqube</groupId>
<version>0.4.2</version>
<version>0.4.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -41,36 +41,15 @@
<groupId>org.sonarsource.sslr-squid-bridge</groupId>
<artifactId>sslr-squid-bridge</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</dependency>

<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -111,6 +90,11 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,5 @@
* Created by gillesgrousset on 23/08/2018.
*/
public final class Constants {

// Common constants
public static final String FALSE = "false";

public static final String PROPERTY_PREFIX = "sonar.swift";

public static final String TEST_FRAMEWORK_KEY = PROPERTY_PREFIX + ".testframework";
public static final String TEST_FRAMEWORK_DEFAULT = "ghunit";

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,11 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.backelite.sonarqube.commons.surefire;
package com.backelite.sonarqube.commons;

import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;

import javax.annotation.Nullable;

/**
* Created by gillesgrousset on 28/08/2018.
*/
public interface TestFileFinder {

@Nullable
InputFile getUnitTestResource(FileSystem fileSystem, String classname);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,20 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.backelite.sonarqube.commons.surefire;
package com.backelite.sonarqube.commons;

import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;

import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;

public class TestFileFinders {

private static TestFileFinders instance;


private final List<TestFileFinder> finders = new ArrayList<>();

private TestFileFinders() {

}
private TestFileFinders() {}

public static synchronized TestFileFinders getInstance() {

if (instance == null) {
instance = new TestFileFinders();
}
Expand All @@ -47,9 +39,7 @@ public void addFinder(TestFileFinder finder) {
finders.add(finder);
}

@Nullable
InputFile getUnitTestResource(FileSystem fileSystem, String classname) {

public InputFile getUnitTestResource(FileSystem fileSystem, String classname) {
for (TestFileFinder finder : finders) {
InputFile result = finder.getUnitTestResource(fileSystem, classname);
if (result != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* commons - Enables analysis of Swift and Objective-C projects into SonarQube.
* Copyright © 2015 Backelite (${email})
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.backelite.sonarqube.commons.surefire;

import org.codehaus.staxmate.SMInputFactory;
import com.ctc.wstx.stax.WstxInputFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import org.codehaus.staxmate.in.SMHierarchicCursor;

public class StaxParser {

private SMInputFactory inf;
private SurefireStaxHandler streamHandler;

public StaxParser(UnitTestIndex index) {
this.streamHandler = new SurefireStaxHandler(index);
XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
if (xmlInputFactory instanceof WstxInputFactory) {
WstxInputFactory wstxInputfactory = (WstxInputFactory) xmlInputFactory;
wstxInputfactory.configureForLowMemUsage();
wstxInputfactory.getConfig().setUndeclaredEntityResolver((String publicID, String systemID, String baseURI, String namespace) -> namespace);
}
this.inf = new SMInputFactory(xmlInputFactory);
}

public void parse(File xmlFile) throws XMLStreamException {
try(FileInputStream input = new FileInputStream(xmlFile)) {
parse(inf.rootElementCursor(input));
} catch (IOException e) {
throw new XMLStreamException(e);
}
}

private void parse(SMHierarchicCursor rootCursor) throws XMLStreamException {
try {
streamHandler.stream(rootCursor);
} finally {
rootCursor.getStreamReader().closeCompletely();
}
}
}

This file was deleted.

Loading

0 comments on commit f148bbb

Please sign in to comment.