diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2018-09-17 16:59:39 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-09-24 20:20:57 +0200 |
commit | 1241f18a7b389336ce1eb98fe024f8db0bc5c627 (patch) | |
tree | c0f533c2afbff0b6271d0ee0575eda4e4834153a /sonar-scanner-engine/src/main/java/org | |
parent | 3e5ce7c6fc3ccffc09ff6cb630b641c3ce101432 (diff) | |
download | sonarqube-1241f18a7b389336ce1eb98fe024f8db0bc5c627.tar.gz sonarqube-1241f18a7b389336ce1eb98fe024f8db0bc5c627.zip |
SONAR-11259 Improve source offset handling on Windows
* Trying to create a range in the middle of a \r\n sequence will now
automatically be adapted to exclude the eol
* Fix a few other tests on Windows
Diffstat (limited to 'sonar-scanner-engine/src/main/java/org')
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java | 5 | ||||
-rw-r--r-- | sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputFileBuilder.java | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java index 2ad95729c13..5cf6649d310 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ComponentsPublisher.java @@ -36,6 +36,7 @@ import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.batch.fs.internal.DefaultInputModule; import org.sonar.api.batch.fs.internal.InputComponentTree; import org.sonar.api.batch.fs.internal.InputModuleHierarchy; +import org.sonar.api.utils.PathUtils; import org.sonar.core.util.CloseableIterator; import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.scanner.protocol.output.ScannerReport.Component.ComponentType; @@ -206,11 +207,11 @@ public class ComponentsPublisher implements ReportPublisherStep { Path projectBaseDir = moduleHierarchy.root().getBaseDir(); if (component instanceof InputDir) { InputDir inputDir = (InputDir) component; - return projectBaseDir.relativize(inputDir.path()).toString(); + return PathUtils.sanitize(projectBaseDir.relativize(inputDir.path()).toString()); } if (component instanceof InputModule) { DefaultInputModule module = (DefaultInputModule) component; - return projectBaseDir.relativize(module.getBaseDir()).toString(); + return PathUtils.sanitize(projectBaseDir.relativize(module.getBaseDir()).toString()); } throw new IllegalStateException("Unknown component: " + component.getClass()); } diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputFileBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputFileBuilder.java index b6bf1899b6f..d17e9dc4e52 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputFileBuilder.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/filesystem/InputFileBuilder.java @@ -55,8 +55,8 @@ public class InputFileBuilder { DefaultInputFile create(InputFile.Type type, Path absolutePath, @Nullable String language) { DefaultIndexedFile indexedFile = new DefaultIndexedFile(absolutePath, moduleKey, - PathUtils.sanitize(projectBaseDir.relativize(absolutePath).toString()), - PathUtils.sanitize(moduleBaseDir.relativize(absolutePath).toString()), + projectBaseDir.relativize(absolutePath).toString(), + moduleBaseDir.relativize(absolutePath).toString(), type, language, idGenerator.getAsInt(), sensorStrategy); DefaultInputFile inputFile = new DefaultInputFile(indexedFile, f -> metadataGenerator.setMetadata(f, moduleFileSystemInitializer.defaultEncoding())); if (language != null) { |