]> source.dussan.org Git - sonarqube.git/commitdiff
Fix Quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 16 Jun 2016 12:28:17 +0000 (14:28 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 16 Jun 2016 13:06:33 +0000 (15:06 +0200)
server/sonar-search/src/main/java/org/sonar/search/SearchServer.java
server/sonar-server/src/main/java/org/sonar/server/source/SourceService.java
server/sonar-server/src/main/java/org/sonar/server/test/index/TestIndexer.java
sonar-db/src/main/java/org/sonar/db/issue/IssueDao.java

index f21987fb994aae65eb0a1bb4cb69e2568ea3e0c4..ee6afaf3487f69938642d6a219da1449f6484b35 100644 (file)
@@ -50,7 +50,7 @@ public class SearchServer implements Monitored {
   }
 
   // copied from https://github.com/elastic/elasticsearch/blob/v2.3.3/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java
-  private void initBootstrap() {
+  private static void initBootstrap() {
     // init lucene random seed. it will use /dev/urandom where available:
     StringHelper.randomId();
   }
index 57689404bc4198409dc7b38f3844f8988b6a2c23..42d482105608277addf3aa56ae9a242d69c3a273 100644 (file)
@@ -47,7 +47,7 @@ public class SourceService {
    * @param toInclusive starts from 1, must be greater than or equal param {@code from}
    */
   public Optional<Iterable<DbFileSources.Line>> getLines(DbSession dbSession, String fileUuid, int from, int toInclusive) {
-    return getLines(dbSession, fileUuid, from, toInclusive, Functions.<DbFileSources.Line>identity());
+    return getLines(dbSession, fileUuid, from, toInclusive, Functions.identity());
   }
 
   /**
@@ -70,7 +70,7 @@ public class SourceService {
       return Optional.absent();
     }
     DbFileSources.Data data = dto.getSourceData();
-    return Optional.of((Iterable<E>) FluentIterable.from(data.getLinesList())
+    return Optional.of(FluentIterable.from(data.getLinesList())
       .filter(new IsGreaterOrEqualThanLine(from))
       .limit(toInclusive - from + 1)
       .transform(function));
@@ -81,12 +81,7 @@ public class SourceService {
   }
 
   private Function<DbFileSources.Line, String> lineToHtml() {
-    return new Function<DbFileSources.Line, String>() {
-      @Override
-      public String apply(@Nonnull DbFileSources.Line line) {
-        return htmlDecorator.getDecoratedSourceAsHtml(line.getSource(), line.getHighlighting(), line.getSymbols());
-      }
-    };
+    return line -> htmlDecorator.getDecoratedSourceAsHtml(line.getSource(), line.getHighlighting(), line.getSymbols());
   }
 
   private enum LineToRaw implements Function<DbFileSources.Line, String> {
index ad112c2f1b9e0f3de3544eccd8a50109d319026b..2b20ffdac67ee8c8a12659455aad7ed1b119d0ff 100644 (file)
  */
 package org.sonar.server.test.index;
 
+import static org.sonar.server.test.index.TestIndexDefinition.FIELD_FILE_UUID;
+import static org.sonar.server.test.index.TestIndexDefinition.FIELD_UPDATED_AT;
+import static org.sonar.server.test.index.TestIndexDefinition.INDEX;
+import static org.sonar.server.test.index.TestIndexDefinition.TYPE;
+
 import java.util.Iterator;
 import javax.annotation.Nullable;
 import org.elasticsearch.action.search.SearchRequestBuilder;
-import org.elasticsearch.action.update.UpdateRequest;
 import org.elasticsearch.index.query.QueryBuilders;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
@@ -31,11 +35,6 @@ import org.sonar.server.es.BulkIndexer;
 import org.sonar.server.es.EsClient;
 import org.sonar.server.source.index.FileSourcesUpdaterHelper;
 
-import static org.sonar.server.test.index.TestIndexDefinition.FIELD_FILE_UUID;
-import static org.sonar.server.test.index.TestIndexDefinition.FIELD_UPDATED_AT;
-import static org.sonar.server.test.index.TestIndexDefinition.INDEX;
-import static org.sonar.server.test.index.TestIndexDefinition.TYPE;
-
 /**
  * Add to Elasticsearch index {@link TestIndexDefinition} the rows of
  * db table FILE_SOURCES of type TEST that are not indexed yet
@@ -51,12 +50,7 @@ public class TestIndexer extends BaseIndexer {
 
   public void index(final String projectUuid) {
     deleteByProject(projectUuid);
-    super.index(new IndexerTask() {
-      @Override
-      public long index(long lastUpdatedAt) {
-        return doIndex(lastUpdatedAt, projectUuid);
-      }
-    });
+    super.index(lastUpdatedAt -> doIndex(lastUpdatedAt, projectUuid));
   }
 
   public long index(Iterator<FileSourcesUpdaterHelper.Row> dbRows) {
@@ -90,9 +84,7 @@ public class TestIndexer extends BaseIndexer {
     bulk.start();
     while (dbRows.hasNext()) {
       FileSourcesUpdaterHelper.Row row = dbRows.next();
-      for (UpdateRequest updateRequest : row.getUpdateRequests()) {
-        bulk.add(updateRequest);
-      }
+      row.getUpdateRequests().forEach(bulk::add);
       maxUpdatedAt = Math.max(maxUpdatedAt, row.getUpdatedAt());
     }
     bulk.stop();
index d5a0eef5d9ae16255a3060a6dd7d94d23d40846a..0a4526f36db36d17a9e7f3cfe20d684f87f89f68 100644 (file)
@@ -31,7 +31,6 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.sonar.db.Dao;
 import org.sonar.db.DbSession;
-import org.sonar.db.MyBatis;
 import org.sonar.db.RowNotFoundException;
 
 import static com.google.common.collect.FluentIterable.from;
@@ -39,12 +38,6 @@ import static org.sonar.db.DatabaseUtils.executeLargeInputs;
 
 public class IssueDao implements Dao {
 
-  private final MyBatis mybatis;
-
-  public IssueDao(MyBatis mybatis) {
-    this.mybatis = mybatis;
-  }
-
   public Optional<IssueDto> selectByKey(DbSession session, String key) {
     return Optional.fromNullable(mapper(session).selectByKey(key));
   }