@@ -11,6 +11,7 @@ dependencies { | |||
runtime project(path: ':sonar-plugin-api', configuration: 'shadow') | |||
compileOnly project(path: ':sonar-plugin-api') | |||
testCompile project(path: ':sonar-scanner-engine') | |||
testCompile 'junit:junit' | |||
testCompile 'org.assertj:assertj-core' | |||
testCompile 'org.mockito:mockito-core' |
@@ -28,9 +28,9 @@ import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.sensor.DefaultSensorDescriptor; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -28,9 +28,9 @@ import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.sensor.DefaultSensorDescriptor; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -28,9 +28,9 @@ import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.sensor.DefaultSensorDescriptor; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -19,14 +19,12 @@ | |||
*/ | |||
package org.sonar.xoo.extensions; | |||
import java.util.Arrays; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.sonar.api.batch.postjob.PostJobContext; | |||
import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor; | |||
import org.sonar.api.batch.postjob.issue.PostJobIssue; | |||
import org.sonar.api.utils.log.LogTester; | |||
import java.util.Arrays; | |||
import org.sonar.scanner.postjob.DefaultPostJobDescriptor; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; |
@@ -28,9 +28,9 @@ import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.sensor.DefaultSensorDescriptor; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.assertj.core.api.Assertions.tuple; |
@@ -29,12 +29,12 @@ import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.measure.MetricFinder; | |||
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.api.measures.CoreMetrics; | |||
import org.sonar.api.measures.Metric; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.sensor.DefaultSensorDescriptor; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; |
@@ -31,9 +31,9 @@ import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.TextRange; | |||
import org.sonar.api.batch.fs.internal.DefaultTextPointer; | |||
import org.sonar.api.batch.fs.internal.DefaultTextRange; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.sensor.DefaultSensorDescriptor; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -29,9 +29,9 @@ import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultTextPointer; | |||
import org.sonar.api.batch.fs.internal.DefaultTextRange; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.sensor.DefaultSensorDescriptor; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import org.sonar.xoo.Xoo; | |||
import static org.assertj.core.api.Assertions.assertThat; |
@@ -27,10 +27,10 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.highlighting.TypeOfText; | |||
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.sensor.DefaultSensorDescriptor; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -25,16 +25,15 @@ import java.nio.file.Files; | |||
import java.nio.file.Path; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultTextPointer; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.error.AnalysisError; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -26,13 +26,13 @@ import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.SonarQubeSide; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.rule.Severity; | |||
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.api.batch.sensor.issue.Issue; | |||
import org.sonar.api.internal.SonarRuntimeImpl; | |||
import org.sonar.api.utils.Version; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.sensor.DefaultSensorDescriptor; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import org.sonar.xoo.Xoo; | |||
import static org.assertj.core.api.Assertions.assertThat; |
@@ -28,13 +28,13 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.internal.DefaultFileSystem; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.scm.BlameCommand.BlameInput; | |||
import org.sonar.api.batch.scm.BlameCommand.BlameOutput; | |||
import org.sonar.api.batch.scm.BlameLine; | |||
import org.sonar.api.utils.DateUtils; | |||
import org.sonar.scanner.fs.DefaultFileSystem; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.xoo.Xoo; | |||
import static java.util.Collections.singletonList; |
@@ -33,6 +33,7 @@ dependencies { | |||
testCompile 'com.tngtech.java:junit-dataprovider' | |||
testCompile 'org.assertj:assertj-core' | |||
testCompile 'org.mockito:mockito-core' | |||
testCompile project(':sonar-scanner-engine') | |||
} | |||
sourceSets { |
@@ -25,6 +25,7 @@ import java.io.InputStream; | |||
import java.net.URI; | |||
import java.nio.file.Files; | |||
import java.nio.file.Path; | |||
import java.util.concurrent.atomic.AtomicInteger; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import javax.annotation.concurrent.Immutable; | |||
@@ -37,6 +38,8 @@ import org.sonar.api.utils.PathUtils; | |||
*/ | |||
@Immutable | |||
public class DefaultIndexedFile extends DefaultInputComponent implements IndexedFile { | |||
private static AtomicInteger intGenerator = new AtomicInteger(0); | |||
private final String projectRelativePath; | |||
private final String moduleRelativePath; | |||
private final String projectKey; | |||
@@ -45,6 +48,14 @@ public class DefaultIndexedFile extends DefaultInputComponent implements Indexed | |||
private final Path absolutePath; | |||
private final SensorStrategy sensorStrategy; | |||
/** | |||
* Testing purposes only! | |||
*/ | |||
public DefaultIndexedFile(String projectKey, Path baseDir, String relativePath, @Nullable String language) { | |||
this(baseDir.resolve(relativePath), projectKey, relativePath, relativePath, Type.MAIN, language, intGenerator.getAndIncrement(), | |||
new SensorStrategy()); | |||
} | |||
public DefaultIndexedFile(Path absolutePath, String projectKey, String projectRelativePath, String moduleRelativePath, Type type, @Nullable String language, int batchId, | |||
SensorStrategy sensorStrategy) { | |||
super(batchId); |
@@ -1,21 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2019 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* 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, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@javax.annotation.ParametersAreNonnullByDefault | |||
package org.sonar.api.batch.postjob.internal; |
@@ -1,21 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2019 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* 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, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
@javax.annotation.ParametersAreNonnullByDefault | |||
package org.sonar.api.batch.sensor.highlighting.internal; |
@@ -19,20 +19,21 @@ | |||
*/ | |||
package org.sonar.api.batch.sensor.internal; | |||
import org.sonar.api.batch.sensor.issue.ExternalIssue; | |||
import org.sonar.api.batch.sensor.rule.AdHocRule; | |||
import org.sonar.api.scanner.ScannerSide; | |||
import org.sonar.api.batch.sensor.code.internal.DefaultSignificantCode; | |||
import org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage; | |||
import org.sonar.api.batch.sensor.cpd.internal.DefaultCpdTokens; | |||
import org.sonar.api.batch.sensor.error.AnalysisError; | |||
import org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting; | |||
import org.sonar.api.batch.sensor.highlighting.NewHighlighting; | |||
import org.sonar.api.batch.sensor.issue.ExternalIssue; | |||
import org.sonar.api.batch.sensor.issue.Issue; | |||
import org.sonar.api.batch.sensor.measure.Measure; | |||
import org.sonar.api.batch.sensor.rule.AdHocRule; | |||
import org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable; | |||
import org.sonar.api.scanner.ScannerSide; | |||
/** | |||
* Interface for storing data computed by sensors. | |||
* | |||
* @since 5.1 | |||
*/ | |||
@ScannerSide | |||
@@ -46,7 +47,7 @@ public interface SensorStorage { | |||
void store(AdHocRule adHocRule); | |||
void store(DefaultHighlighting highlighting); | |||
void store(NewHighlighting highlighting); | |||
/** | |||
* @since 5.2 | |||
@@ -54,12 +55,12 @@ public interface SensorStorage { | |||
void store(DefaultCoverage defaultCoverage); | |||
/** | |||
* @since 5.5 | |||
* @since 5.5 | |||
*/ | |||
void store(DefaultCpdTokens defaultCpdTokens); | |||
/** | |||
* @since 5.6 | |||
* @since 5.6 | |||
*/ | |||
void store(DefaultSymbolTable symbolTable); | |||
@@ -70,6 +71,7 @@ public interface SensorStorage { | |||
/** | |||
* Value is overridden if the key was already stored. | |||
* | |||
* @throws IllegalArgumentException if key is null | |||
* @throws IllegalArgumentException if value is null | |||
* @since 6.1 |
@@ -20,11 +20,9 @@ | |||
package org.sonar.api.internal; | |||
import java.io.IOException; | |||
import java.net.URISyntaxException; | |||
import java.net.URL; | |||
import java.nio.charset.StandardCharsets; | |||
import java.nio.file.Files; | |||
import java.nio.file.Paths; | |||
import java.util.Scanner; | |||
import org.sonar.api.SonarEdition; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.api.utils.Version; | |||
@@ -48,10 +46,11 @@ public class MetadataLoader { | |||
public static Version loadVersion(System2 system) { | |||
try { | |||
URL url = system.getResource(VERSION_FILE_PATH); | |||
String versionInFile = new String(Files.readAllBytes(Paths.get(url.toURI())), StandardCharsets.UTF_8); | |||
Scanner scanner = new Scanner(url.openStream(), StandardCharsets.UTF_8.name()); | |||
String versionInFile = scanner.nextLine(); | |||
return Version.parse(versionInFile); | |||
} catch (IOException | URISyntaxException e) { | |||
throw new IllegalStateException("Can not load " + VERSION_FILE_PATH + " from classpath", e); | |||
} catch (IOException e) { | |||
throw new IllegalStateException("Can not load " + VERSION_FILE_PATH + " from classpath ", e); | |||
} | |||
} | |||
@@ -61,9 +60,10 @@ public class MetadataLoader { | |||
if (url == null) { | |||
return SonarEdition.COMMUNITY; | |||
} | |||
String editionInFile = new String(Files.readAllBytes(Paths.get(url.toURI())), StandardCharsets.UTF_8); | |||
Scanner scanner = new Scanner(url.openStream(), StandardCharsets.UTF_8.name()); | |||
String editionInFile = scanner.nextLine(); | |||
return parseEdition(editionInFile); | |||
} catch (IOException | URISyntaxException e) { | |||
} catch (IOException e) { | |||
throw new IllegalStateException("Can not load " + EDITION_FILE_PATH + " from classpath", e); | |||
} | |||
} |
@@ -40,6 +40,7 @@ import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.TextRange; | |||
import org.sonar.scanner.fs.FileMetadata; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.junit.Assert.fail; |
@@ -28,6 +28,7 @@ import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.InputFile.Status; | |||
import org.sonar.api.batch.fs.InputFile.Type; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -21,10 +21,10 @@ package org.sonar.api.batch.rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.sonar.api.batch.rule.internal.ActiveRulesBuilder; | |||
import org.sonar.api.batch.rule.internal.NewActiveRule; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.utils.SonarException; | |||
import org.sonar.scanner.rule.ActiveRulesBuilder; | |||
import org.sonar.scanner.rule.NewActiveRule; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -23,8 +23,9 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.verify; | |||
@@ -22,8 +22,8 @@ package org.sonar.api.batch.sensor.cpd.internal; | |||
import org.junit.Test; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.assertj.core.api.Assertions.fail; |
@@ -30,9 +30,10 @@ import org.junit.rules.ExpectedException; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.TextPointer; | |||
import org.sonar.api.batch.fs.internal.DefaultTextPointer; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.error.NewAnalysisError; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.junit.Assert.*; | |||
@@ -27,8 +27,8 @@ import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.TextRange; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; |
@@ -23,7 +23,7 @@ import java.util.Arrays; | |||
import java.util.HashSet; | |||
import org.junit.Test; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -32,10 +32,10 @@ public class NoSonarFilterTest { | |||
@Test | |||
public void should_store_nosonar_lines_on_inputfile() { | |||
DefaultInputFile f = TestInputFileBuilder.create("module1", "myfile.java").setLines(8).build(); | |||
new NoSonarFilter().noSonarInFile(f, new HashSet<>(Arrays.asList(1,4))); | |||
new NoSonarFilter().noSonarInFile(f, new HashSet<>(Arrays.asList(1, 4))); | |||
assertThat(f.hasNoSonarAt(1)).isTrue(); | |||
assertThat(f.hasNoSonarAt(2)).isFalse(); | |||
assertThat(f.hasNoSonarAt(4)).isTrue(); | |||
assertThat(f.hasNoSonarAt(1)).isTrue(); | |||
assertThat(f.hasNoSonarAt(2)).isFalse(); | |||
assertThat(f.hasNoSonarAt(4)).isTrue(); | |||
} | |||
} |
@@ -34,6 +34,7 @@ import org.apache.commons.lang.StringUtils; | |||
import org.apache.commons.lang.SystemUtils; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.batch.bootstrap.ProjectDefinition; | |||
import org.sonar.api.batch.fs.internal.DefaultInputComponent; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
@@ -37,6 +37,7 @@ import org.sonar.api.batch.fs.FilePredicates; | |||
import org.sonar.api.batch.fs.FileSystem; | |||
import org.sonar.api.batch.fs.InputDir; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputDir; | |||
import org.sonar.api.scan.filesystem.PathResolver; | |||
import org.sonar.api.utils.PathUtils; | |||
import org.sonar.scanner.fs.predicates.DefaultFilePredicates; |
@@ -1,158 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2019 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* 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, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.scanner.fs; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.net.URI; | |||
import java.nio.file.Files; | |||
import java.nio.file.Path; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import javax.annotation.concurrent.Immutable; | |||
import org.sonar.api.batch.fs.IndexedFile; | |||
import org.sonar.api.batch.fs.InputFile.Type; | |||
import org.sonar.api.utils.PathUtils; | |||
/** | |||
* @since 6.3 | |||
*/ | |||
@Immutable | |||
public class DefaultIndexedFile extends DefaultInputComponent implements IndexedFile { | |||
private final String projectRelativePath; | |||
private final String moduleRelativePath; | |||
private final String projectKey; | |||
private final String language; | |||
private final Type type; | |||
private final Path absolutePath; | |||
private final SensorStrategy sensorStrategy; | |||
/** | |||
* Testing purposes only! | |||
*/ | |||
public DefaultIndexedFile(String projectKey, Path baseDir, String relativePath, @Nullable String language) { | |||
this(baseDir.resolve(relativePath), projectKey, relativePath, relativePath, Type.MAIN, language, TestInputFileBuilder.nextBatchId(), | |||
new SensorStrategy()); | |||
} | |||
public DefaultIndexedFile(Path absolutePath, String projectKey, String projectRelativePath, String moduleRelativePath, Type type, @Nullable String language, int batchId, | |||
SensorStrategy sensorStrategy) { | |||
super(batchId); | |||
this.projectKey = projectKey; | |||
this.projectRelativePath = PathUtils.sanitize(projectRelativePath); | |||
this.moduleRelativePath = PathUtils.sanitize(moduleRelativePath); | |||
this.type = type; | |||
this.language = language; | |||
this.sensorStrategy = sensorStrategy; | |||
this.absolutePath = absolutePath; | |||
} | |||
@Override | |||
public String relativePath() { | |||
return sensorStrategy.isGlobal() ? projectRelativePath : moduleRelativePath; | |||
} | |||
public String getModuleRelativePath() { | |||
return moduleRelativePath; | |||
} | |||
public String getProjectRelativePath() { | |||
return projectRelativePath; | |||
} | |||
@Override | |||
public String absolutePath() { | |||
return PathUtils.sanitize(path().toString()); | |||
} | |||
@Override | |||
public File file() { | |||
return path().toFile(); | |||
} | |||
@Override | |||
public Path path() { | |||
return absolutePath; | |||
} | |||
@Override | |||
public InputStream inputStream() throws IOException { | |||
return Files.newInputStream(path()); | |||
} | |||
@CheckForNull | |||
@Override | |||
public String language() { | |||
return language; | |||
} | |||
@Override | |||
public Type type() { | |||
return type; | |||
} | |||
/** | |||
* Component key (without branch). | |||
*/ | |||
@Override | |||
public String key() { | |||
return new StringBuilder().append(projectKey).append(":").append(projectRelativePath).toString(); | |||
} | |||
@Override | |||
public boolean equals(Object o) { | |||
if (this == o) { | |||
return true; | |||
} | |||
if (!(o instanceof DefaultIndexedFile)) { | |||
return false; | |||
} | |||
DefaultIndexedFile that = (DefaultIndexedFile) o; | |||
return projectRelativePath.equals(that.projectRelativePath); | |||
} | |||
@Override | |||
public int hashCode() { | |||
return projectRelativePath.hashCode(); | |||
} | |||
@Override | |||
public String toString() { | |||
return projectRelativePath; | |||
} | |||
@Override | |||
public boolean isFile() { | |||
return true; | |||
} | |||
@Override | |||
public String filename() { | |||
return path().getFileName().toString(); | |||
} | |||
@Override | |||
public URI uri() { | |||
return path().toUri(); | |||
} | |||
} |
@@ -1,72 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2019 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* 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, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.scanner.fs; | |||
import java.util.HashSet; | |||
import java.util.Set; | |||
import org.sonar.api.batch.fs.InputComponent; | |||
import org.sonar.api.batch.measure.Metric; | |||
/** | |||
* @since 5.2 | |||
*/ | |||
public abstract class DefaultInputComponent implements InputComponent { | |||
private int id; | |||
private Set<String> storedMetricKeys = new HashSet<>(); | |||
public DefaultInputComponent(int scannerId) { | |||
this.id = scannerId; | |||
} | |||
@Override | |||
public boolean equals(Object o) { | |||
if (this == o) { | |||
return true; | |||
} | |||
if (o == null || this.getClass() != o.getClass()) { | |||
return false; | |||
} | |||
DefaultInputComponent that = (DefaultInputComponent) o; | |||
return key().equals(that.key()); | |||
} | |||
public int scannerId() { | |||
return id; | |||
} | |||
@Override | |||
public int hashCode() { | |||
return key().hashCode(); | |||
} | |||
@Override | |||
public String toString() { | |||
return "[key=" + key() + "]"; | |||
} | |||
public void setHasMeasureFor(Metric metric) { | |||
storedMetricKeys.add(metric.key()); | |||
} | |||
public boolean hasMeasureFor(Metric metric) { | |||
return storedMetricKeys.contains(metric.key()); | |||
} | |||
} |
@@ -1,122 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2019 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* 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, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.scanner.fs; | |||
import java.io.File; | |||
import java.net.URI; | |||
import java.nio.file.Path; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.api.batch.fs.InputDir; | |||
import org.sonar.api.utils.PathUtils; | |||
/** | |||
* @since 4.5 | |||
*/ | |||
public class DefaultInputDir extends DefaultInputComponent implements InputDir { | |||
private final String relativePath; | |||
private final String moduleKey; | |||
private Path moduleBaseDir; | |||
public DefaultInputDir(String moduleKey, String relativePath) { | |||
super(-1); | |||
this.moduleKey = moduleKey; | |||
this.relativePath = PathUtils.sanitize(relativePath); | |||
} | |||
@Override | |||
public String relativePath() { | |||
return relativePath; | |||
} | |||
@Override | |||
public String absolutePath() { | |||
return PathUtils.sanitize(path().toString()); | |||
} | |||
@Override | |||
public File file() { | |||
return path().toFile(); | |||
} | |||
@Override | |||
public Path path() { | |||
if (moduleBaseDir == null) { | |||
throw new IllegalStateException("Can not return the java.nio.file.Path because module baseDir is not set (see method setModuleBaseDir(java.io.File))"); | |||
} | |||
return moduleBaseDir.resolve(relativePath); | |||
} | |||
public String moduleKey() { | |||
return moduleKey; | |||
} | |||
@Override | |||
public String key() { | |||
StringBuilder sb = new StringBuilder().append(moduleKey).append(":"); | |||
if (StringUtils.isEmpty(relativePath)) { | |||
sb.append("/"); | |||
} else { | |||
sb.append(relativePath); | |||
} | |||
return sb.toString(); | |||
} | |||
/** | |||
* For testing purpose. Will be automatically set when dir is added to {@link DefaultFileSystem} | |||
*/ | |||
public DefaultInputDir setModuleBaseDir(Path moduleBaseDir) { | |||
this.moduleBaseDir = moduleBaseDir.normalize(); | |||
return this; | |||
} | |||
@Override | |||
public boolean isFile() { | |||
return false; | |||
} | |||
@Override | |||
public boolean equals(Object o) { | |||
if (this == o) { | |||
return true; | |||
} | |||
if (o == null || this.getClass() != o.getClass()) { | |||
return false; | |||
} | |||
DefaultInputDir that = (DefaultInputDir) o; | |||
return moduleKey.equals(that.moduleKey) && relativePath.equals(that.relativePath); | |||
} | |||
@Override | |||
public int hashCode() { | |||
return moduleKey.hashCode() + relativePath.hashCode() * 13; | |||
} | |||
@Override | |||
public String toString() { | |||
return "[moduleKey=" + moduleKey + ", relative=" + relativePath + ", basedir=" + moduleBaseDir + "]"; | |||
} | |||
@Override | |||
public URI uri() { | |||
return path().toUri(); | |||
} | |||
} |
@@ -1,440 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2019 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* 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, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.scanner.fs; | |||
import java.io.ByteArrayInputStream; | |||
import java.io.ByteArrayOutputStream; | |||
import java.io.File; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.net.URI; | |||
import java.nio.charset.Charset; | |||
import java.nio.file.Files; | |||
import java.nio.file.Path; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.BitSet; | |||
import java.util.Collection; | |||
import java.util.Optional; | |||
import java.util.Set; | |||
import java.util.function.Consumer; | |||
import java.util.stream.Collectors; | |||
import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.apache.commons.io.ByteOrderMark; | |||
import org.apache.commons.io.input.BOMInputStream; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.TextPointer; | |||
import org.sonar.api.batch.fs.TextRange; | |||
import org.sonar.api.batch.fs.internal.Metadata; | |||
import static org.sonar.api.utils.Preconditions.checkArgument; | |||
import static org.sonar.api.utils.Preconditions.checkState; | |||
/** | |||
* @since 4.2 | |||
* To create {@link InputFile} in tests, use {@link TestInputFileBuilder}. | |||
*/ | |||
public class DefaultInputFile extends DefaultInputComponent implements InputFile { | |||
private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; | |||
private final DefaultIndexedFile indexedFile; | |||
private final String contents; | |||
private final Consumer<DefaultInputFile> metadataGenerator; | |||
private boolean published; | |||
private boolean excludedForCoverage; | |||
private boolean excludedForDuplication; | |||
private boolean ignoreAllIssues; | |||
// Lazy init to save memory | |||
private BitSet noSonarLines; | |||
private Status status; | |||
private Charset charset; | |||
private Metadata metadata; | |||
private Collection<int[]> ignoreIssuesOnlineRanges; | |||
private BitSet executableLines; | |||
public DefaultInputFile(DefaultIndexedFile indexedFile, Consumer<DefaultInputFile> metadataGenerator) { | |||
this(indexedFile, metadataGenerator, null); | |||
} | |||
// For testing | |||
public DefaultInputFile(DefaultIndexedFile indexedFile, Consumer<DefaultInputFile> metadataGenerator, @Nullable String contents) { | |||
super(indexedFile.scannerId()); | |||
this.indexedFile = indexedFile; | |||
this.metadataGenerator = metadataGenerator; | |||
this.metadata = null; | |||
this.published = false; | |||
this.excludedForCoverage = false; | |||
this.contents = contents; | |||
} | |||
public void checkMetadata() { | |||
if (metadata == null) { | |||
metadataGenerator.accept(this); | |||
} | |||
} | |||
@Override | |||
public InputStream inputStream() throws IOException { | |||
return contents != null ? new ByteArrayInputStream(contents.getBytes(charset())) | |||
: new BOMInputStream(Files.newInputStream(path()), | |||
ByteOrderMark.UTF_8, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE); | |||
} | |||
@Override | |||
public String contents() throws IOException { | |||
if (contents != null) { | |||
return contents; | |||
} else { | |||
ByteArrayOutputStream result = new ByteArrayOutputStream(); | |||
try (InputStream inputStream = inputStream()) { | |||
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; | |||
int length; | |||
while ((length = inputStream.read(buffer)) != -1) { | |||
result.write(buffer, 0, length); | |||
} | |||
} | |||
return result.toString(charset().name()); | |||
} | |||
} | |||
public DefaultInputFile setPublished(boolean published) { | |||
this.published = published; | |||
return this; | |||
} | |||
public boolean isPublished() { | |||
return published; | |||
} | |||
public DefaultInputFile setExcludedForCoverage(boolean excludedForCoverage) { | |||
this.excludedForCoverage = excludedForCoverage; | |||
return this; | |||
} | |||
public boolean isExcludedForCoverage() { | |||
return excludedForCoverage; | |||
} | |||
public DefaultInputFile setExcludedForDuplication(boolean excludedForDuplication) { | |||
this.excludedForDuplication = excludedForDuplication; | |||
return this; | |||
} | |||
public boolean isExcludedForDuplication() { | |||
return excludedForDuplication; | |||
} | |||
/** | |||
* @deprecated since 6.6 | |||
*/ | |||
@Deprecated | |||
@Override | |||
public String relativePath() { | |||
return indexedFile.relativePath(); | |||
} | |||
public String getModuleRelativePath() { | |||
return indexedFile.getModuleRelativePath(); | |||
} | |||
public String getProjectRelativePath() { | |||
return indexedFile.getProjectRelativePath(); | |||
} | |||
@Override | |||
public String absolutePath() { | |||
return indexedFile.absolutePath(); | |||
} | |||
@Override | |||
public File file() { | |||
return indexedFile.file(); | |||
} | |||
@Override | |||
public Path path() { | |||
return indexedFile.path(); | |||
} | |||
@CheckForNull | |||
@Override | |||
public String language() { | |||
return indexedFile.language(); | |||
} | |||
@Override | |||
public Type type() { | |||
return indexedFile.type(); | |||
} | |||
/** | |||
* Component key (without branch). | |||
*/ | |||
@Override | |||
public String key() { | |||
return indexedFile.key(); | |||
} | |||
@Override | |||
public int hashCode() { | |||
return indexedFile.hashCode(); | |||
} | |||
@Override | |||
public String toString() { | |||
return indexedFile.toString(); | |||
} | |||
/** | |||
* {@link #setStatus(Status)} | |||
*/ | |||
@Override | |||
public Status status() { | |||
checkMetadata(); | |||
return status; | |||
} | |||
@Override | |||
public int lines() { | |||
checkMetadata(); | |||
return metadata.lines(); | |||
} | |||
@Override | |||
public boolean isEmpty() { | |||
checkMetadata(); | |||
return metadata.isEmpty(); | |||
} | |||
@Override | |||
public Charset charset() { | |||
checkMetadata(); | |||
return charset; | |||
} | |||
public int lastValidOffset() { | |||
checkMetadata(); | |||
return metadata.lastValidOffset(); | |||
} | |||
/** | |||
* Digest hash of the file. | |||
*/ | |||
public String hash() { | |||
checkMetadata(); | |||
return metadata.hash(); | |||
} | |||
public int nonBlankLines() { | |||
checkMetadata(); | |||
return metadata.nonBlankLines(); | |||
} | |||
public int[] originalLineStartOffsets() { | |||
checkMetadata(); | |||
checkState(metadata.originalLineStartOffsets() != null, "InputFile is not properly initialized."); | |||
checkState(metadata.originalLineStartOffsets().length == metadata.lines(), | |||
"InputFile is not properly initialized. 'originalLineStartOffsets' property length should be equal to 'lines'"); | |||
return metadata.originalLineStartOffsets(); | |||
} | |||
public int[] originalLineEndOffsets() { | |||
checkMetadata(); | |||
checkState(metadata.originalLineEndOffsets() != null, "InputFile is not properly initialized."); | |||
checkState(metadata.originalLineEndOffsets().length == metadata.lines(), | |||
"InputFile is not properly initialized. 'originalLineEndOffsets' property length should be equal to 'lines'"); | |||
return metadata.originalLineEndOffsets(); | |||
} | |||
@Override | |||
public TextPointer newPointer(int line, int lineOffset) { | |||
checkMetadata(); | |||
DefaultTextPointer textPointer = new DefaultTextPointer(line, lineOffset); | |||
checkValid(textPointer, "pointer"); | |||
return textPointer; | |||
} | |||
@Override | |||
public TextRange newRange(TextPointer start, TextPointer end) { | |||
checkMetadata(); | |||
checkValid(start, "start pointer"); | |||
checkValid(end, "end pointer"); | |||
return newRangeValidPointers(start, end, false); | |||
} | |||
@Override | |||
public TextRange newRange(int startLine, int startLineOffset, int endLine, int endLineOffset) { | |||
checkMetadata(); | |||
TextPointer start = newPointer(startLine, startLineOffset); | |||
TextPointer end = newPointer(endLine, endLineOffset); | |||
return newRangeValidPointers(start, end, false); | |||
} | |||
@Override | |||
public TextRange selectLine(int line) { | |||
checkMetadata(); | |||
TextPointer startPointer = newPointer(line, 0); | |||
TextPointer endPointer = newPointer(line, lineLength(line)); | |||
return newRangeValidPointers(startPointer, endPointer, true); | |||
} | |||
public void validate(TextRange range) { | |||
checkMetadata(); | |||
checkValid(range.start(), "start pointer"); | |||
checkValid(range.end(), "end pointer"); | |||
} | |||
/** | |||
* Create Range from global offsets. Used for backward compatibility with older API. | |||
*/ | |||
public TextRange newRange(int startOffset, int endOffset) { | |||
checkMetadata(); | |||
return newRangeValidPointers(newPointer(startOffset), newPointer(endOffset), false); | |||
} | |||
public TextPointer newPointer(int globalOffset) { | |||
checkMetadata(); | |||
checkArgument(globalOffset >= 0, "%s is not a valid offset for a file", globalOffset); | |||
checkArgument(globalOffset <= lastValidOffset(), "%s is not a valid offset for file %s. Max offset is %s", globalOffset, this, lastValidOffset()); | |||
int line = findLine(globalOffset); | |||
int startLineOffset = originalLineStartOffsets()[line - 1]; | |||
// In case the global offset is between \r and \n, move the pointer to a valid location | |||
return new DefaultTextPointer(line, Math.min(globalOffset, originalLineEndOffsets()[line - 1]) - startLineOffset); | |||
} | |||
public DefaultInputFile setStatus(Status status) { | |||
this.status = status; | |||
return this; | |||
} | |||
public DefaultInputFile setCharset(Charset charset) { | |||
this.charset = charset; | |||
return this; | |||
} | |||
private void checkValid(TextPointer pointer, String owner) { | |||
checkArgument(pointer.line() >= 1, "%s is not a valid line for a file", pointer.line()); | |||
checkArgument(pointer.line() <= this.metadata.lines(), "%s is not a valid line for %s. File %s has %s line(s)", pointer.line(), owner, this, metadata.lines()); | |||
checkArgument(pointer.lineOffset() >= 0, "%s is not a valid line offset for a file", pointer.lineOffset()); | |||
int lineLength = lineLength(pointer.line()); | |||
checkArgument(pointer.lineOffset() <= lineLength, | |||
"%s is not a valid line offset for %s. File %s has %s character(s) at line %s", pointer.lineOffset(), owner, this, lineLength, pointer.line()); | |||
} | |||
private int lineLength(int line) { | |||
return originalLineEndOffsets()[line - 1] - originalLineStartOffsets()[line - 1]; | |||
} | |||
private static TextRange newRangeValidPointers(TextPointer start, TextPointer end, boolean acceptEmptyRange) { | |||
checkArgument(acceptEmptyRange ? (start.compareTo(end) <= 0) : (start.compareTo(end) < 0), | |||
"Start pointer %s should be before end pointer %s", start, end); | |||
return new DefaultTextRange(start, end); | |||
} | |||
private int findLine(int globalOffset) { | |||
return Math.abs(Arrays.binarySearch(originalLineStartOffsets(), globalOffset) + 1); | |||
} | |||
public DefaultInputFile setMetadata(Metadata metadata) { | |||
this.metadata = metadata; | |||
return this; | |||
} | |||
@Override | |||
public boolean equals(Object obj) { | |||
if (obj == null) { | |||
return false; | |||
} | |||
if (this.getClass() != obj.getClass()) { | |||
return false; | |||
} | |||
DefaultInputFile that = (DefaultInputFile) obj; | |||
return this.getProjectRelativePath().equals(that.getProjectRelativePath()); | |||
} | |||
@Override | |||
public boolean isFile() { | |||
return true; | |||
} | |||
@Override | |||
public String filename() { | |||
return indexedFile.filename(); | |||
} | |||
@Override | |||
public URI uri() { | |||
return indexedFile.uri(); | |||
} | |||
public void noSonarAt(Set<Integer> noSonarLines) { | |||
if (this.noSonarLines == null) { | |||
this.noSonarLines = new BitSet(lines()); | |||
} | |||
noSonarLines.forEach(l -> this.noSonarLines.set(l - 1)); | |||
} | |||
public boolean hasNoSonarAt(int line) { | |||
if (this.noSonarLines == null) { | |||
return false; | |||
} | |||
return this.noSonarLines.get(line - 1); | |||
} | |||
public boolean isIgnoreAllIssues() { | |||
return ignoreAllIssues; | |||
} | |||
public void setIgnoreAllIssues(boolean ignoreAllIssues) { | |||
this.ignoreAllIssues = ignoreAllIssues; | |||
} | |||
public void addIgnoreIssuesOnLineRanges(Collection<int[]> lineRanges) { | |||
if (this.ignoreIssuesOnlineRanges == null) { | |||
this.ignoreIssuesOnlineRanges = new ArrayList<>(); | |||
} | |||
this.ignoreIssuesOnlineRanges.addAll(lineRanges); | |||
} | |||
public boolean isIgnoreAllIssuesOnLine(@Nullable Integer line) { | |||
if (line == null || ignoreIssuesOnlineRanges == null) { | |||
return false; | |||
} | |||
return ignoreIssuesOnlineRanges.stream().anyMatch(r -> r[0] <= line && line <= r[1]); | |||
} | |||
public void setExecutableLines(Set<Integer> executableLines) { | |||
checkState(this.executableLines == null, "Executable lines have already been saved for file: {}", this.toString()); | |||
this.executableLines = new BitSet(lines()); | |||
executableLines.forEach(l -> this.executableLines.set(l - 1)); | |||
} | |||
public Optional<Set<Integer>> getExecutableLines() { | |||
if (this.executableLines == null) { | |||
return Optional.empty(); | |||
} | |||
return Optional.of(this.executableLines.stream().map(i -> i + 1).boxed().collect(Collectors.toSet())); | |||
} | |||
} |
@@ -1,136 +0,0 @@ | |||
/* | |||
* SonarQube | |||
* Copyright (C) 2009-2019 SonarSource SA | |||
* mailto:info AT sonarsource DOT com | |||
* | |||
* 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, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.scanner.fs; | |||
import java.nio.file.Path; | |||
import javax.annotation.concurrent.ThreadSafe; | |||
import org.apache.commons.io.FilenameUtils; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.sonar.api.utils.PathUtils; | |||
import org.sonar.api.utils.WildcardPattern; | |||
import org.sonar.api.utils.log.Logger; | |||
import org.sonar.api.utils.log.Loggers; | |||
@ThreadSafe | |||
public abstract class PathPattern { | |||
private static final Logger LOG = Loggers.get(PathPattern.class); | |||
/** | |||
* @deprecated since 6.6 | |||
*/ | |||
@Deprecated | |||
private static final String ABSOLUTE_PATH_PATTERN_PREFIX = "file:"; | |||
final WildcardPattern pattern; | |||
PathPattern(String pattern) { | |||
this.pattern = WildcardPattern.create(pattern); | |||
} | |||
public abstract boolean match(Path absolutePath, Path relativePath); | |||
public abstract boolean match(Path absolutePath, Path relativePath, boolean caseSensitiveFileExtension); | |||
public static PathPattern create(String s) { | |||
String trimmed = StringUtils.trim(s); | |||
if (StringUtils.startsWithIgnoreCase(trimmed, ABSOLUTE_PATH_PATTERN_PREFIX)) { | |||
LOG.warn("Using absolute path pattern is deprecated. Please use relative path instead of '" + trimmed + "'"); | |||
return new AbsolutePathPattern(StringUtils.substring(trimmed, ABSOLUTE_PATH_PATTERN_PREFIX.length())); | |||
} | |||
return new RelativePathPattern(trimmed); | |||
} | |||
public static PathPattern[] create(String[] s) { | |||
PathPattern[] result = new PathPattern[s.length]; | |||
for (int i = 0; i < s.length; i++) { | |||
result[i] = create(s[i]); | |||
} | |||
return result; | |||
} | |||
/** | |||
* @deprecated since 6.6 | |||
*/ | |||
@Deprecated | |||
private static class AbsolutePathPattern extends PathPattern { | |||
private AbsolutePathPattern(String pattern) { | |||
super(pattern); | |||
} | |||
@Override | |||
public boolean match(Path absolutePath, Path relativePath) { | |||
return match(absolutePath, relativePath, true); | |||
} | |||
@Override | |||
public boolean match(Path absolutePath, Path relativePath, boolean caseSensitiveFileExtension) { | |||
String path = PathUtils.sanitize(absolutePath.toString()); | |||
if (!caseSensitiveFileExtension) { | |||
String extension = sanitizeExtension(FilenameUtils.getExtension(path)); | |||
if (StringUtils.isNotBlank(extension)) { | |||
path = StringUtils.removeEndIgnoreCase(path, extension); | |||
path = path + extension; | |||
} | |||
} | |||
return pattern.match(path); | |||
} | |||
@Override | |||
public String toString() { | |||
return ABSOLUTE_PATH_PATTERN_PREFIX + pattern.toString(); | |||
} | |||
} | |||
/** | |||
* Path relative to module basedir | |||
*/ | |||
private static class RelativePathPattern extends PathPattern { | |||
private RelativePathPattern(String pattern) { | |||
super(pattern); | |||
} | |||
@Override | |||
public boolean match(Path absolutePath, Path relativePath) { | |||
return match(absolutePath, relativePath, true); | |||
} | |||
@Override | |||
public boolean match(Path absolutePath, Path relativePath, boolean caseSensitiveFileExtension) { | |||
String path = PathUtils.sanitize(relativePath.toString()); | |||
if (!caseSensitiveFileExtension) { | |||
String extension = sanitizeExtension(FilenameUtils.getExtension(path)); | |||
if (StringUtils.isNotBlank(extension)) { | |||
path = StringUtils.removeEndIgnoreCase(path, extension); | |||
path = path + extension; | |||
} | |||
} | |||
return path != null && pattern.match(path); | |||
} | |||
@Override | |||
public String toString() { | |||
return pattern.toString(); | |||
} | |||
} | |||
static String sanitizeExtension(String suffix) { | |||
return StringUtils.lowerCase(StringUtils.removeStart(suffix, ".")); | |||
} | |||
} |
@@ -31,7 +31,14 @@ import javax.annotation.CheckForNull; | |||
import javax.annotation.Nullable; | |||
import org.sonar.api.batch.bootstrap.ProjectDefinition; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.AbstractProjectOrModule; | |||
import org.sonar.api.batch.fs.internal.DefaultIndexedFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputDir; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputModule; | |||
import org.sonar.api.batch.fs.internal.DefaultInputProject; | |||
import org.sonar.api.batch.fs.internal.Metadata; | |||
import org.sonar.api.batch.fs.internal.SensorStrategy; | |||
import org.sonar.api.utils.PathUtils; | |||
/** | |||
@@ -211,14 +218,14 @@ public class TestInputFileBuilder { | |||
return setMetadata(new FileMetadata().readMetadata(new StringReader(content))); | |||
} | |||
public DefaultInputFile build() { | |||
public org.sonar.api.batch.fs.internal.DefaultInputFile build() { | |||
Path absolutePath = moduleBaseDir.resolve(relativePath); | |||
if (projectBaseDir == null) { | |||
projectBaseDir = moduleBaseDir; | |||
} | |||
String projectRelativePath = projectBaseDir.relativize(absolutePath).toString(); | |||
DefaultIndexedFile indexedFile = new DefaultIndexedFile(absolutePath, projectKey, projectRelativePath, relativePath, type, language, id, new SensorStrategy()); | |||
DefaultInputFile inputFile = new DefaultInputFile(indexedFile, | |||
org.sonar.api.batch.fs.internal.DefaultIndexedFile indexedFile = new DefaultIndexedFile(absolutePath, projectKey, projectRelativePath, relativePath, type, language, id, new SensorStrategy()); | |||
org.sonar.api.batch.fs.internal.DefaultInputFile inputFile = new org.sonar.api.batch.fs.internal.DefaultInputFile(indexedFile, | |||
f -> f.setMetadata(new Metadata(lines, nonBlankLines, hash, originalLineStartOffsets, originalLineEndOffsets, lastValidOffset)), | |||
contents); | |||
inputFile.setStatus(status); | |||
@@ -227,7 +234,7 @@ public class TestInputFileBuilder { | |||
return inputFile; | |||
} | |||
public static DefaultInputModule newDefaultInputModule(String moduleKey, File baseDir) { | |||
public static org.sonar.api.batch.fs.internal.DefaultInputModule newDefaultInputModule(String moduleKey, File baseDir) { | |||
ProjectDefinition definition = ProjectDefinition.create() | |||
.setKey(moduleKey) | |||
.setBaseDir(baseDir) | |||
@@ -235,17 +242,17 @@ public class TestInputFileBuilder { | |||
return newDefaultInputModule(definition); | |||
} | |||
public static DefaultInputModule newDefaultInputModule(ProjectDefinition projectDefinition) { | |||
return new DefaultInputModule(projectDefinition, TestInputFileBuilder.nextBatchId()); | |||
public static org.sonar.api.batch.fs.internal.DefaultInputModule newDefaultInputModule(ProjectDefinition projectDefinition) { | |||
return new org.sonar.api.batch.fs.internal.DefaultInputModule(projectDefinition, TestInputFileBuilder.nextBatchId()); | |||
} | |||
public static DefaultInputModule newDefaultInputModule(AbstractProjectOrModule parent, String key) throws IOException { | |||
public static DefaultInputModule newDefaultInputModule(org.sonar.api.batch.fs.internal.AbstractProjectOrModule parent, String key) throws IOException { | |||
Path basedir = parent.getBaseDir().resolve(key); | |||
Files.createDirectory(basedir); | |||
return newDefaultInputModule(key, basedir.toFile()); | |||
} | |||
public static DefaultInputProject newDefaultInputProject(String projectKey, File baseDir) { | |||
public static org.sonar.api.batch.fs.internal.DefaultInputProject newDefaultInputProject(String projectKey, File baseDir) { | |||
ProjectDefinition definition = ProjectDefinition.create() | |||
.setKey(projectKey) | |||
.setBaseDir(baseDir) | |||
@@ -253,8 +260,8 @@ public class TestInputFileBuilder { | |||
return newDefaultInputProject(definition); | |||
} | |||
public static DefaultInputProject newDefaultInputProject(ProjectDefinition projectDefinition) { | |||
return new DefaultInputProject(projectDefinition, TestInputFileBuilder.nextBatchId()); | |||
public static org.sonar.api.batch.fs.internal.DefaultInputProject newDefaultInputProject(ProjectDefinition projectDefinition) { | |||
return new org.sonar.api.batch.fs.internal.DefaultInputProject(projectDefinition, TestInputFileBuilder.nextBatchId()); | |||
} | |||
public static DefaultInputProject newDefaultInputProject(String key, Path baseDir) throws IOException { | |||
@@ -262,7 +269,7 @@ public class TestInputFileBuilder { | |||
return newDefaultInputProject(key, baseDir.toFile()); | |||
} | |||
public static DefaultInputDir newDefaultInputDir(AbstractProjectOrModule module, String relativePath) throws IOException { | |||
public static org.sonar.api.batch.fs.internal.DefaultInputDir newDefaultInputDir(org.sonar.api.batch.fs.internal.AbstractProjectOrModule module, String relativePath) throws IOException { | |||
Path basedir = module.getBaseDir().resolve(relativePath); | |||
Files.createDirectory(basedir); | |||
return new DefaultInputDir(module.key(), relativePath) |
@@ -30,7 +30,7 @@ import org.sonar.api.batch.fs.FilePredicate; | |||
import org.sonar.api.batch.fs.FilePredicates; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.InputFile.Status; | |||
import org.sonar.scanner.fs.PathPattern; | |||
import org.sonar.api.batch.fs.internal.PathPattern; | |||
/** | |||
* Factory of {@link FilePredicate} |
@@ -21,7 +21,7 @@ package org.sonar.scanner.fs.predicates; | |||
import java.nio.file.Paths; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.scanner.fs.PathPattern; | |||
import org.sonar.api.batch.fs.internal.PathPattern; | |||
/** | |||
* @since 4.2 |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.postjob.internal; | |||
package org.sonar.scanner.postjob; | |||
import java.util.Arrays; | |||
import java.util.Collection; |
@@ -21,7 +21,6 @@ package org.sonar.scanner.postjob; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor; | |||
import org.sonar.api.config.Configuration; | |||
public class PostJobOptimizer { |
@@ -21,7 +21,6 @@ package org.sonar.scanner.postjob; | |||
import org.sonar.api.batch.postjob.PostJob; | |||
import org.sonar.api.batch.postjob.PostJobContext; | |||
import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor; | |||
public class PostJobWrapper { | |||
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.sensor.highlighting.internal; | |||
package org.sonar.scanner.sensor; | |||
import java.util.ArrayList; | |||
import java.util.Collections; |
@@ -41,7 +41,7 @@ import org.sonar.api.batch.sensor.code.internal.DefaultSignificantCode; | |||
import org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage; | |||
import org.sonar.api.batch.sensor.cpd.internal.DefaultCpdTokens; | |||
import org.sonar.api.batch.sensor.error.AnalysisError; | |||
import org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting; | |||
import org.sonar.api.batch.sensor.highlighting.NewHighlighting; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.sonar.api.batch.sensor.issue.ExternalIssue; | |||
import org.sonar.api.batch.sensor.issue.Issue; | |||
@@ -255,7 +255,8 @@ public class DefaultSensorStorage implements SensorStorage { | |||
} | |||
@Override | |||
public void store(DefaultHighlighting highlighting) { | |||
public void store(NewHighlighting newHighlighting) { | |||
DefaultHighlighting highlighting = (DefaultHighlighting) newHighlighting; | |||
ScannerReportWriter writer = reportPublisher.getWriter(); | |||
DefaultInputFile inputFile = (DefaultInputFile) highlighting.inputFile(); | |||
if (shouldSkipStorage(inputFile)) { |
@@ -29,7 +29,7 @@ import org.sonar.api.batch.sensor.code.internal.DefaultSignificantCode; | |||
import org.sonar.api.batch.sensor.coverage.internal.DefaultCoverage; | |||
import org.sonar.api.batch.sensor.cpd.internal.DefaultCpdTokens; | |||
import org.sonar.api.batch.sensor.error.AnalysisError; | |||
import org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting; | |||
import org.sonar.api.batch.sensor.highlighting.NewHighlighting; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.sonar.api.batch.sensor.issue.ExternalIssue; | |||
import org.sonar.api.batch.sensor.issue.Issue; | |||
@@ -48,7 +48,7 @@ class InMemorySensorStorage implements SensorStorage { | |||
Collection<AdHocRule> allAdHocRules = new ArrayList<>(); | |||
Collection<AnalysisError> allAnalysisErrors = new ArrayList<>(); | |||
Map<String, DefaultHighlighting> highlightingByComponent = new HashMap<>(); | |||
Map<String, NewHighlighting> highlightingByComponent = new HashMap<>(); | |||
Map<String, DefaultCpdTokens> cpdTokensByComponent = new HashMap<>(); | |||
Map<String, List<DefaultCoverage>> coverageByComponent = new HashMap<>(); | |||
Map<String, DefaultSymbolTable> symbolsPerComponent = new HashMap<>(); | |||
@@ -77,7 +77,8 @@ class InMemorySensorStorage implements SensorStorage { | |||
} | |||
@Override | |||
public void store(DefaultHighlighting highlighting) { | |||
public void store(NewHighlighting newHighlighting) { | |||
DefaultHighlighting highlighting = (DefaultHighlighting) newHighlighting; | |||
String fileKey = highlighting.inputFile().key(); | |||
// Emulate duplicate storage check | |||
if (highlightingByComponent.containsKey(fileKey)) { |
@@ -37,7 +37,6 @@ import org.sonar.api.batch.sensor.cpd.NewCpdTokens; | |||
import org.sonar.api.batch.sensor.cpd.internal.DefaultCpdTokens; | |||
import org.sonar.api.batch.sensor.error.NewAnalysisError; | |||
import org.sonar.api.batch.sensor.highlighting.NewHighlighting; | |||
import org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.sonar.api.batch.sensor.issue.NewExternalIssue; | |||
import org.sonar.api.batch.sensor.issue.NewIssue; | |||
@@ -65,7 +64,7 @@ public class ProjectSensorContext implements SensorContext { | |||
private final Configuration config; | |||
public ProjectSensorContext(DefaultInputProject project, Configuration config, Settings mutableSettings, FileSystem fs, ActiveRules activeRules, | |||
SensorStorage sensorStorage, SonarRuntime sonarRuntime) { | |||
SensorStorage sensorStorage, SonarRuntime sonarRuntime) { | |||
this.project = project; | |||
this.config = config; | |||
this.mutableSettings = mutableSettings; |
@@ -44,7 +44,6 @@ import org.sonar.api.batch.fs.internal.DefaultInputModule; | |||
import org.sonar.api.batch.fs.internal.DefaultInputProject; | |||
import org.sonar.api.batch.fs.internal.DefaultTextPointer; | |||
import org.sonar.api.batch.rule.ActiveRules; | |||
import org.sonar.scanner.rule.ActiveRulesBuilder; | |||
import org.sonar.api.batch.sensor.Sensor; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.batch.sensor.code.NewSignificantCode; | |||
@@ -59,8 +58,6 @@ import org.sonar.api.batch.sensor.error.NewAnalysisError; | |||
import org.sonar.api.batch.sensor.error.internal.DefaultAnalysisError; | |||
import org.sonar.api.batch.sensor.highlighting.NewHighlighting; | |||
import org.sonar.api.batch.sensor.highlighting.TypeOfText; | |||
import org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting; | |||
import org.sonar.api.batch.sensor.highlighting.internal.SyntaxHighlightingRule; | |||
import org.sonar.api.batch.sensor.issue.ExternalIssue; | |||
import org.sonar.api.batch.sensor.issue.Issue; | |||
import org.sonar.api.batch.sensor.issue.NewExternalIssue; | |||
@@ -82,6 +79,7 @@ import org.sonar.api.scanner.fs.InputProject; | |||
import org.sonar.api.utils.System2; | |||
import org.sonar.api.utils.Version; | |||
import org.sonar.scanner.fs.DefaultFileSystem; | |||
import org.sonar.scanner.rule.ActiveRulesBuilder; | |||
import static java.util.Collections.unmodifiableMap; | |||
@@ -342,7 +340,7 @@ public class SensorContextTester implements SensorContext { | |||
* @return List of styles applied to this position or empty list if there is no highlighting at this position. | |||
*/ | |||
public List<TypeOfText> highlightingTypeAt(String componentKey, int line, int lineOffset) { | |||
DefaultHighlighting syntaxHighlightingData = sensorStorage.highlightingByComponent.get(componentKey); | |||
DefaultHighlighting syntaxHighlightingData = (DefaultHighlighting) sensorStorage.highlightingByComponent.get(componentKey); | |||
if (syntaxHighlightingData == null) { | |||
return Collections.emptyList(); | |||
} |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.sensor.highlighting.internal; | |||
package org.sonar.scanner.sensor; | |||
import org.apache.commons.lang.builder.ReflectionToStringBuilder; | |||
import org.apache.commons.lang.builder.ToStringStyle; |
@@ -26,7 +26,7 @@ import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.mockito.ArgumentCaptor; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.api.batch.measure.MetricFinder; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.sonar.scanner.sensor.DefaultMeasure; |
@@ -33,8 +33,8 @@ import org.sonar.api.batch.ScannerSide; | |||
import org.sonar.api.batch.sensor.Sensor; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.batch.sensor.SensorDescriptor; | |||
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; | |||
import org.sonar.core.platform.ComponentContainer; | |||
import org.sonar.scanner.sensor.DefaultSensorDescriptor; | |||
import org.sonar.scanner.sensor.ModuleSensorContext; | |||
import org.sonar.scanner.sensor.ModuleSensorExtensionDictionnary; | |||
import org.sonar.scanner.sensor.ModuleSensorOptimizer; |
@@ -25,7 +25,7 @@ import org.sonar.api.batch.Phase; | |||
import org.sonar.api.batch.postjob.PostJob; | |||
import org.sonar.api.batch.postjob.PostJobContext; | |||
import org.sonar.api.batch.postjob.PostJobDescriptor; | |||
import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor; | |||
import org.sonar.scanner.postjob.DefaultPostJobDescriptor; | |||
import org.sonar.api.batch.sensor.Sensor; | |||
import org.sonar.api.batch.sensor.SensorContext; | |||
import org.sonar.api.batch.sensor.SensorDescriptor; |
@@ -38,7 +38,7 @@ import org.junit.rules.TemporaryFolder; | |||
import org.mockito.ArgumentMatchers; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputProject; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.api.utils.log.LogTester; | |||
import org.sonar.api.utils.log.LoggerLevel; | |||
import org.sonar.core.util.CloseableIterator; |
@@ -33,10 +33,10 @@ import org.mockito.Captor; | |||
import org.mockito.Mock; | |||
import org.mockito.MockitoAnnotations; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.duplications.block.Block; | |||
import org.sonar.scanner.cpd.index.SonarCpdBlockIndex; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.ArgumentMatchers.eq; |
@@ -28,12 +28,12 @@ import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.TextRange; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.api.batch.rule.Severity; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.api.batch.sensor.issue.ExternalIssue; | |||
import org.sonar.api.utils.log.LogTester; | |||
import org.sonar.api.utils.log.LoggerLevel; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import static java.nio.charset.StandardCharsets.UTF_8; | |||
import static org.apache.commons.lang.ObjectUtils.defaultIfNull; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.fs.internal; | |||
package org.sonar.scanner.fs; | |||
import java.io.File; | |||
import java.nio.charset.Charset; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.fs.internal; | |||
package org.sonar.scanner.fs; | |||
import java.io.File; | |||
import java.io.FileInputStream; | |||
@@ -31,7 +31,8 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.internal.FileMetadata.LineHashConsumer; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.Metadata; | |||
import org.sonar.api.utils.log.LogTester; | |||
import org.sonar.api.utils.log.LoggerLevel; | |||
@@ -222,11 +223,11 @@ public class FileMetadataTest { | |||
File tempFile = temp.newFile(); | |||
FileUtils.write(tempFile, " foo\nb ar\r\nbaz \t", StandardCharsets.UTF_8, true); | |||
DefaultInputFile f = new TestInputFileBuilder("foo", tempFile.getName()) | |||
org.sonar.api.batch.fs.internal.DefaultInputFile f = new TestInputFileBuilder("foo", tempFile.getName()) | |||
.setModuleBaseDir(tempFile.getParentFile().toPath()) | |||
.setCharset(StandardCharsets.UTF_8) | |||
.build(); | |||
FileMetadata.computeLineHashesForIssueTracking(f, new LineHashConsumer() { | |||
FileMetadata.computeLineHashesForIssueTracking(f, new FileMetadata.LineHashConsumer() { | |||
@Override | |||
public void consume(int lineIdx, @Nullable byte[] hash) { | |||
@@ -256,7 +257,7 @@ public class FileMetadataTest { | |||
.setModuleBaseDir(tempFile.getParentFile().toPath()) | |||
.setCharset(StandardCharsets.UTF_8) | |||
.build(); | |||
FileMetadata.computeLineHashesForIssueTracking(f, new LineHashConsumer() { | |||
FileMetadata.computeLineHashesForIssueTracking(f, new FileMetadata.LineHashConsumer() { | |||
@Override | |||
public void consume(int lineIdx, @Nullable byte[] hash) { |
@@ -17,10 +17,9 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.fs.internal.charhandler; | |||
package org.sonar.scanner.fs.charhandler; | |||
import org.junit.Test; | |||
import org.sonar.api.batch.fs.internal.charhandler.IntArrayList; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -17,12 +17,13 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.fs.internal; | |||
package org.sonar.scanner.fs.predicates; | |||
import org.junit.Test; | |||
import org.sonar.api.batch.fs.FilePredicate; | |||
import java.util.Arrays; | |||
import org.sonar.api.batch.fs.internal.PathPattern; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.fs.internal; | |||
package org.sonar.scanner.fs.predicates; | |||
import java.io.File; | |||
import java.io.IOException; | |||
@@ -33,6 +33,7 @@ import org.sonar.api.batch.fs.FilePredicate; | |||
import org.sonar.api.batch.fs.FilePredicates; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.InputFile.Status; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.fs.internal; | |||
package org.sonar.scanner.fs.predicates; | |||
import java.io.IOException; | |||
import org.junit.Test; | |||
@@ -26,7 +26,7 @@ import org.sonar.api.batch.fs.InputFile; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; | |||
import static org.mockito.Mockito.when; | |||
import static org.sonar.api.batch.fs.internal.FileExtensionPredicate.getExtension; | |||
import static org.sonar.scanner.fs.predicates.FileExtensionPredicate.getExtension; | |||
public class FileExtensionPredicateTest { | |||
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.fs.internal; | |||
package org.sonar.scanner.fs.predicates; | |||
import java.io.IOException; | |||
import java.util.Collections; |
@@ -17,12 +17,13 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.fs.internal; | |||
package org.sonar.scanner.fs.predicates; | |||
import org.junit.Test; | |||
import org.sonar.api.batch.fs.FilePredicate; | |||
import java.util.Arrays; | |||
import org.sonar.api.batch.fs.internal.PathPattern; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.fs.internal; | |||
package org.sonar.scanner.fs.predicates; | |||
import org.junit.Test; | |||
import org.sonar.api.batch.fs.InputFile; |
@@ -28,9 +28,9 @@ import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.api.utils.MessageException; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -28,12 +28,12 @@ import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.api.test.MutableTestCase; | |||
import org.sonar.api.test.MutableTestPlan; | |||
import org.sonar.api.utils.MessageException; | |||
import org.sonar.scanner.deprecated.test.TestPlanBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.ArgumentMatchers.any; |
@@ -28,7 +28,6 @@ import org.apache.commons.io.FileUtils; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.sensor.internal.SensorContextTester; | |||
import org.sonar.api.config.Encryption; | |||
import org.sonar.api.config.PropertyDefinitions; | |||
import org.sonar.api.utils.log.LogTester; | |||
@@ -36,6 +35,7 @@ import org.sonar.api.utils.log.LoggerLevel; | |||
import org.sonar.scanner.config.DefaultConfiguration; | |||
import org.sonar.scanner.deprecated.test.TestPlanBuilder; | |||
import org.sonar.scanner.scan.ProjectConfiguration; | |||
import org.sonar.scanner.sensor.SensorContextTester; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; |
@@ -34,7 +34,7 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition; | |||
import org.sonar.api.batch.fs.InputComponent; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputProject; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.rule.ActiveRulesBuilder; | |||
import org.sonar.scanner.rule.NewActiveRule; | |||
import org.sonar.scanner.rule.RulesBuilder; |
@@ -26,7 +26,7 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.InputComponent; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.api.notifications.AnalysisWarnings; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.scan.issue.filter.IssueFilterChain; |
@@ -28,7 +28,7 @@ import org.junit.rules.ExpectedException; | |||
import org.mockito.Mock; | |||
import org.mockito.MockitoAnnotations; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.api.notifications.AnalysisWarnings; | |||
import org.sonar.scanner.issue.ignore.IgnoreIssuesFilter; | |||
import org.sonar.scanner.issue.ignore.pattern.IssueExclusionPatternInitializer; |
@@ -35,8 +35,8 @@ import org.junit.Test; | |||
import org.mockito.Mock; | |||
import org.mockito.MockitoAnnotations; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.FileMetadata; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.FileMetadata; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.issue.ignore.pattern.IssueExclusionPatternInitializer; | |||
import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader.DoubleRegexpMatcher; | |||
@@ -31,7 +31,7 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.FileMetadata; | |||
import org.sonar.scanner.fs.FileMetadata; | |||
import org.sonar.scanner.mediumtest.AnalysisResult; | |||
import org.sonar.scanner.mediumtest.ScannerMediumTester; | |||
import org.sonar.scanner.protocol.output.ScannerReport; |
@@ -26,7 +26,7 @@ import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.scan.ModuleConfiguration; | |||
import org.sonar.scanner.scan.filesystem.ModuleCoverageAndDuplicationExclusions; | |||
@@ -29,7 +29,7 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition; | |||
import org.sonar.api.batch.fs.internal.DefaultInputModule; | |||
import org.sonar.api.batch.fs.internal.InputModuleHierarchy; | |||
import org.sonar.api.batch.fs.internal.SensorStrategy; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.Sensor; | |||
import org.sonar.scanner.sensor.ModuleSensorExtensionDictionnary; | |||
import org.sonar.scanner.bootstrap.ScannerPluginRepository; |
@@ -26,7 +26,7 @@ import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.CoreProperties; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.scan.ProjectConfiguration; | |||
import org.sonar.scanner.scan.filesystem.ProjectCoverageAndDuplicationExclusions; | |||
@@ -23,8 +23,6 @@ import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.sonar.api.batch.postjob.internal.DefaultPostJobDescriptor; | |||
import org.sonar.api.config.Settings; | |||
import org.sonar.api.config.internal.MapSettings; | |||
import static org.assertj.core.api.Assertions.assertThat; |
@@ -33,7 +33,7 @@ import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputProject; | |||
import org.sonar.api.batch.fs.internal.InputModuleHierarchy; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.api.batch.scm.ScmProvider; | |||
import org.sonar.scanner.protocol.output.ScannerReportReader; | |||
import org.sonar.scanner.protocol.output.ScannerReportWriter; |
@@ -33,7 +33,7 @@ import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.InputFile.Type; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputProject; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.api.utils.DateUtils; | |||
import org.sonar.scanner.ProjectInfo; | |||
import org.sonar.scanner.protocol.output.FileStructure; |
@@ -41,7 +41,7 @@ import org.sonar.api.CoreProperties; | |||
import org.sonar.api.batch.bootstrap.ProjectDefinition; | |||
import org.sonar.api.batch.fs.internal.DefaultInputModule; | |||
import org.sonar.api.batch.fs.internal.InputModuleHierarchy; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.api.batch.scm.ScmProvider; | |||
import org.sonar.scanner.ProjectInfo; | |||
import org.sonar.scanner.bootstrap.ScannerPlugin; |
@@ -29,7 +29,7 @@ import org.junit.Test; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputProject; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.protocol.output.ScannerReportWriter; | |||
import org.sonar.scanner.scan.branch.BranchConfiguration; | |||
import org.sonar.scanner.scan.filesystem.InputComponentStore; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.rule.internal; | |||
package org.sonar.scanner.rule; | |||
import org.junit.Rule; | |||
import org.junit.Test; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.rule.internal; | |||
package org.sonar.scanner.rule; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.junit.Test; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.rule.internal; | |||
package org.sonar.scanner.rule; | |||
import com.google.common.collect.ImmutableMap; | |||
import org.junit.Before; |
@@ -24,9 +24,7 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.slf4j.Logger; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.config.internal.MapSettings; | |||
import org.sonar.api.utils.MessageException; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.scan.branch.BranchConfiguration; | |||
import org.sonar.scanner.scan.filesystem.InputComponentStore; | |||
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.rule.internal; | |||
package org.sonar.scanner.rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; |
@@ -22,7 +22,7 @@ package org.sonar.scanner.scan.filesystem; | |||
import org.junit.Test; | |||
import org.sonar.api.batch.fs.FilePredicate; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
@@ -35,7 +35,7 @@ import org.sonar.api.batch.fs.InputPath; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputModule; | |||
import org.sonar.api.batch.fs.internal.DefaultInputProject; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.scan.branch.BranchConfiguration; | |||
import static org.assertj.core.api.Assertions.assertThat; |
@@ -33,10 +33,10 @@ import org.mockito.Mock; | |||
import org.mockito.MockitoAnnotations; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.FileMetadata; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.notifications.AnalysisWarnings; | |||
import org.sonar.api.utils.PathUtils; | |||
import org.sonar.scanner.fs.FileMetadata; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.issue.ignore.IgnoreIssuesFilter; | |||
import org.sonar.scanner.issue.ignore.pattern.IssueExclusionPatternInitializer; | |||
import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader; | |||
@@ -59,7 +59,7 @@ public class MetadataGeneratorTest { | |||
private MetadataGenerator generator; | |||
@Before | |||
public void setUp() throws IOException { | |||
public void setUp() { | |||
MockitoAnnotations.initMocks(this); | |||
metadata = new FileMetadata(); | |||
IssueExclusionsLoader issueExclusionsLoader = new IssueExclusionsLoader(mock(IssueExclusionPatternInitializer.class), mock(IgnoreIssuesFilter.class), |
@@ -28,7 +28,7 @@ import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.InputModule; | |||
import org.sonar.api.batch.fs.internal.DefaultInputProject; | |||
import org.sonar.api.batch.fs.internal.SensorStrategy; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.scan.branch.BranchConfiguration; | |||
import static org.assertj.core.api.Assertions.assertThat; |
@@ -27,7 +27,7 @@ import org.junit.Before; | |||
import org.junit.Test; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.repository.FileData; | |||
import org.sonar.scanner.repository.ProjectRepositoriesSupplier; | |||
import org.sonar.scanner.repository.SingleProjectRepository; |
@@ -25,7 +25,7 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.api.batch.scm.BlameLine; | |||
public class DefaultBlameOutputTest { |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.sensor.rule.internal; | |||
package org.sonar.scanner.sensor; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
@@ -153,4 +153,4 @@ public class DefaultAdHocRuleTest { | |||
rule.save(); | |||
} | |||
} | |||
} |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.sensor.issue.internal; | |||
package org.sonar.scanner.sensor; | |||
import java.io.IOException; | |||
import org.junit.Before; | |||
@@ -29,11 +29,11 @@ import org.sonar.api.batch.bootstrap.ProjectDefinition; | |||
import org.sonar.api.batch.fs.InputComponent; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputProject; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.rule.Severity; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.api.rules.RuleType; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.sensor.highlighting.internal; | |||
package org.sonar.scanner.sensor; | |||
import java.util.Collection; | |||
import org.junit.Before; | |||
@@ -28,8 +28,8 @@ import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.TextRange; | |||
import org.sonar.api.batch.fs.internal.DefaultTextPointer; | |||
import org.sonar.api.batch.fs.internal.DefaultTextRange; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.sensor.issue.internal; | |||
package org.sonar.scanner.sensor; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.hamcrest.Description; | |||
@@ -27,7 +27,7 @@ import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.junit.rules.ExpectedException.none; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.sensor.issue.internal; | |||
package org.sonar.scanner.sensor; | |||
import java.io.File; | |||
import java.io.IOException; | |||
@@ -30,10 +30,10 @@ import org.sonar.api.batch.fs.internal.DefaultInputDir; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputModule; | |||
import org.sonar.api.batch.fs.internal.DefaultInputProject; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.rule.Severity; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.sensor.measure.internal; | |||
package org.sonar.scanner.sensor; | |||
import java.io.IOException; | |||
import org.junit.Rule; | |||
@@ -27,9 +27,9 @@ import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.bootstrap.ProjectDefinition; | |||
import org.sonar.api.batch.fs.internal.AbstractProjectOrModule; | |||
import org.sonar.api.batch.fs.internal.DefaultInputProject; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.sonar.api.measures.CoreMetrics; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.sensor.internal; | |||
package org.sonar.scanner.sensor; | |||
import org.junit.Test; | |||
import org.sonar.api.batch.fs.InputFile; |
@@ -33,11 +33,9 @@ import org.sonar.api.batch.fs.internal.DefaultInputDir; | |||
import org.sonar.api.batch.fs.internal.DefaultInputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultInputModule; | |||
import org.sonar.api.batch.fs.internal.DefaultInputProject; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.measure.MetricFinder; | |||
import org.sonar.api.batch.sensor.code.internal.DefaultSignificantCode; | |||
import org.sonar.api.batch.sensor.highlighting.TypeOfText; | |||
import org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting; | |||
import org.sonar.api.batch.sensor.issue.ExternalIssue; | |||
import org.sonar.api.batch.sensor.issue.Issue; | |||
import org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable; | |||
@@ -45,6 +43,7 @@ import org.sonar.api.config.internal.MapSettings; | |||
import org.sonar.api.measures.CoreMetrics; | |||
import org.sonar.core.metric.ScannerMetrics; | |||
import org.sonar.scanner.cpd.index.SonarCpdBlockIndex; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.issue.IssuePublisher; | |||
import org.sonar.scanner.protocol.output.FileStructure; | |||
import org.sonar.scanner.protocol.output.ScannerReport; |
@@ -17,7 +17,7 @@ | |||
* along with this program; if not, write to the Free Software Foundation, | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
package org.sonar.api.batch.sensor.internal; | |||
package org.sonar.scanner.sensor; | |||
import org.junit.Rule; | |||
import org.junit.Test; |
@@ -19,25 +19,25 @@ | |||
*/ | |||
package org.sonar.scanner.sensor; | |||
import org.sonar.api.SonarEdition; | |||
import org.junit.Before; | |||
import org.junit.Rule; | |||
import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.SonarEdition; | |||
import org.sonar.api.SonarQubeSide; | |||
import org.sonar.api.SonarRuntime; | |||
import org.sonar.api.batch.fs.InputModule; | |||
import org.sonar.api.batch.fs.internal.DefaultFileSystem; | |||
import org.sonar.api.batch.fs.internal.DefaultInputProject; | |||
import org.sonar.api.batch.measure.MetricFinder; | |||
import org.sonar.api.batch.rule.ActiveRules; | |||
import org.sonar.scanner.rule.ActiveRulesBuilder; | |||
import org.sonar.api.batch.sensor.internal.SensorStorage; | |||
import org.sonar.api.config.internal.MapSettings; | |||
import org.sonar.api.internal.SonarRuntimeImpl; | |||
import org.sonar.api.measures.CoreMetrics; | |||
import org.sonar.api.utils.Version; | |||
import org.sonar.scanner.fs.DefaultFileSystem; | |||
import org.sonar.scanner.rule.ActiveRulesBuilder; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||
import static org.mockito.Mockito.mock; |
@@ -25,14 +25,13 @@ import org.junit.Test; | |||
import org.junit.rules.ExpectedException; | |||
import org.junit.rules.TemporaryFolder; | |||
import org.sonar.api.batch.fs.InputFile; | |||
import org.sonar.api.batch.fs.internal.DefaultFileSystem; | |||
import org.sonar.api.batch.fs.internal.TestInputFileBuilder; | |||
import org.sonar.api.batch.rule.ActiveRules; | |||
import org.sonar.scanner.rule.ActiveRulesBuilder; | |||
import org.sonar.scanner.rule.NewActiveRule; | |||
import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; | |||
import org.sonar.api.config.internal.MapSettings; | |||
import org.sonar.api.rule.RuleKey; | |||
import org.sonar.scanner.fs.DefaultFileSystem; | |||
import org.sonar.scanner.fs.TestInputFileBuilder; | |||
import org.sonar.scanner.rule.ActiveRulesBuilder; | |||
import org.sonar.scanner.rule.NewActiveRule; | |||
import static org.assertj.core.api.Assertions.assertThat; | |||