Browse Source

move deprecated rule API to sonar-deprecated

tags/2.6
simonbrandhof 13 years ago
parent
commit
ddcc6272a6
32 changed files with 68 additions and 135 deletions
  1. 5
    0
      plugins/sonar-findbugs-plugin/pom.xml
  2. 1
    1
      plugins/sonar-pmd-plugin/pmd-result.xml
  3. 5
    0
      plugins/sonar-pmd-plugin/pom.xml
  4. 2
    0
      sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractViolationsStaxParser.java
  5. 0
    0
      sonar-deprecated/src/main/java/org/sonar/api/rules/AbstractImportableRulesRepository.java
  6. 0
    0
      sonar-deprecated/src/main/java/org/sonar/api/rules/AbstractRulesRepository.java
  7. 0
    0
      sonar-deprecated/src/main/java/org/sonar/api/rules/ConfigurationExportable.java
  8. 1
    0
      sonar-deprecated/src/main/java/org/sonar/api/rules/ConfigurationImportable.java
  9. 0
    0
      sonar-deprecated/src/main/java/org/sonar/api/rules/RulePriorityMapper.java
  10. 1
    3
      sonar-deprecated/src/main/java/org/sonar/api/rules/RulesManager.java
  11. 1
    3
      sonar-deprecated/src/main/java/org/sonar/api/rules/RulesRepository.java
  12. 0
    0
      sonar-deprecated/src/main/java/org/sonar/api/rules/StandardProfileXmlParser.java
  13. 0
    0
      sonar-deprecated/src/main/java/org/sonar/api/rules/StandardRulesXmlParser.java
  14. 0
    0
      sonar-deprecated/src/main/java/org/sonar/api/rules/xml/Profile.java
  15. 0
    0
      sonar-deprecated/src/main/java/org/sonar/api/rules/xml/Property.java
  16. 0
    0
      sonar-deprecated/src/main/java/org/sonar/api/rules/xml/Rule.java
  17. 0
    0
      sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractViolationsStaxParserTest.java
  18. 0
    0
      sonar-deprecated/src/test/java/org/sonar/api/rules/AnnotatedCheck.java
  19. 0
    0
      sonar-deprecated/src/test/java/org/sonar/api/rules/AnnotatedCheckWithParameters.java
  20. 3
    2
      sonar-deprecated/src/test/java/org/sonar/api/rules/RuleAnnotationUtilsTest.java
  21. 8
    6
      sonar-deprecated/src/test/java/org/sonar/api/rules/RulePriorityTest.java
  22. 9
    6
      sonar-deprecated/src/test/java/org/sonar/api/rules/RuleTest.java
  23. 4
    2
      sonar-deprecated/src/test/java/org/sonar/api/rules/RuleUtilsTest.java
  24. 5
    2
      sonar-deprecated/src/test/java/org/sonar/api/rules/StandardProfileXmlParserTest.java
  25. 4
    3
      sonar-deprecated/src/test/java/org/sonar/api/rules/StandardRuleXmlFormatTest.java
  26. 19
    17
      sonar-deprecated/src/test/java/org/sonar/api/rules/StandardRulesXmlParserTest.java
  27. 0
    0
      sonar-deprecated/src/test/resources/org/sonar/api/rules/StandardRuleXmlFormatTest/deprecated.xml
  28. 0
    0
      sonar-deprecated/src/test/resources/org/sonar/api/rules/StandardRuleXmlFormatTest/rules.xml
  29. 0
    0
      sonar-deprecated/src/test/resources/org/sonar/api/rules/StandardRuleXmlFormatTest/utf8.xml
  30. 0
    0
      sonar-deprecated/src/test/resources/org/sonar/api/rules/test_profile.xml
  31. 0
    0
      sonar-deprecated/src/test/resources/org/sonar/api/rules/test_profile_name_null.xml
  32. 0
    90
      sonar-plugin-api/src/test/java/org/sonar/api/FakePlugin.java

+ 5
- 0
plugins/sonar-findbugs-plugin/pom.xml View File

@@ -23,6 +23,11 @@
<artifactId>sonar-plugin-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-deprecated</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>

+ 1
- 1
plugins/sonar-pmd-plugin/pmd-result.xml View File

@@ -1,3 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<pmd version="4.2.5" timestamp="2010-09-12T21:47:59.064">
<pmd version="4.2.5" timestamp="2010-09-14T13:20:30.108">
</pmd>

+ 5
- 0
plugins/sonar-pmd-plugin/pom.xml View File

@@ -18,6 +18,11 @@
</properties>

<dependencies>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-deprecated</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-plugin-api</artifactId>

sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractViolationsStaxParser.java → sonar-deprecated/src/main/java/org/sonar/api/batch/AbstractViolationsStaxParser.java View File

@@ -43,7 +43,9 @@ import org.sonar.api.utils.StaxParser;

/**
* @since 1.10
* @deprecated since 2.3. Too much "black-box".
*/
@Deprecated
public abstract class AbstractViolationsStaxParser {

protected RulesManager rulesManager;

sonar-plugin-api/src/main/java/org/sonar/api/rules/AbstractImportableRulesRepository.java → sonar-deprecated/src/main/java/org/sonar/api/rules/AbstractImportableRulesRepository.java View File


sonar-plugin-api/src/main/java/org/sonar/api/rules/AbstractRulesRepository.java → sonar-deprecated/src/main/java/org/sonar/api/rules/AbstractRulesRepository.java View File


sonar-plugin-api/src/main/java/org/sonar/api/rules/ConfigurationExportable.java → sonar-deprecated/src/main/java/org/sonar/api/rules/ConfigurationExportable.java View File


sonar-plugin-api/src/main/java/org/sonar/api/rules/ConfigurationImportable.java → sonar-deprecated/src/main/java/org/sonar/api/rules/ConfigurationImportable.java View File

@@ -20,6 +20,7 @@
package org.sonar.api.rules;
import java.util.List;
import org.sonar.api.rules.Rule;
@Deprecated
public interface ConfigurationImportable {

sonar-plugin-api/src/main/java/org/sonar/api/rules/RulePriorityMapper.java → sonar-deprecated/src/main/java/org/sonar/api/rules/RulePriorityMapper.java View File


sonar-plugin-api/src/main/java/org/sonar/api/rules/RulesManager.java → sonar-deprecated/src/main/java/org/sonar/api/rules/RulesManager.java View File

@@ -28,9 +28,7 @@ import java.util.Map;
import java.util.Set;

/**
* Manage and access rules defined in Sonar.
*
* @deprecated UGLY COMPONENT - WILL BE COMPLETELY REFACTORED IN SONAR 2.3
* @deprecated since 2.3
*/
@Deprecated
public abstract class RulesManager {

sonar-plugin-api/src/main/java/org/sonar/api/rules/RulesRepository.java → sonar-deprecated/src/main/java/org/sonar/api/rules/RulesRepository.java View File

@@ -27,9 +27,7 @@ import org.sonar.api.resources.Language;
import java.util.List;
/**
* The interface to implement to create a repository of rules
*
* @param <LANG>
* @deprecated since 2.3
*/
@Deprecated
public interface RulesRepository<LANG extends Language> extends BatchExtension, ServerExtension {

sonar-plugin-api/src/main/java/org/sonar/api/rules/StandardProfileXmlParser.java → sonar-deprecated/src/main/java/org/sonar/api/rules/StandardProfileXmlParser.java View File


sonar-plugin-api/src/main/java/org/sonar/api/rules/StandardRulesXmlParser.java → sonar-deprecated/src/main/java/org/sonar/api/rules/StandardRulesXmlParser.java View File


sonar-plugin-api/src/main/java/org/sonar/api/rules/xml/Profile.java → sonar-deprecated/src/main/java/org/sonar/api/rules/xml/Profile.java View File


sonar-plugin-api/src/main/java/org/sonar/api/rules/xml/Property.java → sonar-deprecated/src/main/java/org/sonar/api/rules/xml/Property.java View File


sonar-plugin-api/src/main/java/org/sonar/api/rules/xml/Rule.java → sonar-deprecated/src/main/java/org/sonar/api/rules/xml/Rule.java View File


sonar-plugin-api/src/test/java/org/sonar/api/batch/AbstractViolationsStaxParserTest.java → sonar-deprecated/src/test/java/org/sonar/api/batch/AbstractViolationsStaxParserTest.java View File


sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotatedCheck.java → sonar-deprecated/src/test/java/org/sonar/api/rules/AnnotatedCheck.java View File


sonar-plugin-api/src/test/java/org/sonar/api/rules/AnnotatedCheckWithParameters.java → sonar-deprecated/src/test/java/org/sonar/api/rules/AnnotatedCheckWithParameters.java View File


sonar-plugin-api/src/test/java/org/sonar/api/rules/RuleAnnotationUtilsTest.java → sonar-deprecated/src/test/java/org/sonar/api/rules/RuleAnnotationUtilsTest.java View File

@@ -19,6 +19,7 @@
*/
package org.sonar.api.rules;

import org.hamcrest.core.Is;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.nullValue;
@@ -38,8 +39,8 @@ public class RuleAnnotationUtilsTest {
assertThat(rule.getConfigKey(), nullValue());
assertThat(rule.getParams().size(), is(0));
assertThat(rule.getDescription(), is("Description"));
assertThat(rule.getCardinality(), is(Rule.Cardinality.SINGLE));
assertThat(rule.getRulesCategory().getName(), is(Iso9126RulesCategories.RELIABILITY.getName()));
assertThat(rule.getCardinality(), Is.is(Rule.Cardinality.SINGLE));
assertThat(rule.getRulesCategory().getName(), Is.is(Iso9126RulesCategories.RELIABILITY.getName()));
}

@Test

sonar-plugin-api/src/test/java/org/sonar/api/rules/RulePriorityTest.java → sonar-deprecated/src/test/java/org/sonar/api/rules/RulePriorityTest.java View File

@@ -20,18 +20,20 @@
package org.sonar.api.rules;

import static junit.framework.Assert.assertEquals;

import junit.framework.Assert;
import org.junit.Test;

public class RulePriorityTest {

@Test
public void testValueOfString() {
assertEquals(RulePriority.INFO, RulePriority.valueOfString("info"));
assertEquals(RulePriority.MAJOR, RulePriority.valueOfString("MAJOR"));
assertEquals(RulePriority.MAJOR, RulePriority.valueOfString("ERROR"));
assertEquals(RulePriority.INFO, RulePriority.valueOfString("WARNING"));
assertEquals(RulePriority.MAJOR, RulePriority.valueOfString("ErRor"));
assertEquals(RulePriority.INFO, RulePriority.valueOfString("WaRnInG"));
Assert.assertEquals(RulePriority.INFO, RulePriority.valueOfString("info"));
Assert.assertEquals(RulePriority.MAJOR, RulePriority.valueOfString("MAJOR"));
Assert.assertEquals(RulePriority.MAJOR, RulePriority.valueOfString("ERROR"));
Assert.assertEquals(RulePriority.INFO, RulePriority.valueOfString("WARNING"));
Assert.assertEquals(RulePriority.MAJOR, RulePriority.valueOfString("ErRor"));
Assert.assertEquals(RulePriority.INFO, RulePriority.valueOfString("WaRnInG"));
}

@Test(expected = IllegalArgumentException.class)

sonar-plugin-api/src/test/java/org/sonar/api/rules/RuleTest.java → sonar-deprecated/src/test/java/org/sonar/api/rules/RuleTest.java View File

@@ -21,6 +21,9 @@ package org.sonar.api.rules;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;

import org.hamcrest.core.Is;
import org.junit.Assert;
import org.junit.Test;

import java.util.Arrays;
@@ -32,7 +35,7 @@ public class RuleTest {
public void descriptionShouldBeCleaned() {
Rule rule = new Rule();
rule.setDescription(" my description ");
assertEquals("my description", rule.getDescription());
Assert.assertEquals("my description", rule.getDescription());

rule.setDescription(null);
assertNull(rule.getDescription());
@@ -68,19 +71,19 @@ public class RuleTest {
@Test
public void defaultPriorityIsMajor() {
Rule rule = new Rule();
assertThat(rule.getPriority(), is(RulePriority.MAJOR));
assertThat(rule.getPriority(), Is.is(RulePriority.MAJOR));

rule = new Rule("name", "key");
assertThat(rule.getPriority(), is(RulePriority.MAJOR));
assertThat(rule.getPriority(), Is.is(RulePriority.MAJOR));

rule = new Rule("pkey", "key", "name", Iso9126RulesCategories.EFFICIENCY, null, null);
assertThat(rule.getPriority(), is(RulePriority.MAJOR));
assertThat(rule.getPriority(), Is.is(RulePriority.MAJOR));

rule.setPriority(RulePriority.BLOCKER);
assertThat(rule.getPriority(), is(RulePriority.BLOCKER));
assertThat(rule.getPriority(), Is.is(RulePriority.BLOCKER));

rule.setPriority(null);
assertThat(rule.getPriority(), is(RulePriority.MAJOR));
assertThat(rule.getPriority(), Is.is(RulePriority.MAJOR));
}



sonar-plugin-api/src/test/java/org/sonar/api/rules/RuleUtilsTest.java → sonar-deprecated/src/test/java/org/sonar/api/rules/RuleUtilsTest.java View File

@@ -27,6 +27,8 @@ import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.mockito.Matchers;
import org.sonar.api.CoreProperties;

import java.util.Map;
@@ -36,7 +38,7 @@ public class RuleUtilsTest {
@Test
public void getPriorityWeights() {
Configuration conf = mock(Configuration.class);
when(conf.getString(eq(CoreProperties.CORE_RULE_WEIGHTS_PROPERTY), anyString())).thenReturn("info=0;minor=1;major=2;critical=5;blocker=10");
when(conf.getString(Matchers.eq(CoreProperties.CORE_RULE_WEIGHTS_PROPERTY), anyString())).thenReturn("info=0;minor=1;major=2;critical=5;blocker=10");

final Map<RulePriority, Integer> map = RuleUtils.getPriorityWeights(conf);

@@ -50,7 +52,7 @@ public class RuleUtilsTest {
@Test
public void loadMissingWeights() {
Configuration conf = mock(Configuration.class);
when(conf.getString(eq(CoreProperties.CORE_RULE_WEIGHTS_PROPERTY), anyString())).thenReturn("foo=0;bar=1;CRITICAL=5");
when(conf.getString(Matchers.eq(CoreProperties.CORE_RULE_WEIGHTS_PROPERTY), anyString())).thenReturn("foo=0;bar=1;CRITICAL=5");

final Map<RulePriority, Integer> map = RuleUtils.getPriorityWeights(conf);


sonar-plugin-api/src/test/java/org/sonar/api/rules/StandardProfileXmlParserTest.java → sonar-deprecated/src/test/java/org/sonar/api/rules/StandardProfileXmlParserTest.java View File

@@ -22,6 +22,9 @@ package org.sonar.api.rules;
import org.apache.commons.io.IOUtils;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;

import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Test;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.rules.xml.Profile;
@@ -107,7 +110,7 @@ public class StandardProfileXmlParserTest {
RulesProfile profile = standardProfileXmlParser.importConfiguration(IOUtils.toString(input));
List<ActiveRule> results = profile.getActiveRules();

assertThat("Sonar way", is(profile.getName()));
assertThat("Sonar way", CoreMatchers.is(profile.getName()));
assertThat(results.size(), is(activeRulesExpected.size()));
assertActiveRulesAreEquals(results, activeRulesExpected);
}
@@ -156,7 +159,7 @@ public class StandardProfileXmlParserTest {
ActiveRule activeRule2 = activeRules2.get(i);
assertTrue(activeRule1.getRule().equals(activeRule2.getRule()) && activeRule1.getPriority().equals(activeRule2.getPriority()));

assertEquals(activeRule1.getActiveRuleParams().size(), (activeRule2.getActiveRuleParams().size()));
Assert.assertEquals(activeRule1.getActiveRuleParams().size(), (activeRule2.getActiveRuleParams().size()));
for (int j = 0; j < activeRule1.getActiveRuleParams().size(); j++) {
ActiveRuleParam activeRuleParam1 = activeRule1.getActiveRuleParams().get(j);
ActiveRuleParam activeRuleParam2 = activeRule2.getActiveRuleParams().get(j);

sonar-plugin-api/src/test/java/org/sonar/api/rules/StandardRuleXmlFormatTest.java → sonar-deprecated/src/test/java/org/sonar/api/rules/StandardRuleXmlFormatTest.java View File

@@ -19,6 +19,7 @@
*/
package org.sonar.api.rules;

import org.hamcrest.core.Is;
import org.junit.Test;
import org.sonar.api.utils.SonarException;

@@ -40,8 +41,8 @@ public class StandardRuleXmlFormatTest {
Rule rule = rules.get(0);
assertThat(rule.getName(), is("Local Variable Name"));
assertThat(rule.getDescription(), is("Checks that local, non-final variable names conform to a format specified by the format property."));
assertThat(rule.getPriority(), is(RulePriority.BLOCKER));
assertThat(rule.getCardinality(), is(Rule.Cardinality.MULTIPLE));
assertThat(rule.getPriority(), Is.is(RulePriority.BLOCKER));
assertThat(rule.getCardinality(), Is.is(Rule.Cardinality.MULTIPLE));
assertThat(rule.getConfigKey(), is("Checker/TreeWalker/LocalVariableName"));

assertThat(rule.getParams().size(), is(2));
@@ -83,7 +84,7 @@ public class StandardRuleXmlFormatTest {
List<Rule> rules = StandardRuleXmlFormat.parseXml(getClass().getResourceAsStream("/org/sonar/api/rules/StandardRuleXmlFormatTest/deprecated.xml"));
assertThat(rules.size(), is(1));
Rule rule = rules.get(0);
assertThat(rule.getPriority(), is(RulePriority.CRITICAL));
assertThat(rule.getPriority(), Is.is(RulePriority.CRITICAL));
assertThat(rule.getKey(), is("org.sonar.it.checkstyle.MethodsCountCheck"));
assertThat(rule.getParam("minMethodsCount"), not(nullValue()));
}

sonar-plugin-api/src/test/java/org/sonar/api/rules/StandardRulesXmlParserTest.java → sonar-deprecated/src/test/java/org/sonar/api/rules/StandardRulesXmlParserTest.java View File

@@ -23,6 +23,8 @@ import org.apache.commons.io.IOUtils;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.*;

import org.junit.Assert;
import org.junit.Test;

import java.util.List;
@@ -36,14 +38,14 @@ public class StandardRulesXmlParserTest {
assertEquals(1, rules.size());

Rule rule = rules.get(0);
assertEquals("key1", rule.getKey());
assertEquals("my name", rule.getName());
assertEquals("my_config_key", rule.getConfigKey());
assertEquals("my description", rule.getDescription());
assertEquals(2, rule.getParams().size());
assertEquals("param1", rule.getParams().get(0).getKey());
assertEquals("s", rule.getParams().get(0).getType());
assertEquals("param description", rule.getParams().get(0).getDescription());
Assert.assertEquals("key1", rule.getKey());
Assert.assertEquals("my name", rule.getName());
Assert.assertEquals("my_config_key", rule.getConfigKey());
Assert.assertEquals("my description", rule.getDescription());
Assert.assertEquals(2, rule.getParams().size());
Assert.assertEquals("param1", rule.getParams().get(0).getKey());
Assert.assertEquals("s", rule.getParams().get(0).getType());
Assert.assertEquals("param description", rule.getParams().get(0).getDescription());
}

@Test
@@ -52,7 +54,7 @@ public class StandardRulesXmlParserTest {
String xml = "<rules><rule><category name='cat1' /></rule></rules>";
List<Rule> rules = parser.parse(xml);
assertNotNull(rules.get(0).getRulesCategory());
assertEquals("cat1", rules.get(0).getRulesCategory().getName());
Assert.assertEquals("cat1", rules.get(0).getRulesCategory().getName());
assertNull(rules.get(0).getRulesCategory().getId());
assertNull(rules.get(0).getRulesCategory().getDescription());
}
@@ -63,7 +65,7 @@ public class StandardRulesXmlParserTest {
String xml = "<rules><rule key='1' priority='CRITICAL'><category name='cat1'/></rule></rules>";
List<Rule> rules = parser.parse(xml);
assertNotNull(rules.get(0).getRulesCategory());
assertEquals(RulePriority.CRITICAL, rules.get(0).getPriority());
Assert.assertEquals(RulePriority.CRITICAL, rules.get(0).getPriority());
assertNull(rules.get(0).getRulesCategory().getId());
assertNull(rules.get(0).getRulesCategory().getDescription());
}
@@ -73,7 +75,7 @@ public class StandardRulesXmlParserTest {
StandardRulesXmlParser parser = new StandardRulesXmlParser();
String xml = "<rules><rule key='1'><category name='cat1'/></rule></rules>";
List<Rule> rules = parser.parse(xml);
assertEquals(RulePriority.MAJOR, rules.get(0).getPriority());
Assert.assertEquals(RulePriority.MAJOR, rules.get(0).getPriority());
}

@Test
@@ -82,8 +84,8 @@ public class StandardRulesXmlParserTest {
String xml = "<rules><rule key='key1' category='cat1' /><rule key='key2' category='cat1' /></rules>";
List<Rule> rules = parser.parse(xml);
assertEquals(2, rules.size());
assertEquals("key1", rules.get(0).getKey());
assertEquals("key2", rules.get(1).getKey());
Assert.assertEquals("key1", rules.get(0).getKey());
Assert.assertEquals("key2", rules.get(1).getKey());
}

@Test
@@ -102,7 +104,7 @@ public class StandardRulesXmlParserTest {
String xml = "<rules><rule key='key1' category='cat1'><description> <![CDATA[<xml> </nodes> and accents Žˆ˜ ]]> </description></rule></rules>";
List<Rule> rules = parser.parse(xml);
assertEquals(1, rules.size());
assertEquals("<xml> </nodes> and accents Žˆ˜", rules.get(0).getDescription());
Assert.assertEquals("<xml> </nodes> and accents Žˆ˜", rules.get(0).getDescription());
}

@Test
@@ -113,9 +115,9 @@ public class StandardRulesXmlParserTest {
assertEquals(1, rules.size());

Rule rule = rules.get(0);
assertEquals("key1", rule.getKey());
assertEquals(1, rule.getParams().size());
assertEquals("param1", rule.getParams().get(0).getKey());
Assert.assertEquals("key1", rule.getKey());
Assert.assertEquals(1, rule.getParams().size());
Assert.assertEquals("param1", rule.getParams().get(0).getKey());
}

@Test

sonar-plugin-api/src/test/resources/org/sonar/api/rules/StandardRuleXmlFormatTest/deprecated.xml → sonar-deprecated/src/test/resources/org/sonar/api/rules/StandardRuleXmlFormatTest/deprecated.xml View File


sonar-plugin-api/src/test/resources/org/sonar/api/rules/StandardRuleXmlFormatTest/rules.xml → sonar-deprecated/src/test/resources/org/sonar/api/rules/StandardRuleXmlFormatTest/rules.xml View File


sonar-plugin-api/src/test/resources/org/sonar/api/rules/StandardRuleXmlFormatTest/utf8.xml → sonar-deprecated/src/test/resources/org/sonar/api/rules/StandardRuleXmlFormatTest/utf8.xml View File


sonar-plugin-api/src/test/resources/org/sonar/api/rules/test_profile.xml → sonar-deprecated/src/test/resources/org/sonar/api/rules/test_profile.xml View File


sonar-plugin-api/src/test/resources/org/sonar/api/rules/test_profile_name_null.xml → sonar-deprecated/src/test/resources/org/sonar/api/rules/test_profile_name_null.xml View File


+ 0
- 90
sonar-plugin-api/src/test/java/org/sonar/api/FakePlugin.java View File

@@ -1,90 +0,0 @@
/*
* Sonar, open source software quality management tool.
* Copyright (C) 2009 SonarSource SA
* mailto:contact AT sonarsource DOT com
*
* Sonar is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* Sonar is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Sonar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
package org.sonar.api;

import java.util.ArrayList;
import java.util.List;

import org.sonar.api.batch.Sensor;
import org.sonar.api.resources.AbstractLanguage;
import org.sonar.api.resources.Language;
import org.sonar.api.rules.RulesRepository;

public class FakePlugin implements Plugin {
private Language lang;
private String key;
private Class<? extends RulesRepository> rulesClass;
private Class<? extends Sensor> sensor = null;

public FakePlugin(String key, Language lang) {
this.lang = lang;
this.key = key;
}

public FakePlugin(String key, Language lang, Class<? extends RulesRepository> rulesClass) {
this.lang = lang;
this.key = key;
this.rulesClass = rulesClass;
}

public FakePlugin(String key, Language lang, Class<? extends RulesRepository> rulesClass, Class<? extends Sensor> sensor) {
this.lang = lang;
this.key = key;
this.rulesClass = rulesClass;
this.sensor = sensor;
}

FakePlugin() {
this("fake", new AbstractLanguage("fake", "Fake") {
public String[] getFileSuffixes() {
return new String[0];
}
});
}

public String getKey() {
return key;
}

public String getName() {
return null;
}

public String getDescription() {
return null;
}

public Language getLanguage() {
return lang;
}

public List<Class<? extends Extension>> getExtensions() {
List<Class<? extends Extension>> list = new ArrayList<Class<? extends Extension>>();
if (sensor != null) {
list.add(sensor);
}
if (rulesClass != null) {
list.add(rulesClass);
}
return list;
}


}

Loading…
Cancel
Save