From 4ccfd4e84e152cce4f6bf166f6ea478ebcdaf445 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Wed, 8 Aug 2012 00:17:54 +0600 Subject: SONAR-3600 Support Checkstyle rules ClassTypeParameterName and MethodTypeParameterName --- .../sonar/plugins/checkstyle/profile-sonar-way.xml | 10 +++++++++- .../plugins/checkstyle/profile-sun-conventions.xml | 10 +++++++++- .../org/sonar/plugins/checkstyle/rules.xml | 21 +++++++++++++++++++++ .../checkstyle/CheckstyleRuleRepositoryTest.java | 6 +++--- .../plugins/checkstyle/SonarWayProfileTest.java | 9 ++++----- .../checkstyle/SunConventionsProfileTest.java | 9 ++++----- 6 files changed, 50 insertions(+), 15 deletions(-) (limited to 'plugins/sonar-checkstyle-plugin/src') 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() { -- cgit v1.2.3