aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2012-08-08 00:17:54 +0600
committerEvgeny Mandrikov <mandrikov@gmail.com>2012-08-08 01:36:54 +0600
commit4ccfd4e84e152cce4f6bf166f6ea478ebcdaf445 (patch)
tree993e82d15f8b7bba84f6ea650168df89638065e5
parent2ef978c162f11c5cee5944327568b69bbdea1142 (diff)
downloadsonarqube-4ccfd4e84e152cce4f6bf166f6ea478ebcdaf445.tar.gz
sonarqube-4ccfd4e84e152cce4f6bf166f6ea478ebcdaf445.zip
SONAR-3600 Support Checkstyle rules ClassTypeParameterName and MethodTypeParameterName
-rw-r--r--plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/profile-sonar-way.xml10
-rw-r--r--plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/profile-sun-conventions.xml10
-rw-r--r--plugins/sonar-checkstyle-plugin/src/main/resources/org/sonar/plugins/checkstyle/rules.xml21
-rw-r--r--plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstyleRuleRepositoryTest.java6
-rw-r--r--plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SonarWayProfileTest.java9
-rw-r--r--plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/SunConventionsProfileTest.java9
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle.properties2
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.naming.ClassTypeParameterName.html1
-rw-r--r--plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/checkstyle/rules/checkstyle/com.puppycrawl.tools.checkstyle.checks.naming.MethodTypeParameterName.html1
9 files changed, 54 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() {
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