]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9734 fix Quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 18 Aug 2017 20:10:07 +0000 (22:10 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 21 Aug 2017 19:39:21 +0000 (21:39 +0200)
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/batch/BatchReportReader.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/batch/BatchReportReaderImpl.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/source/SourceLinesRepository.java
server/sonar-server/src/main/java/org/sonar/server/computation/task/projectanalysis/source/SourceLinesRepositoryImpl.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/batch/BatchReportReaderImplTest.java
server/sonar-server/src/test/java/org/sonar/server/computation/task/projectanalysis/batch/BatchReportReaderRule.java

index 1305f9d14a2ff65c12727b78c93ed08bc11aae67..a4d52ff7535a0bbd07a4f806453ccf93367986f1 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.server.computation.task.projectanalysis.batch;
 
-import com.google.common.base.Optional;
+import java.util.Optional;
 import javax.annotation.CheckForNull;
 import org.sonar.core.util.CloseableIterator;
 import org.sonar.scanner.protocol.output.ScannerReport;
index 51f10103566f7c2a883433c1378e22467ed17b5e..c98d75a7fda4663be206ed8d1b71042f15c30114 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.computation.task.projectanalysis.batch;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Throwables;
 import com.google.protobuf.InvalidProtocolBufferException;
 import com.google.protobuf.Parser;
@@ -29,6 +28,7 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
 import java.util.NoSuchElementException;
+import java.util.Optional;
 import javax.annotation.CheckForNull;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
@@ -144,7 +144,7 @@ public class BatchReportReaderImpl implements BatchReportReader {
     ensureInitialized();
     File file = delegate.readFileSource(fileRef);
     if (file == null) {
-      return Optional.absent();
+      return Optional.empty();
     }
 
     try {
index 7f19f857058fa9d8a6301bd59662a1b5d6ebbba3..50260afa797c287a3c6aaaf7f3751af0c590d6da 100644 (file)
@@ -29,7 +29,7 @@ public interface SourceLinesRepository {
    * <p>
    * The returned {@link CloseableIterator} will wrap the {@link CloseableIterator} returned by
    * {@link org.sonar.server.computation.task.projectanalysis.batch.BatchReportReader#readFileSource(int)} but enforces that the number
-   * of lines specified by {@link org.sonar.batch.protocol.output.ScannerReport.Component#getLines()} is respected, adding
+   * of lines specified by {@link org.sonar.scanner.protocol.output.ScannerReport.Component#getLines()} is respected, adding
    * an extra empty last line if required.
    * </p>
    *
index cba254cb716a2af86a0f8cb29063d4e44e7a8b6d..9753c2d81b5442cea9ff9f9e30b87b37a5375892 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.server.computation.task.projectanalysis.source;
 
-import com.google.common.base.Optional;
+import java.util.Optional;
 import org.sonar.core.util.CloseableIterator;
 import org.sonar.server.computation.task.projectanalysis.batch.BatchReportReader;
 import org.sonar.server.computation.task.projectanalysis.component.Component;
index 5366c016a36af5f0584e5c9f15ad14e9e6789530..f05dbebfea2ecbfece30427b191a570f1e7ab39f 100644 (file)
@@ -32,7 +32,6 @@ import org.sonar.scanner.protocol.output.ScannerReportWriter;
 
 import static com.google.common.collect.ImmutableList.of;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.guava.api.Assertions.assertThat;
 
 public class BatchReportReaderImplTest {
   private static final int COMPONENT_REF = 1;
@@ -275,7 +274,7 @@ public class BatchReportReaderImplTest {
 
   @Test
   public void readFileSource_returns_absent_optional_when_file_does_not_exist() {
-    assertThat(underTest.readFileSource(COMPONENT_REF)).isAbsent();
+    assertThat(underTest.readFileSource(COMPONENT_REF)).isEmpty();
   }
 
   @Test
index 4018c9259c32d33447c17c85ca36fe3de2ea254c..40c995edc1f7edef96d04fc5048f5f62f0087a47 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.computation.task.projectanalysis.batch;
 
-import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -27,6 +26,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.junit.rules.TestRule;
@@ -246,7 +246,7 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader {
   public Optional<CloseableIterator<String>> readFileSource(int fileRef) {
     List<String> lines = fileSources.get(fileRef);
     if (lines == null) {
-      return Optional.absent();
+      return Optional.empty();
     }
 
     return Optional.of(CloseableIterator.from(lines.iterator()));