This repository has been archived by the owner on May 26, 2023. It is now read-only.
forked from Idean/sonar-swift
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '794c8f4ef76ee559a1af5f34cbbbc5943ca65503' into 0.4.4-volvo
* commit '794c8f4ef76ee559a1af5f34cbbbc5943ca65503': fix for cast exception licensing format update version update thanks @timothy-volvoIdean#207 version change thanks tim imports imports merged pull request code from main fix a space issue for lizardReport revert directory stream to original and keep sensors consistent # Conflicts: # commons/pom.xml # commons/src/main/java/com/backelite/sonarqube/commons/surefire/SurefireSensor.java # objclang/pom.xml # objclang/src/main/java/com/backelite/sonarqube/objectivec/ObjectiveCSquidSensor.java # objclang/src/main/java/com/backelite/sonarqube/objectivec/issues/oclint/OCLintParser.java # pom.xml # sonar-swift-plugin/pom.xml # sonar-swift-plugin/src/main/java/com/backelite/sonarqube/swift/complexity/LizardReportParser.java # sonar-swift-plugin/src/test/resources/lizard-report.xml # swiftlang/pom.xml # swiftlang/src/main/java/com/backelite/sonarqube/swift/SwiftSquidSensor.java # swiftlang/src/main/resources/org/sonar/plugins/swiftlint/profile-swiftlint.xml # swiftlang/src/main/resources/org/sonar/plugins/swiftlint/rules.json
- Loading branch information
Showing
14 changed files
with
507 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
...plugin/src/test/java/com/backelite/sonarqube/swift/complexity/LizardReportParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/** | ||
* backelite-sonar-swift-plugin - 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.swift.complexity; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.ArgumentCaptor; | ||
import org.mockito.Captor; | ||
import org.mockito.Mock; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
import org.sonar.api.batch.fs.*; | ||
import org.sonar.api.batch.measure.Metric; | ||
import org.sonar.api.batch.sensor.SensorContext; | ||
import org.sonar.api.batch.sensor.measure.NewMeasure; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.Mockito.when; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class LizardReportParserTest { | ||
|
||
@Mock | ||
SensorContext sensorContext; | ||
|
||
@Mock | ||
FileSystem fileSystem; | ||
|
||
@Mock | ||
FilePredicates filePredicates; | ||
|
||
@Mock | ||
FilePredicate filePredicate; | ||
|
||
@Mock | ||
InputFile inputFile; | ||
|
||
@Mock | ||
NewMeasure<Integer> newMeasure; | ||
|
||
@Captor | ||
ArgumentCaptor<String> hasRelativePathCaptor; | ||
|
||
@Captor | ||
ArgumentCaptor<InputComponent> onCaptor; | ||
|
||
@Captor | ||
ArgumentCaptor<Metric<Integer>> forMetricCaptor; | ||
|
||
@Captor | ||
ArgumentCaptor<Integer> withValueCaptor; | ||
|
||
|
||
@Test | ||
public void parseSimpleFile() { | ||
|
||
LizardReportParser parser = new LizardReportParser(sensorContext); | ||
File xmlFile = new File("src/test/resources/lizard-report.xml"); | ||
|
||
when(sensorContext.<Integer>newMeasure()).thenReturn(newMeasure); | ||
when(newMeasure.on(onCaptor.capture())).thenReturn(newMeasure); | ||
when(newMeasure.forMetric(forMetricCaptor.capture())).thenReturn(newMeasure); | ||
when(newMeasure.withValue(withValueCaptor.capture())).thenReturn(newMeasure); | ||
|
||
when(sensorContext.fileSystem()).thenReturn(fileSystem); | ||
when(fileSystem.predicates()).thenReturn(filePredicates); | ||
when(filePredicates.hasRelativePath(hasRelativePathCaptor.capture())).thenReturn(filePredicate); | ||
when(fileSystem.hasFiles(filePredicate)).thenReturn(true); | ||
when(fileSystem.inputFile(filePredicate)).thenReturn(inputFile); | ||
|
||
parser.parseReport(xmlFile); | ||
|
||
assertEquals(5, onCaptor.getAllValues().size()); | ||
assertEquals(5, forMetricCaptor.getAllValues().size()); | ||
|
||
assertEquals(Arrays.asList(1, 4, 8, 5, 46), withValueCaptor.getAllValues()); | ||
assertEquals(Arrays.asList("./Folder With Space/File With Space.swift"), hasRelativePathCaptor.getAllValues()); | ||
} | ||
|
||
} |
Oops, something went wrong.