From 21374a173c929bd20a717769da582cb28f4a8f6c Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 26 Feb 2014 15:01:09 +0100 Subject: [PATCH] SONAR-5067 Update message displayed when activating already activated rules on a profile --- .../src/main/java/org/sonar/api/profiles/RulesProfile.java | 7 ++++--- .../test/java/org/sonar/api/profiles/RulesProfileTest.java | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) 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 c8ac0082627..d0abfb4bf92 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 @@ -376,9 +376,10 @@ public class RulesProfile implements Cloneable { public boolean apply(ActiveRule input) { return input.getRule().equals(rule); } - })){ - throw new IllegalStateException(String.format("The rule '%s:%s' is already activated on the profile '%s' (language '%s')", - rule.getRepositoryKey(), rule.getKey(), getName(), getLanguage())); + })) { + throw new IllegalStateException(String.format( + "The definition of the profile '%s' (language '%s') contains multiple occurrences of the '%s:%s' rule. The plugin which declares this profile should fix this.", + getName(), getLanguage(), rule.getRepositoryKey(), rule.getKey())); } ActiveRule activeRule = new ActiveRule(); activeRule.setRule(rule); 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 3a31a73b060..79275aa2422 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 @@ -71,7 +71,8 @@ public class RulesProfileTest { profile.activateRule(rule, null); fail(); } catch (Exception e) { - assertThat(e).isInstanceOf(IllegalStateException.class).hasMessage("The rule 'repo:key1' is already activated on the profile 'Default' (language 'java')"); + assertThat(e).isInstanceOf(IllegalStateException.class) + .hasMessage("The definition of the profile 'Default' (language 'java') contains multiple occurrences of the 'repo:key1' rule. The plugin which declares this profile should fix this."); } } } -- 2.39.5