aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2018-04-30 22:53:02 +0200
committerSonarTech <sonartech@sonarsource.com>2018-05-11 20:20:46 +0200
commit045a34deadfa9e0aed6d1dc3cc0059f3e0b390ad (patch)
tree102fdf6e243de349571b9af3ab99fb0ed2644667 /sonar-scanner-engine
parent75c553337901c4e09aa53f07f1659d8608ad5181 (diff)
downloadsonarqube-045a34deadfa9e0aed6d1dc3cc0059f3e0b390ad.tar.gz
sonarqube-045a34deadfa9e0aed6d1dc3cc0059f3e0b390ad.zip
SONAR-10591 Remove unused code in sonar-home
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/FileCacheProvider.java5
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginJarExploderTest.java8
2 files changed, 8 insertions, 5 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/FileCacheProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/FileCacheProvider.java
index b2946c96071..7deea6e36d6 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/FileCacheProvider.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/FileCacheProvider.java
@@ -19,6 +19,7 @@
*/
package org.sonar.scanner.bootstrap;
+import java.io.File;
import org.picocontainer.injectors.ProviderAdapter;
import org.sonar.api.config.Configuration;
import org.sonar.home.cache.FileCache;
@@ -29,7 +30,9 @@ public class FileCacheProvider extends ProviderAdapter {
public FileCache provide(Configuration settings) {
if (cache == null) {
- String home = settings.get("sonar.userHome").orElse(null);
+ File home = settings.get("sonar.userHome")
+ .map(File::new)
+ .orElse(null);
cache = new FileCacheBuilder(new Slf4jLogger()).setUserHome(home).build();
}
return cache;
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginJarExploderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginJarExploderTest.java
index 00e7bdfc398..c8a92c3a3ca 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginJarExploderTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginJarExploderTest.java
@@ -38,8 +38,8 @@ public class ScannerPluginJarExploderTest {
@ClassRule
public static TemporaryFolder temp = new TemporaryFolder();
- File userHome;
- ScannerPluginJarExploder underTest;
+ private File userHome;
+ private ScannerPluginJarExploder underTest;
@Before
public void setUp() throws IOException {
@@ -55,7 +55,7 @@ public class ScannerPluginJarExploderTest {
assertThat(exploded.getKey()).isEqualTo("checkstyle");
assertThat(exploded.getMain()).isFile().exists();
- assertThat(exploded.getLibs()).extracting("name").containsOnly("antlr-2.7.6.jar", "checkstyle-5.1.jar", "commons-cli-1.0.jar");
+ assertThat(exploded.getLibs()).extracting(File::getName).containsExactlyInAnyOrder("antlr-2.7.6.jar", "checkstyle-5.1.jar", "commons-cli-1.0.jar");
assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar")).exists();
assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar_unzip/META-INF/lib/checkstyle-5.1.jar")).exists();
}
@@ -70,7 +70,7 @@ public class ScannerPluginJarExploderTest {
assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar_unzip/org/sonar/plugins/checkstyle/CheckstyleVersion.class")).doesNotExist();
}
- File getFileFromCache(String filename) throws IOException {
+ private File getFileFromCache(String filename) throws IOException {
File src = FileUtils.toFile(getClass().getResource(this.getClass().getSimpleName() + "/" + filename));
File destFile = new File(new File(userHome, "" + filename.hashCode()), filename);
FileUtils.copyFile(src, destFile);