From: Simon Brandhof Date: Mon, 30 Jun 2014 14:52:26 +0000 (+0200) Subject: Fix some quality flaws X-Git-Tag: 4.4-RC1~85 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c95a564cd7ee1705f38062efe4f8750dffd6a8fa;p=sonarqube.git Fix some quality flaws --- diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java index 0391110d3a5..f7acd618a3a 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchComponents.java @@ -30,6 +30,10 @@ import java.util.Collection; import java.util.List; public class BatchComponents { + private BatchComponents() { + // only static stuff + } + public static Collection all() { List components = Lists.newArrayList( // Maven diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java index a9224cbbf3e..0ec11fc5973 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchExtensionDictionnary.java @@ -60,14 +60,14 @@ public class BatchExtensionDictionnary extends org.sonar.api.batch.BatchExtensio private List getFilteredExtensions(Class type, @Nullable Project project, @Nullable ExtensionMatcher matcher) { List result = Lists.newArrayList(); for (Object extension : getExtensions(type)) { - if (type == Sensor.class && extension instanceof Analyzer) { + if (Sensor.class.equals(type) && extension instanceof Analyzer) { extension = new SensorWrapper((Analyzer) extension, context, analyzerOptimizer); } if (shouldKeep(type, extension, project, matcher)) { result.add((T) extension); } } - if (type == Sensor.class) { + if (Sensor.class.equals(type)) { // Retrieve Analyzer and wrap then in SensorWrapper for (Object extension : getExtensions(Analyzer.class)) { extension = new SensorWrapper((Analyzer) extension, context, analyzerOptimizer); @@ -81,7 +81,7 @@ public class BatchExtensionDictionnary extends org.sonar.api.batch.BatchExtensio private boolean shouldKeep(Class type, Object extension, @Nullable Project project, @Nullable ExtensionMatcher matcher) { boolean keep = (ClassUtils.isAssignable(extension.getClass(), type) - || (type == Sensor.class && ClassUtils.isAssignable(extension.getClass(), Analyzer.class))) + || (Sensor.class.equals(type) && ClassUtils.isAssignable(extension.getClass(), Analyzer.class))) && (matcher == null || matcher.accept(extension)); if (keep && project != null && ClassUtils.isAssignable(extension.getClass(), CheckProject.class)) { keep = ((CheckProject) extension).shouldExecuteOnProject(project); diff --git a/sonar-batch/src/main/java/org/sonar/batch/qualitygate/ConditionUtils.java b/sonar-batch/src/main/java/org/sonar/batch/qualitygate/ConditionUtils.java index 59b3209dfef..5d5378a638a 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/qualitygate/ConditionUtils.java +++ b/sonar-batch/src/main/java/org/sonar/batch/qualitygate/ConditionUtils.java @@ -60,9 +60,9 @@ class ConditionUtils { private static boolean doesReachThresholds(Comparable measureValue, Comparable criteriaValue, ResolvedCondition condition) { int comparison = measureValue.compareTo(criteriaValue); return !(isNotEquals(comparison, condition) - || isGreater(comparison, condition) - || isSmaller(comparison, condition) - || isEquals(comparison, condition)); + || isGreater(comparison, condition) + || isSmaller(comparison, condition) + || isEquals(comparison, condition)); } private static boolean isNotEquals(int comparison, ResolvedCondition condition) { @@ -156,18 +156,18 @@ class ConditionUtils { private static boolean isADouble(Metric metric) { return metric.getType() == Metric.ValueType.FLOAT || - metric.getType() == Metric.ValueType.PERCENT || - metric.getType() == Metric.ValueType.RATING; + metric.getType() == Metric.ValueType.PERCENT || + metric.getType() == Metric.ValueType.RATING; } private static boolean isAInteger(Metric metric) { return metric.getType() == Metric.ValueType.INT || - metric.getType() == Metric.ValueType.MILLISEC; + metric.getType() == Metric.ValueType.MILLISEC; } private static boolean isAString(Metric metric) { return metric.getType() == Metric.ValueType.STRING || - metric.getType() == Metric.ValueType.LEVEL; + metric.getType() == Metric.ValueType.LEVEL; } private static boolean isABoolean(Metric metric) { @@ -183,18 +183,26 @@ class ConditionUtils { Double value; if (period == null) { value = measure.getValue(); - } else if (period == 1) { - value = measure.getVariation1(); - } else if (period == 2) { - value = measure.getVariation2(); - } else if (period == 3) { - value = measure.getVariation3(); - } else if (period == 4) { - value = measure.getVariation4(); - } else if (period == 5) { - value = measure.getVariation5(); } else { - throw new IllegalStateException("Following index period is not allowed : " + Double.toString(period)); + switch (period.intValue()) { + case 1: + value = measure.getVariation1(); + break; + case 2: + value = measure.getVariation2(); + break; + case 3: + value = measure.getVariation3(); + break; + case 4: + value = measure.getVariation4(); + break; + case 5: + value = measure.getVariation5(); + break; + default: + throw new IllegalStateException("Following index period is not allowed : " + Double.toString(period)); + } } return value; } diff --git a/sonar-core/src/main/java/org/sonar/jpa/session/DatabaseSessionFactory.java b/sonar-core/src/main/java/org/sonar/jpa/session/DatabaseSessionFactory.java index ae2f2799223..e22f79be589 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/session/DatabaseSessionFactory.java +++ b/sonar-core/src/main/java/org/sonar/jpa/session/DatabaseSessionFactory.java @@ -21,6 +21,9 @@ package org.sonar.jpa.session; import org.sonar.api.database.DatabaseSession; +/** + * @deprecated replaced by mybatis + */ @Deprecated public interface DatabaseSessionFactory { diff --git a/sonar-server/src/main/java/org/sonar/server/activity/ws/SearchAction.java b/sonar-server/src/main/java/org/sonar/server/activity/ws/SearchAction.java index 587de65ac8a..a6c40219281 100644 --- a/sonar-server/src/main/java/org/sonar/server/activity/ws/SearchAction.java +++ b/sonar-server/src/main/java/org/sonar/server/activity/ws/SearchAction.java @@ -72,7 +72,7 @@ public class SearchAction implements RequestHandler { @Override public void handle(Request request, Response response) { - ActivityQuery query = createLogQuery(logService.newActivityQuery(), request); + ActivityQuery query = logService.newActivityQuery(); SearchOptions searchOptions = SearchOptions.create(request); QueryOptions queryOptions = mapping.newQueryOptions(searchOptions); @@ -84,11 +84,6 @@ public class SearchAction implements RequestHandler { json.endObject().close(); } - public static ActivityQuery createLogQuery(ActivityQuery query, Request request) { - // query.setTypes(request.param(SearchOptions.PARAM_TEXT_QUERY)); - return query; - } - private void writeLogs(Result result, JsonWriter json, SearchOptions options) { json.name("logs").beginArray(); for (Activity log : result.getHits()) { 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 bec04c2fa8c..3e206296000 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 @@ -113,7 +113,7 @@ public class DuplicationsParser implements ServerComponent { @Override public int compare(@Nullable Duplication d1, - @Nullable Duplication d2) { + @Nullable Duplication d2) { if (d1 == null || d2 == null) { return -1; } @@ -145,10 +145,10 @@ public class DuplicationsParser implements ServerComponent { } } - private class BlockComparator implements Comparator, Serializable { + private static class BlockComparator implements Comparator { @Override public int compare(@Nullable Block b1, - @Nullable Block b2) { + @Nullable Block b2) { if (b1 == null || b2 == null) { return -1; } @@ -161,7 +161,6 @@ public class DuplicationsParser implements ServerComponent { } } - public static class Duplication { private final ComponentDto file; private final Integer from, size; diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfile.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfile.java index 40cfff102f7..ff068a999f0 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfile.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfile.java @@ -35,11 +35,17 @@ public class QProfile { private String language; private String parent; + /** + * @deprecated in 4.4 + */ @Deprecated public int id() { return id; } + /** + * @deprecated in 4.4 + */ @Deprecated QProfile setId(int id) { this.id = id; diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileName.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileName.java index ec97754abef..ae09c899cd5 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileName.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileName.java @@ -39,14 +39,13 @@ public class QProfileName { @Override public boolean equals(@Nullable Object o) { - if (this == o) + if (this == o) { return true; + } if (o == null || getClass() != o.getClass()) { return false; } - QProfileName that = (QProfileName) o; - if (!lang.equals(that.lang)) { return false; } diff --git a/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java b/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java index 8c0a2fc6181..f0b388b98cf 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java +++ b/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java @@ -295,7 +295,6 @@ public class RegisterRules implements Startable { RulesDefinition.Param paramDef = ruleDef.param(paramDto.getName()); if (paramDef == null) { // TODO cascade on the activeRule upon RuleDeletion - // activeRuleDao.removeRuleParam(paramDto, sqlSession); dbClient.ruleDao().removeRuleParam(session, rule, paramDto); } else { // TODO validate that existing active rules still match constraints diff --git a/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java b/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java index 7cd89b2811e..30dd0f2c058 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java +++ b/sonar-server/src/main/java/org/sonar/server/rule/RuleCreator.java @@ -196,13 +196,13 @@ public class RuleCreator implements ServerComponent { private void updateExistingRule(RuleDto ruleDto, NewRule newRule, DbSession dbSession){ if (ruleDto.getStatus().equals(RuleStatus.REMOVED)) { if (newRule.isPreventReactivation()) { - throw new ReactivationException(String.format("A removed rule with the key '%s' already exits", ruleDto.getKey().rule()), ruleDto.getKey()); + throw new ReactivationException(String.format("A removed rule with the key '%s' already exists", ruleDto.getKey().rule()), ruleDto.getKey()); } else { ruleDto.setStatus(RuleStatus.READY); dbClient.ruleDao().update(dbSession, ruleDto); } } else { - throw new IllegalArgumentException(String.format("A rule with the key '%s' already exits", ruleDto.getKey().rule())); + throw new IllegalArgumentException(String.format("A rule with the key '%s' already exists", ruleDto.getKey().rule())); } } 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 87f197c8973..22b272b72cd 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 @@ -59,6 +59,7 @@ import org.sonar.server.search.Result; import javax.annotation.CheckForNull; import javax.annotation.Nullable; + import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -105,7 +106,7 @@ public class RuleIndex extends BaseIndex { } private void setFields(QueryOptions options, SearchRequestBuilder esSearch) { - /* integrate Option's Fields */ + /* integrate Option's Fields */ Set fields = new HashSet(); if (!options.getFieldsToReturn().isEmpty()) { for (String fieldToReturn : options.getFieldsToReturn()) { @@ -125,14 +126,14 @@ public class RuleIndex extends BaseIndex { } private void setFacets(QueryOptions options, SearchRequestBuilder esSearch) { - /* Integrate Facets */ + /* Integrate Facets */ if (options.isFacet()) { this.setFacets(esSearch); } } private void setSorting(RuleQuery query, SearchRequestBuilder esSearch) { - /* integrate Query Sort */ + /* integrate Query Sort */ if (query.getSortField() != null) { FieldSortBuilder sort = SortBuilders.fieldSort(query.getSortField().sortField()); if (query.isAscendingSort()) { @@ -152,17 +153,10 @@ public class RuleIndex extends BaseIndex { } protected void setPagination(QueryOptions options, SearchRequestBuilder esSearch) { - /* integrate Option's Pagination */ esSearch.setFrom(options.getOffset()); esSearch.setSize(options.getLimit()); } - private QueryBuilder phraseQuery(IndexField field, String query, float boost) { - return QueryBuilders.matchPhraseQuery(field.field() + "." + IndexField.SEARCH_WORDS_SUFFIX, query) - .boost(boost) - .operator(MatchQueryBuilder.Operator.AND); - } - private QueryBuilder termQuery(IndexField field, String query, float boost) { return QueryBuilders.multiMatchQuery(query, field.field(), field.field() + "." + IndexField.SEARCH_PARTIAL_SUFFIX) @@ -189,7 +183,7 @@ public class RuleIndex extends BaseIndex { BoolQueryBuilder qb = QueryBuilders.boolQuery(); String queryString = query.getQueryText(); - //Human readable type of querying + // Human readable type of querying qb.should(QueryBuilders.queryString(query.getQueryText()) .field(RuleNormalizer.RuleField.NAME.field() + "." + IndexField.SEARCH_WORDS_SUFFIX, 20f) .field(RuleNormalizer.RuleField.HTML_DESCRIPTION.field() + "." + IndexField.SEARCH_WORDS_SUFFIX, 3f) @@ -244,7 +238,7 @@ public class RuleIndex extends BaseIndex { FilterBuilders.orFilter( FilterBuilders.termsFilter(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field(), query.getDebtCharacteristics()), FilterBuilders.termsFilter(RuleNormalizer.RuleField.CHARACTERISTIC.field(), query.getDebtCharacteristics())) - ), + ), // Match only when NOT NONE overriden FilterBuilders.andFilter( @@ -254,16 +248,15 @@ public class RuleIndex extends BaseIndex { FilterBuilders.orFilter( FilterBuilders.termsFilter(RuleNormalizer.RuleField.DEFAULT_SUB_CHARACTERISTIC.field(), query.getDebtCharacteristics()), FilterBuilders.termsFilter(RuleNormalizer.RuleField.DEFAULT_CHARACTERISTIC.field(), query.getDebtCharacteristics()))) - ) - ); + ) + ); } - //Debt char exist filter + // Debt char exist filter if (query.getHasDebtCharacteristic() != null && query.getHasDebtCharacteristic()) { fb.must(FilterBuilders.existsFilter(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field())); } - if (query.getAvailableSince() != null) { fb.must(FilterBuilders.rangeFilter(RuleNormalizer.RuleField.CREATED_AT.field()) .gte(query.getAvailableSince())); @@ -322,7 +315,7 @@ public class RuleIndex extends BaseIndex { .size(10) .minDocCount(1)); - /* the Tag facet */ + /* the Tag facet */ query.addAggregation(AggregationBuilders .terms("tags") .field(RuleNormalizer.RuleField._TAGS.field()) @@ -330,7 +323,7 @@ public class RuleIndex extends BaseIndex { .size(10) .minDocCount(1)); - /* the Repo facet */ + /* the Repo facet */ query.addAggregation(AggregationBuilders .terms("repositories") .field(RuleNormalizer.RuleField.REPOSITORY.field()) @@ -340,7 +333,6 @@ public class RuleIndex extends BaseIndex { } - public Result search(RuleQuery query, QueryOptions options) { StopWatch profile = profiling.start("es", Profiling.Level.FULL); @@ -369,14 +361,12 @@ public class RuleIndex extends BaseIndex { return new Result(this, esResult); } - @Override protected Rule toDoc(@Nullable Map fields) { Preconditions.checkArgument(fields != null, "Cannot construct Rule with null response!!!"); return new RuleDoc(fields); } - public Set terms(String fields) { Set tags = new HashSet(); String key = "_ref"; @@ -406,11 +396,11 @@ public class RuleIndex extends BaseIndex { public Rule getById(int id) { SearchResponse response = getClient().prepareSearch(this.getIndexName()) .setTypes(this.getIndexType()) - .setQuery(QueryBuilders.termQuery(RuleNormalizer.RuleField.ID.field(),id)) + .setQuery(QueryBuilders.termQuery(RuleNormalizer.RuleField.ID.field(), id)) .setSize(1) .get(); SearchHit hit = response.getHits().getAt(0); - if(hit == null){ + if (hit == null) { return null; } else { return toDoc(hit.getSource()); diff --git a/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java b/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java index 6460aca50f3..ddd10ef0e85 100644 --- a/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java +++ b/sonar-server/src/main/java/org/sonar/server/search/BaseIndex.java @@ -97,10 +97,6 @@ public abstract class BaseIndex, KEY extends Serial return node.client(); } - private ESNode getNode() { - return this.node; - } - /* Component Methods */ @Override @@ -112,7 +108,7 @@ public abstract class BaseIndex, KEY extends Serial @Override public void stop() { - + // nothing to do } // Scrolling within the index @@ -157,29 +153,7 @@ public abstract class BaseIndex, KEY extends Serial /* Cluster And ES Stats/Client methods */ - private void initializeManagementIndex() { - LOG.debug("Setup of Management Index for ES"); - - // String index = indexDefinition.getManagementIndex(); - // - // IndicesExistsResponse indexExistsResponse = getClient().admin().indices() - // .prepareExists(index).execute().actionGet(); - // - // if (!indexExistsResponse.isExists()) { - // getClient().admin().indices().prepareCreate(index) - // .setSettings(ImmutableSettings.builder() - // .put("mapper.dynamic", true) - // .put("number_of_replicas", 1) - // .put("number_of_shards", 1) - // .build()) - // .get(); - // } - } - protected void initializeIndex() { - - initializeManagementIndex(); - String index = this.getIndexName(); IndicesExistsResponse indexExistsResponse = getClient().admin().indices() diff --git a/sonar-server/src/main/java/org/sonar/server/search/IndexDefinition.java b/sonar-server/src/main/java/org/sonar/server/search/IndexDefinition.java index 5185ae6b9ef..81d8929466e 100644 --- a/sonar-server/src/main/java/org/sonar/server/search/IndexDefinition.java +++ b/sonar-server/src/main/java/org/sonar/server/search/IndexDefinition.java @@ -26,8 +26,8 @@ public class IndexDefinition { private final String indexName; private final String indexType; - private final String MANAGEMENT_INDEX = "sonarindex"; - private final String MANAGEMENT_TYPE = "index"; + private static final String MANAGEMENT_INDEX = "sonarindex"; + private static final String MANAGEMENT_TYPE = "index"; private IndexDefinition(String indexName, String indexType) { this.indexName = indexName; diff --git a/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java b/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java index 87a68428806..a2f67178aca 100644 --- a/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java +++ b/sonar-server/src/main/java/org/sonar/server/search/IndexProperties.java @@ -19,11 +19,12 @@ */ package org.sonar.server.search; -/** - * @since 4.4 - */ public final class IndexProperties { + private IndexProperties() { + // only static stuff + } + public static enum ES_TYPE { MEMORY, TRANSPORT, DATA } diff --git a/sonar-server/src/main/java/org/sonar/server/search/IndexQueueWorker.java b/sonar-server/src/main/java/org/sonar/server/search/IndexQueueWorker.java index d0c5ade780f..c2948b717d9 100644 --- a/sonar-server/src/main/java/org/sonar/server/search/IndexQueueWorker.java +++ b/sonar-server/src/main/java/org/sonar/server/search/IndexQueueWorker.java @@ -51,9 +51,6 @@ public class IndexQueueWorker extends ThreadPoolExecutor } protected void afterExecute(Runnable r, Throwable t) { -// LOG.info("Current active thread number: " + this.getActiveCount() + -// " queue size:" + this.getQueue().size() + -// " scheduled task number:" + this.getTaskCount()); super.afterExecute(r, t); if (t != null) { throw new IllegalStateException(t); diff --git a/sonar-server/src/main/java/org/sonar/server/user/UserSession.java b/sonar-server/src/main/java/org/sonar/server/user/UserSession.java index f8b9853fb50..1bfc6f48ff0 100644 --- a/sonar-server/src/main/java/org/sonar/server/user/UserSession.java +++ b/sonar-server/src/main/java/org/sonar/server/user/UserSession.java @@ -35,7 +35,11 @@ import org.sonar.server.platform.Platform; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Locale; +import java.util.Map; import static com.google.common.collect.Lists.newArrayList; import static com.google.common.collect.Maps.newHashMap; @@ -188,7 +192,7 @@ public class UserSession { if (projectKey == null) { ResourceDto project = resourceDao().getRootProjectByComponentKey(componentKey); if (project == null) { - return false; + return false; } projectKey = project.getKey(); } diff --git a/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java b/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java index cac6742e1b4..9cc91b2c0b2 100644 --- a/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java +++ b/sonar-server/src/test/java/org/sonar/server/rule/RuleCreatorMediumTest.java @@ -248,7 +248,7 @@ public class RuleCreatorMediumTest { } @Test - public void fail_to_create_custom_rule_when_rule_key_already_exits() throws Exception { + public void fail_to_create_custom_rule_when_rule_key_already_exists() throws Exception { // insert template rule RuleDto templateRule = createTemplateRule(); @@ -272,7 +272,7 @@ public class RuleCreatorMediumTest { creator.create(newRule); fail(); } catch (Exception e) { - assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("A rule with the key 'CUSTOM_RULE' already exits"); + assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("A rule with the key 'CUSTOM_RULE' already exists"); } } @@ -507,7 +507,7 @@ public class RuleCreatorMediumTest { } @Test - public void fail_to_create_manual_rule_when_rule_key_already_exits() throws Exception { + public void fail_to_create_manual_rule_when_rule_key_already_exists() throws Exception { NewRule newRule = NewRule.createForManualRule("MANUAL_RULE") .setName("My manual") .setHtmlDescription("Some description"); @@ -521,7 +521,7 @@ public class RuleCreatorMediumTest { creator.create(newRule); fail(); } catch (Exception e) { - assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("A rule with the key 'MANUAL_RULE' already exits"); + assertThat(e).isInstanceOf(IllegalArgumentException.class).hasMessage("A rule with the key 'MANUAL_RULE' already exists"); } } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java index 0ab9691bb54..0a7275151b2 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java @@ -32,8 +32,6 @@ import org.sonar.wsclient.qprofile.QProfileClient; import org.sonar.wsclient.qprofile.internal.DefaultQProfileClient; import org.sonar.wsclient.qualitygate.QualityGateClient; import org.sonar.wsclient.qualitygate.internal.DefaultQualityGateClient; -import org.sonar.wsclient.rule.RuleClient; -import org.sonar.wsclient.rule.internal.DefaultRuleClient; import org.sonar.wsclient.system.SystemClient; import org.sonar.wsclient.system.internal.DefaultSystemClient; import org.sonar.wsclient.user.UserClient; @@ -109,13 +107,6 @@ public class SonarClient { return new DefaultProjectClient(requestFactory); } - /** - * New client to interact with web services related to rules - */ - public RuleClient ruleClient() { - return new DefaultRuleClient(requestFactory); - } - /** * New client to interact with web services related to quality gates */ diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issue.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issue.java index ccd18193463..3727840e4d9 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issue.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issue.java @@ -38,7 +38,7 @@ public interface Issue { String componentKey(); /** - * Deprecated since 4.4. Use {@link #componentKey()} instead + * @deprecated since 4.4. Use {@link #componentKey()} instead */ @Deprecated Long componentId(); diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/RuleClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/RuleClient.java deleted file mode 100644 index c59588f1e73..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/RuleClient.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.rule; - -/** - * Allows management of rules - * @since 4.2 - */ -public interface RuleClient { - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/DefaultRuleClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/DefaultRuleClient.java deleted file mode 100644 index e6d7f98ec0e..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/DefaultRuleClient.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.rule.internal; - -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.rule.RuleClient; - -/** - * Do not instantiate this class, but use {@link org.sonar.wsclient.SonarClient#ruleClient()}. - */ -public class DefaultRuleClient implements RuleClient { - - private static final String ROOT_URL = "/api/rules"; - - private final HttpRequestFactory requestFactory; - - public DefaultRuleClient(HttpRequestFactory requestFactory) { - this.requestFactory = requestFactory; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/package-info.java deleted file mode 100644 index 73869c9ce0e..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@ParametersAreNonnullByDefault package org.sonar.wsclient.rule.internal; - -import javax.annotation.ParametersAreNonnullByDefault; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java index 3f3c6e53050..e6e82045b96 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java @@ -26,7 +26,6 @@ import org.sonar.wsclient.permissions.internal.DefaultPermissionClient; import org.sonar.wsclient.project.internal.DefaultProjectClient; import org.sonar.wsclient.qprofile.internal.DefaultQProfileClient; import org.sonar.wsclient.qualitygate.internal.DefaultQualityGateClient; -import org.sonar.wsclient.rule.internal.DefaultRuleClient; import org.sonar.wsclient.system.internal.DefaultSystemClient; import org.sonar.wsclient.user.internal.DefaultUserClient; @@ -42,7 +41,6 @@ public class SonarClientTest { assertThat(client.userClient()).isNotNull().isInstanceOf(DefaultUserClient.class); assertThat(client.permissionClient()).isNotNull().isInstanceOf(DefaultPermissionClient.class); assertThat(client.projectClient()).isNotNull().isInstanceOf(DefaultProjectClient.class); - assertThat(client.ruleClient()).isNotNull().isInstanceOf(DefaultRuleClient.class); assertThat(client.qualityGateClient()).isNotNull().isInstanceOf(DefaultQualityGateClient.class); assertThat(client.qProfileClient()).isNotNull().isInstanceOf(DefaultQProfileClient.class); assertThat(client.systemClient()).isNotNull().isInstanceOf(DefaultSystemClient.class); diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/rule/internal/DefaultRuleClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/rule/internal/DefaultRuleClientTest.java deleted file mode 100644 index ac27da21700..00000000000 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/rule/internal/DefaultRuleClientTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.rule.internal; - -import org.junit.Before; -import org.junit.Rule; -import org.sonar.wsclient.MockHttpServerInterceptor; -import org.sonar.wsclient.internal.HttpRequestFactory; - -public class DefaultRuleClientTest { - - @Rule - public MockHttpServerInterceptor httpServer = new MockHttpServerInterceptor(); - - private DefaultRuleClient client; - - @Before - public void initClient() { - HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url()); - this.client = new DefaultRuleClient(requestFactory); - } - -}