From: Evgeny Mandrikov Date: Tue, 7 Aug 2012 18:17:54 +0000 (+0600) Subject: SONAR-3600 Support Checkstyle rules ClassTypeParameterName and MethodTypeParameterName X-Git-Tag: 3.3~349 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=4ccfd4e84e152cce4f6bf166f6ea478ebcdaf445;p=sonarqube.git SONAR-3600 Support Checkstyle rules ClassTypeParameterName and MethodTypeParameterName --- diff --git a/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/profile-sonar-way.xml b/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/profile-sonar-way.xml index d6798e01b1e..1b91689f319 100644 --- a/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/profile-sonar-way.xml +++ b/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/profile-sonar-way.xml @@ -146,5 +146,13 @@ + + checkstyle + com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterName + + + checkstyle + com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterName + - \ No newline at end of file + diff --git a/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/profile-sun-conventions.xml b/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/profile-sun-conventions.xml index 81d18cd226b..9eb0857c211 100644 --- a/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/profile-sun-conventions.xml +++ b/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/profile-sun-conventions.xml @@ -617,5 +617,13 @@ + + checkstyle + com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterName + + + checkstyle + com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterName + - \ No newline at end of file + diff --git a/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/rules.xml b/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/rules.xml index e8de5fb04c7..64033016da6 100644 --- a/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/rules.xml +++ b/plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/rules.xml @@ -1645,4 +1645,25 @@ + + + MAJOR + + + + + ^[A-Z]$ + + + + + MAJOR + + + + + ^[A-Z]$ + + + diff --git a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRuleRepositoryTest.java b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRuleRepositoryTest.java index 06b9ea9b566..b42b99357d8 100644 --- a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRuleRepositoryTest.java +++ b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRuleRepositoryTest.java @@ -26,8 +26,7 @@ import org.sonar.api.rules.XMLRuleParser; import java.util.List; -import static org.hamcrest.Matchers.greaterThan; -import static org.junit.Assert.assertThat; +import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Mockito.mock; public class CheckstyleRuleRepositoryTest { @@ -37,6 +36,7 @@ public class CheckstyleRuleRepositoryTest { ServerFileSystem fileSystem = mock(ServerFileSystem.class); CheckstyleRuleRepository repository = new CheckstyleRuleRepository(fileSystem, new XMLRuleParser()); List rules = repository.createRules(); - assertThat(rules.size(), greaterThan(100)); + assertThat(rules.size()).isEqualTo(129); } + } diff --git a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SonarWayProfileTest.java b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SonarWayProfileTest.java index 8db437da2d5..29c69ed9244 100644 --- a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SonarWayProfileTest.java +++ b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SonarWayProfileTest.java @@ -30,9 +30,7 @@ import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleFinder; import org.sonar.api.utils.ValidationMessages; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.number.OrderingComparisons.greaterThan; -import static org.junit.Assert.assertThat; +import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -44,8 +42,8 @@ public class SonarWayProfileTest { ProfileDefinition sonarWay = new SonarWayProfile(new XMLProfileParser(newRuleFinder(), mock(MetricFinder.class))); ValidationMessages validation = ValidationMessages.create(); RulesProfile profile = sonarWay.createProfile(validation); - assertThat(profile.getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY).size(), greaterThan(1)); - assertThat(validation.hasErrors(), is(false)); + assertThat(profile.getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY).size()).isEqualTo(32); + assertThat(validation.hasErrors()).isFalse(); } private RuleFinder newRuleFinder() { @@ -57,4 +55,5 @@ public class SonarWayProfileTest { }); return ruleFinder; } + } diff --git a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SunConventionsProfileTest.java b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SunConventionsProfileTest.java index 26913a7ae48..dc49069e45e 100644 --- a/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SunConventionsProfileTest.java +++ b/plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SunConventionsProfileTest.java @@ -19,7 +19,6 @@ */ package org.sonar.plugins.checkstyle; -import org.hamcrest.core.Is; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -31,20 +30,20 @@ import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleFinder; import org.sonar.api.utils.ValidationMessages; -import static org.hamcrest.number.OrderingComparisons.greaterThan; -import static org.junit.Assert.assertThat; +import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class SunConventionsProfileTest { + @Test public void shouldCreateProfile() { ProfileDefinition definition = new SunConventionsProfile(new XMLProfileParser(newRuleFinder(), mock(MetricFinder.class))); ValidationMessages validation = ValidationMessages.create(); RulesProfile sunProfile = definition.createProfile(validation); - assertThat(sunProfile.getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY).size(), greaterThan(1)); - assertThat(validation.hasErrors(), Is.is(false)); + assertThat(sunProfile.getActiveRulesByRepository(CheckstyleConstants.REPOSITORY_KEY).size()).isEqualTo(59); + assertThat(validation.hasErrors()).isFalse(); } private RuleFinder newRuleFinder() { diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle.properties index 07491e32255..2f7c1e230a7 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle.properties @@ -338,3 +338,5 @@ rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.sizes.MethodCountCheck.pa rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.sizes.MethodCountCheck.param.maxProtected=maximum allowable number of protected methods. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.sizes.MethodCountCheck.param.maxPublic=maximum allowable number of public methods. rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck.name=One Statement Per Line +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterName=Class Type Parameter Name +rule.checkstyle.com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterName=Method Type Parameter Name diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterName.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterName.html new file mode 100644 index 00000000000..31398fe860b --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterName.html @@ -0,0 +1 @@ +Checks that class parameter names conform to the specified format diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterName.html b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterName.html new file mode 100644 index 00000000000..cfdf3b02410 --- /dev/null +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterName.html @@ -0,0 +1 @@ +Checks that method type parameter names conform to the specified format