diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2012-08-08 00:17:54 +0600 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2012-08-08 01:36:54 +0600 |
commit | 4ccfd4e84e152cce4f6bf166f6ea478ebcdaf445 (patch) | |
tree | 993e82d15f8b7bba84f6ea650168df89638065e5 /plugins/sonar-checkstyle-plugin/src | |
parent | 2ef978c162f11c5cee5944327568b69bbdea1142 (diff) | |
download | sonarqube-4ccfd4e84e152cce4f6bf166f6ea478ebcdaf445.tar.gz sonarqube-4ccfd4e84e152cce4f6bf166f6ea478ebcdaf445.zip |
SONAR-3600 Support Checkstyle rules ClassTypeParameterName and MethodTypeParameterName
Diffstat (limited to 'plugins/sonar-checkstyle-plugin/src')
6 files changed, 50 insertions, 15 deletions
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 @@ </parameter>
</parameters>
</rule>
+ <rule>
+ <repositoryKey>checkstyle</repositoryKey>
+ <key>com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterName</key>
+ </rule>
+ <rule>
+ <repositoryKey>checkstyle</repositoryKey>
+ <key>com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterName</key>
+ </rule>
</rules>
-</profile>
\ No newline at end of file +</profile>
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 @@ </parameter>
</parameters>
</rule>
+ <rule>
+ <repositoryKey>checkstyle</repositoryKey>
+ <key>com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterName</key>
+ </rule>
+ <rule>
+ <repositoryKey>checkstyle</repositoryKey>
+ <key>com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterName</key>
+ </rule>
</rules>
-</profile>
\ No newline at end of file +</profile>
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 @@ <name><![CDATA[One Statement Per Line]]></name> <configKey><![CDATA[Checker/TreeWalker/OneStatementPerLine]]></configKey> </rule> + + <rule key="com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterName"> + <priority>MAJOR</priority> + <name><![CDATA[Class Type Parameter Name]]></name> + <configKey><![CDATA[Checker/TreeWalker/ClassTypeParameterName]]></configKey> + + <param key="format" type="REGULAR_EXPRESSION"> + <defaultValue>^[A-Z]$</defaultValue> + </param> + </rule> + + <rule key="com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterName"> + <priority>MAJOR</priority> + <name><![CDATA[Method Type Parameter Name]]></name> + <configKey><![CDATA[Checker/TreeWalker/MethodTypeParameterName]]></configKey> + + <param key="format" type="REGULAR_EXPRESSION"> + <defaultValue>^[A-Z]$</defaultValue> + </param> + </rule> + </rules> 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<Rule> 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() { |