diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-06-18 17:08:30 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-06-19 20:12:12 +0200 |
commit | 9bfb3bb8b4775294831f38f7ae7aea35416d680b (patch) | |
tree | 13b20ce874b87d5c1dc7a2f715244ee0ea603bc0 /sonar-plugin-api | |
parent | 6fbd7d0754de53986bc1d37ae7fd29c8e32872a1 (diff) | |
download | sonarqube-9bfb3bb8b4775294831f38f7ae7aea35416d680b.tar.gz sonarqube-9bfb3bb8b4775294831f38f7ae7aea35416d680b.zip |
SONAR-5007 add single unique key to quality profiles. Replace DB ID.
Diffstat (limited to 'sonar-plugin-api')
5 files changed, 43 insertions, 48 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rules/QProfile.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rules/QProfile.java index 1b4e947b679..189cdc06158 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rules/QProfile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rules/QProfile.java @@ -20,13 +20,13 @@ package org.sonar.api.batch.rules; public class QProfile { - private final String name, language; - private final Integer version; - public QProfile(String name, String language, Integer version) { + private final String key, name, language; + + public QProfile(String key, String name, String language) { + this.key = key; this.name = name; this.language = language; - this.version = version; } public String name() { @@ -37,7 +37,25 @@ public class QProfile { return language; } - public Integer version() { - return version; + public String key() { + return key; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + QProfile qProfile = (QProfile) o; + return key.equals(qProfile.key); + } + + @Override + public int hashCode() { + return key.hashCode(); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java index eb0c7ccb409..fcd97ff2799 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java @@ -2226,38 +2226,6 @@ public final class CoreMetrics { .create(); /** - * @deprecated since 4.4 doesn't support multi-language. See {@link #QUALITY_PROFILES_KEY} - */ - @Deprecated - public static final String PROFILE_KEY = "profile"; - /** - * @deprecated since 4.4 doesn't support multi-language. See {@link #QUALITY_PROFILES_KEY} - */ - @Deprecated - public static final Metric<String> PROFILE = new Metric.Builder(PROFILE_KEY, "Profile", Metric.ValueType.DATA) - .setDescription("Selected quality profile") - .setDomain(DOMAIN_GENERAL) - .create(); - - /** - * @since 2.9 - * @deprecated since 4.4 doesn't support multi-language. See {@link #QUALITY_PROFILES_KEY} - */ - @Deprecated - public static final String PROFILE_VERSION_KEY = "profile_version"; - /** - * @since 2.9 - * @deprecated since 4.4 doesn't support multi-language. See {@link #QUALITY_PROFILES_KEY} - */ - @Deprecated - public static final Metric<Integer> PROFILE_VERSION = new Metric.Builder(PROFILE_VERSION_KEY, "Profile version", Metric.ValueType.INT) - .setDescription("Selected quality profile version") - .setQualitative(false) - .setDomain(DOMAIN_GENERAL) - .setHidden(true) - .create(); - - /** * @since 4.4 */ public static final String QUALITY_PROFILES_KEY = "quality_profiles"; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java index 07b71645d15..64f9ea92ab7 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java @@ -66,7 +66,6 @@ public class RulesProfile implements Cloneable { private Integer id; private String name; - private int version = 1; private Boolean defaultProfile = Boolean.FALSE; private Boolean used = Boolean.FALSE; private String language; @@ -118,19 +117,35 @@ public class RulesProfile implements Cloneable { return this; } + /** + * @deprecated profile versioning is dropped in 4.4. Always returns -1. + */ + @Deprecated public int getVersion() { - return version; + return -1; } + /** + * @deprecated profile versioning is dropped in 4.4. Always returns -1. + */ + @Deprecated public RulesProfile setVersion(int version) { - this.version = version; + // ignore return this; } + /** + * @deprecated profile versioning is dropped in 4.4. Always returns -1. + */ + @Deprecated public Boolean getUsed() { return used; } + /** + * @deprecated profile versioning is dropped in 4.4. Always returns -1. + */ + @Deprecated public RulesProfile setUsed(Boolean used) { this.used = used; return this; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/RulesProfileTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/RulesProfileTest.java index 877685ece27..9830c392a2c 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/profiles/RulesProfileTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/profiles/RulesProfileTest.java @@ -57,12 +57,6 @@ public class RulesProfileTest { } @Test - public void defaultVersionIs1() { - RulesProfile profile = RulesProfile.create(); - assertThat(profile.getVersion()).isEqualTo(1); - } - - @Test public void fail_to_activate_already_activated_rule() { RulesProfile profile = RulesProfile.create("Default", "java"); Rule rule = Rule.create("repo", "key1", "name1").setSeverity(RulePriority.CRITICAL); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java index 086005be0f8..1db080ea3c3 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/CoreMetricsTest.java @@ -32,7 +32,7 @@ public class CoreMetricsTest { @Test public void read_metrics_from_class_reflection() { List<Metric> metrics = CoreMetrics.getMetrics(); - assertThat(metrics).hasSize(152); + assertThat(metrics).hasSize(150); assertThat(metrics).contains(CoreMetrics.NCLOC, CoreMetrics.DIRECTORIES); } |