aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-10-06 12:41:53 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-10-06 12:41:53 +0200
commit6e12b78d539dd2b299bde13e79197cdda81348b2 (patch)
treef57fe1ac318b214efc15bee67ebb2dd1c635ac4f
parent91d7a98155a4a47e945e06a6cd7c4ea476fea668 (diff)
downloadsonarqube-6e12b78d539dd2b299bde13e79197cdda81348b2.tar.gz
sonarqube-6e12b78d539dd2b299bde13e79197cdda81348b2.zip
Fix quality flaws
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/computation/issue/IntegrateIssuesVisitor.java9
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java37
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java8
-rw-r--r--sonar-db/src/main/java/org/sonar/db/version/DecimalColumnDef.java4
4 files changed, 34 insertions, 24 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/IntegrateIssuesVisitor.java b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/IntegrateIssuesVisitor.java
index e95b8814da4..2765aa5ace6 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/computation/issue/IntegrateIssuesVisitor.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/computation/issue/IntegrateIssuesVisitor.java
@@ -19,6 +19,9 @@
*/
package org.sonar.server.computation.issue;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.core.issue.tracking.Tracking;
import org.sonar.server.computation.component.Component;
@@ -26,10 +29,6 @@ import org.sonar.server.computation.component.CrawlerDepthLimit;
import org.sonar.server.computation.component.TypeAwareVisitorAdapter;
import org.sonar.server.util.cache.DiskCache;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
import static org.sonar.server.computation.component.ComponentVisitor.Order.POST_ORDER;
public class IntegrateIssuesVisitor extends TypeAwareVisitorAdapter {
@@ -72,7 +71,7 @@ public class IntegrateIssuesVisitor extends TypeAwareVisitorAdapter {
closeUnmatchedBaseIssues(component, tracking, cacheAppender);
issueVisitors.afterComponent(component);
} catch (Exception e) {
- throw new RuntimeException(String.format("Fail to process issues of component '%s'", component.getKey()), e);
+ throw new IllegalStateException(String.format("Fail to process issues of component '%s'", component.getKey()), e);
} finally {
cacheAppender.close();
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java
index 94dc86b1c77..ab36cf17083 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/debt/DebtRulesXMLImporter.java
@@ -23,6 +23,14 @@ package org.sonar.server.debt;
import com.google.common.base.Predicate;
import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.List;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.codehaus.stax2.XMLInputFactory2;
@@ -33,28 +41,31 @@ import org.sonar.api.rule.RuleKey;
import org.sonar.api.server.ServerSide;
import org.sonar.api.utils.Duration;
import org.sonar.api.utils.ValidationMessages;
-import org.sonar.server.debt.DebtModelXMLExporter.*;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.List;
+import org.sonar.server.debt.DebtModelXMLExporter.RuleDebt;
import static com.google.common.collect.Lists.newArrayList;
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
-import static javax.xml.stream.XMLInputFactory.*;
+import static javax.xml.stream.XMLInputFactory.IS_COALESCING;
+import static javax.xml.stream.XMLInputFactory.IS_NAMESPACE_AWARE;
+import static javax.xml.stream.XMLInputFactory.IS_VALIDATING;
+import static javax.xml.stream.XMLInputFactory.SUPPORT_DTD;
import static org.apache.commons.lang.StringUtils.isNotBlank;
import static org.sonar.api.server.debt.DebtRemediationFunction.Type.CONSTANT_ISSUE;
import static org.sonar.api.server.debt.DebtRemediationFunction.Type.LINEAR;
import static org.sonar.api.utils.Duration.MINUTE;
import static org.sonar.server.debt.DebtCharacteristicsXMLImporter.convertKey;
-import static org.sonar.server.debt.DebtModelXMLExporter.*;
+import static org.sonar.server.debt.DebtModelXMLExporter.CHARACTERISTIC;
+import static org.sonar.server.debt.DebtModelXMLExporter.CHARACTERISTIC_KEY;
+import static org.sonar.server.debt.DebtModelXMLExporter.PROPERTY;
+import static org.sonar.server.debt.DebtModelXMLExporter.PROPERTY_COEFFICIENT;
+import static org.sonar.server.debt.DebtModelXMLExporter.PROPERTY_FUNCTION;
+import static org.sonar.server.debt.DebtModelXMLExporter.PROPERTY_KEY;
+import static org.sonar.server.debt.DebtModelXMLExporter.PROPERTY_OFFSET;
+import static org.sonar.server.debt.DebtModelXMLExporter.PROPERTY_TEXT_VALUE;
+import static org.sonar.server.debt.DebtModelXMLExporter.PROPERTY_VALUE;
+import static org.sonar.server.debt.DebtModelXMLExporter.REPOSITORY_KEY;
+import static org.sonar.server.debt.DebtModelXMLExporter.RULE_KEY;
/**
* Import rules debt definitions from an XML
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java b/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java
index ec2e140e37d..a058604bcfc 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/BackendCleanup.java
@@ -22,12 +22,13 @@ package org.sonar.server.platform;
import java.sql.Connection;
import java.sql.SQLException;
import org.apache.commons.dbutils.DbUtils;
+import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.index.query.QueryBuilders;
import org.sonar.api.server.ServerSide;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.db.version.DatabaseVersion;
import org.sonar.db.DbSession;
import org.sonar.db.MyBatis;
+import org.sonar.db.version.DatabaseVersion;
import org.sonar.server.es.EsClient;
import org.sonar.server.issue.index.IssueIndexDefinition;
import org.sonar.server.search.IndexDefinition;
@@ -88,7 +89,6 @@ public class BackendCleanup {
.get();
esClient.prepareRefresh(esClient.prepareState().get()
.getState().getMetaData().concreteAllIndices())
- .setForce(true)
.get();
esClient.prepareFlush(esClient.prepareState().get()
.getState().getMetaData().concreteAllIndices())
@@ -159,7 +159,7 @@ public class BackendCleanup {
*/
public void clearIndex(String indexName) {
esClient.prepareDeleteByQuery(esClient.prepareState().get()
- .getState().getMetaData().concreteIndices(new String[] {indexName}))
+ .getState().getMetaData().concreteIndices(IndicesOptions.strictExpand(), indexName))
.setQuery(QueryBuilders.matchAllQuery())
.get();
}
@@ -169,7 +169,7 @@ public class BackendCleanup {
*/
public void clearIndexType(IndexDefinition indexDefinition) {
esClient.prepareDeleteByQuery(esClient.prepareState().get()
- .getState().getMetaData().concreteIndices(new String[] {indexDefinition.getIndexName()})).setTypes(indexDefinition.getIndexType())
+ .getState().getMetaData().concreteIndices(IndicesOptions.strictExpand(), indexDefinition.getIndexName())).setTypes(indexDefinition.getIndexType())
.setQuery(QueryBuilders.matchAllQuery())
.get();
}
diff --git a/sonar-db/src/main/java/org/sonar/db/version/DecimalColumnDef.java b/sonar-db/src/main/java/org/sonar/db/version/DecimalColumnDef.java
index 733564a1164..b2a0c6cb0eb 100644
--- a/sonar-db/src/main/java/org/sonar/db/version/DecimalColumnDef.java
+++ b/sonar-db/src/main/java/org/sonar/db/version/DecimalColumnDef.java
@@ -32,8 +32,8 @@ import static org.sonar.db.version.ColumnDefValidation.validateColumnName;
public class DecimalColumnDef extends AbstractColumnDef {
- public final static int DEFAULT_PRECISION = 38;
- public final static int DEFAULT_SCALE = 20;
+ public static final int DEFAULT_PRECISION = 38;
+ public static final int DEFAULT_SCALE = 20;
private final int precision;
private final int scale;