diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-07-01 16:25:01 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-07-01 16:25:08 +0200 |
commit | bdc239fc9ac9c6aa94bc80eab122de7a0fb698ef (patch) | |
tree | 5319c5a9da777c247f252566245a4dc9b7a8d5ab /sonar-server | |
parent | 31c56c4337d47b6e0486c8ceb2815c7fa1173dcc (diff) | |
download | sonarqube-bdc239fc9ac9c6aa94bc80eab122de7a0fb698ef.tar.gz sonarqube-bdc239fc9ac9c6aa94bc80eab122de7a0fb698ef.zip |
Fix quality flaws
Diffstat (limited to 'sonar-server')
8 files changed, 29 insertions, 28 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/charts/deprecated/CustomBarChart.java b/sonar-server/src/main/java/org/sonar/server/charts/deprecated/CustomBarChart.java index 260c4930277..4541ce07895 100644 --- a/sonar-server/src/main/java/org/sonar/server/charts/deprecated/CustomBarChart.java +++ b/sonar-server/src/main/java/org/sonar/server/charts/deprecated/CustomBarChart.java @@ -115,7 +115,7 @@ public class CustomBarChart extends BarChart { } else { categoriesSplit = new String[nbValues]; for (int i = 0; i < nbValues; i++) { - categoriesSplit[i] = DEFAULT_NAME_CATEGORY + i; + categoriesSplit[i] = new StringBuilder().append(DEFAULT_NAME_CATEGORY).append(i).toString(); } } diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ChangeLogMigration.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ChangeLogMigration.java index 2a3f67432d8..a92f0983af6 100644 --- a/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ChangeLogMigration.java +++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ChangeLogMigration.java @@ -109,10 +109,10 @@ public class ChangeLogMigration implements DatabaseMigration { private void processRuleChange(ActiveRuleChange ruleChange, ChangeLog change) { ruleChange.setSeverity(SeverityUtil.getSeverityFromOrdinal(change.getSeverity())); - String param_name = change.getParamKey(); - String param_value = change.getParamValue(); - if (StringUtils.isNotEmpty(param_name)) { - ruleChange.setParameter(param_name, param_value); + String paramName = change.getParamKey(); + String paramValue = change.getParamValue(); + if (StringUtils.isNotEmpty(paramName)) { + ruleChange.setParameter(paramName, paramValue); } } diff --git a/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsParser.java b/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsParser.java index 3e206296000..fd448b98f91 100644 --- a/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsParser.java +++ b/sonar-server/src/main/java/org/sonar/server/duplication/ws/DuplicationsParser.java @@ -145,7 +145,7 @@ public class DuplicationsParser implements ServerComponent { } } - private static class BlockComparator implements Comparator<Block> { + private static class BlockComparator implements Comparator<Block>, Serializable { @Override public int compare(@Nullable Block b1, @Nullable Block b2) { diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RuleActivationActions.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RuleActivationActions.java index b89ebbc5a3a..efa0e1bca12 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RuleActivationActions.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/RuleActivationActions.java @@ -117,7 +117,7 @@ public class RuleActivationActions implements ServerComponent { if (params != null) { activation.setParameters(KeyValueFormat.parse(params)); } - activation.setReset(request.paramAsBoolean(RESET) == Boolean.TRUE); + activation.setReset(Boolean.TRUE.equals(request.paramAsBoolean(RESET))); service.activate(request.mandatoryParam(PROFILE_KEY), activation); } diff --git a/sonar-server/src/main/java/org/sonar/server/rule/index/RuleDoc.java b/sonar-server/src/main/java/org/sonar/server/rule/index/RuleDoc.java index 0ff56b58ae1..b90b835440a 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule/index/RuleDoc.java +++ b/sonar-server/src/main/java/org/sonar/server/rule/index/RuleDoc.java @@ -136,16 +136,10 @@ public class RuleDoc extends BaseDoc implements Rule { @Override public List<RuleParam> params() { List<RuleParam> params = new ArrayList<RuleParam>(); - List<Map<String, Object>> esParams = getNullableField(RuleNormalizer.RuleField.PARAMS.field()); + final List<Map<String, Object>> esParams = getNullableField(RuleNormalizer.RuleField.PARAMS.field()); if (esParams != null) { for (final Map<String, Object> esParam : esParams) { params.add(new RuleParam() { - { - this.fields = esParam; - } - - Map<String, Object> fields; - @Override public String key() { return (String) esParam.get(RuleNormalizer.RuleParamField.NAME.field()); @@ -163,8 +157,7 @@ public class RuleDoc extends BaseDoc implements Rule { @Override public RuleParamType type() { - return RuleParamType - .parse((String) esParam.get(RuleNormalizer.RuleParamField.TYPE.field())); + return RuleParamType.parse((String) esParam.get(RuleNormalizer.RuleParamField.TYPE.field())); } }); } diff --git a/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java b/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java index 22b272b72cd..a6bc91a3213 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java +++ b/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java @@ -228,7 +228,8 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { this.addTermFilter(fb, RuleNormalizer.RuleField._TAGS.field(), query.getTags()); // Construct the debt filter on effective char and subChar - if (query.getDebtCharacteristics() != null && !query.getDebtCharacteristics().isEmpty()) { + Collection<String> characteristics = query.getDebtCharacteristics(); + if (characteristics != null && !characteristics.isEmpty()) { fb.must( FilterBuilders.orFilter( // Match only when NOT NONE overriden @@ -236,8 +237,8 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { FilterBuilders.notFilter( FilterBuilders.termsFilter(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field(), DebtCharacteristic.NONE)), FilterBuilders.orFilter( - FilterBuilders.termsFilter(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field(), query.getDebtCharacteristics()), - FilterBuilders.termsFilter(RuleNormalizer.RuleField.CHARACTERISTIC.field(), query.getDebtCharacteristics())) + FilterBuilders.termsFilter(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field(), characteristics), + FilterBuilders.termsFilter(RuleNormalizer.RuleField.CHARACTERISTIC.field(), characteristics)) ), // Match only when NOT NONE overriden @@ -246,14 +247,14 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { FilterBuilders.termsFilter(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field(), ""), FilterBuilders.notFilter(FilterBuilders.existsFilter(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field()))), FilterBuilders.orFilter( - FilterBuilders.termsFilter(RuleNormalizer.RuleField.DEFAULT_SUB_CHARACTERISTIC.field(), query.getDebtCharacteristics()), - FilterBuilders.termsFilter(RuleNormalizer.RuleField.DEFAULT_CHARACTERISTIC.field(), query.getDebtCharacteristics()))) + FilterBuilders.termsFilter(RuleNormalizer.RuleField.DEFAULT_SUB_CHARACTERISTIC.field(), characteristics), + FilterBuilders.termsFilter(RuleNormalizer.RuleField.DEFAULT_CHARACTERISTIC.field(), characteristics))) ) ); } // Debt char exist filter - if (query.getHasDebtCharacteristic() != null && query.getHasDebtCharacteristic()) { + if (Boolean.TRUE.equals(query.getHasDebtCharacteristic())) { fb.must(FilterBuilders.existsFilter(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field())); } @@ -262,9 +263,10 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { .gte(query.getAvailableSince())); } - if (query.getStatuses() != null && !query.getStatuses().isEmpty()) { + Collection<RuleStatus> statuses = query.getStatuses(); + if (statuses != null && !statuses.isEmpty()) { Collection<String> stringStatus = new ArrayList<String>(); - for (RuleStatus status : query.getStatuses()) { + for (RuleStatus status : statuses) { stringStatus.add(status.name()); } this.addTermFilter(fb, RuleNormalizer.RuleField.STATUS.field(), stringStatus); @@ -391,6 +393,9 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { return tags; } + /** + * @deprecated do not use ids but keys + */ @Deprecated @CheckForNull public Rule getById(int id) { @@ -407,6 +412,9 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { } } + /** + * @deprecated do not use ids but keys + */ @Deprecated public List<Rule> getByIds(Collection<Integer> ids) { SearchResponse response = getClient().prepareSearch(this.getIndexName()) diff --git a/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java b/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java index 887b92abba3..0bb354aa314 100644 --- a/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java +++ b/sonar-server/src/main/java/org/sonar/server/search/IndexSynchronizer.java @@ -60,6 +60,6 @@ public class IndexSynchronizer { long start = System.currentTimeMillis(); dao.synchronizeAfter(session, index.getLastSynchronization()); - LOG.info("-- Synchronized {} in {}ms", index.getIndexType(), (System.currentTimeMillis() - start)); + LOG.info("-- Synchronized {} in {}ms", index.getIndexType(), System.currentTimeMillis() - start); } } diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewMeasureFilters.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewMeasureFilters.java index 755a1eed6a6..84c53745e9b 100644 --- a/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewMeasureFilters.java +++ b/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewMeasureFilters.java @@ -149,11 +149,11 @@ public final class RegisterNewMeasureFilters { private static void appendColumns(Filter filter, List<String> fields) { List<String> columnFields = Lists.newArrayList(); for (FilterColumn column : filter.getColumns()) { - String columnKey = column.getFamily(); + StringBuilder columnKey = new StringBuilder().append(column.getFamily()); if (StringUtils.isNotBlank(column.getKey()) && !column.isVariation()) { - columnKey += ":" + column.getKey(); + columnKey.append(":").append(column.getKey()); } - columnFields.add(columnKey); + columnFields.add(columnKey.toString()); } if (!columnFields.isEmpty()) { fields.add("cols=" + Joiner.on(",").join(columnFields)); |