Browse Source

SONAR-1898 Introduce new entry point - SonarPlugin

tags/2.8
Evgeny Mandrikov 13 years ago
parent
commit
d4bb3b72f9
19 changed files with 215 additions and 192 deletions
  1. 3
    14
      plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java
  2. 3
    3
      plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstylePluginTest.java
  3. 1
    18
      plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaPlugin.java
  4. 2
    19
      plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
  5. 2
    14
      plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java
  6. 2
    19
      plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java
  7. 1
    18
      plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java
  8. 33
    0
      plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/DesignPluginTest.java
  9. 1
    14
      plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java
  10. 34
    0
      plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsPluginTest.java
  11. 1
    17
      plugins/sonar-googleanalytics-plugin/src/main/java/org/sonar/plugins/googleanalytics/GoogleAnalyticsPlugin.java
  12. 7
    19
      plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdPlugin.java
  13. 35
    0
      plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdPluginTest.java
  14. 2
    19
      plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java
  15. 2
    5
      plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/SquidPluginTest.java
  16. 1
    13
      plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/SurefirePlugin.java
  17. 35
    0
      plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/SurefirePluginTest.java
  18. 1
    0
      sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java
  19. 49
    0
      sonar-plugin-api/src/main/java/org/sonar/api/SonarPlugin.java

+ 3
- 14
plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstylePlugin.java View File

@@ -19,6 +19,8 @@
*/
package org.sonar.plugins.checkstyle;

import org.sonar.api.SonarPlugin;

import org.sonar.api.CoreProperties;
import org.sonar.api.Plugin;
import org.sonar.api.Properties;
@@ -35,20 +37,7 @@ import java.util.List;
+ "This property allows to configure all those filters with a native XML format."
+ " See <a href='http://checkstyle.sourceforge.net/config.html'>Checkstyle configuration page</a> to get more information on those filters.",
project = false, global = true) })
public class CheckstylePlugin implements Plugin {

public String getKey() {
return CoreProperties.CHECKSTYLE_PLUGIN;
}

public String getName() {
return CheckstyleConstants.PLUGIN_NAME;
}

public String getDescription() {
return "Checkstyle is a rule engine that helps programmers writing Java code that adheres to a coding standard. " +
"You can find more by going to the <a href='http://checkstyle.sourceforge.net'>Checkstyle web site</a>.";
}
public class CheckstylePlugin extends SonarPlugin {

public List getExtensions() {
return Arrays.asList(

+ 3
- 3
plugins/sonar-checkstyle-plugin/src/test/java/org/sonar/plugins/checkstyle/CheckstylePluginTest.java View File

@@ -19,15 +19,15 @@
*/
package org.sonar.plugins.checkstyle;

import org.junit.Test;

import static org.hamcrest.number.OrderingComparisons.greaterThan;
import static org.junit.Assert.assertThat;

import org.junit.Test;

public class CheckstylePluginTest {

@Test
public void getSonarWayProfileDefinition() {
public void testGetExtensions() {
CheckstylePlugin plugin = new CheckstylePlugin();
assertThat(plugin.getExtensions().size(), greaterThan(1));
}

+ 1
- 18
plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaPlugin.java View File

@@ -38,19 +38,7 @@ import java.util.List;
description = "Maximum memory to pass to JVM of Cobertura processes",
project = true,
global = true) })
public class CoberturaPlugin implements Plugin {

public String getKey() {
return CoreProperties.COBERTURA_PLUGIN;
}

public String getName() {
return "Cobertura";
}

public String getDescription() {
return "Cobertura is a tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of Java program are lacking test coverage. You can find more by going to the <a href='http://cobertura.sourceforge.net'>Cobertura web site</a>.";
}
public class CoberturaPlugin extends SonarPlugin {

public List<Class<? extends Extension>> getExtensions() {
List<Class<? extends Extension>> list = new ArrayList<Class<? extends Extension>>();
@@ -59,9 +47,4 @@ public class CoberturaPlugin implements Plugin {
list.add(CoberturaMavenInitializer.class);
return list;
}

@Override
public String toString() {
return getKey();
}
}

+ 2
- 19
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java View File

@@ -21,7 +21,7 @@ package org.sonar.plugins.core;

import com.google.common.collect.Lists;
import org.sonar.api.CoreProperties;
import org.sonar.api.Plugin;
import org.sonar.api.SonarPlugin;
import org.sonar.api.Properties;
import org.sonar.api.Property;
import org.sonar.api.checks.NoSonarFilter;
@@ -155,19 +155,7 @@ import java.util.List;
defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_5
)
})
public class CorePlugin implements Plugin {

public String getKey() {
return CoreProperties.CORE_PLUGIN;
}

public String getName() {
return "General";
}

public String getDescription() {
return "";
}
public class CorePlugin extends SonarPlugin {

public List getExtensions() {
List extensions = Lists.newLinkedList();
@@ -238,9 +226,4 @@ public class CorePlugin implements Plugin {

return extensions;
}

@Override
public String toString() {
return getKey();
}
}

+ 2
- 14
plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdPlugin.java View File

@@ -20,9 +20,9 @@
package org.sonar.plugins.cpd;

import org.sonar.api.CoreProperties;
import org.sonar.api.Plugin;
import org.sonar.api.Properties;
import org.sonar.api.Property;
import org.sonar.api.SonarPlugin;
import org.sonar.plugins.cpd.decorators.DuplicationDensityDecorator;
import org.sonar.plugins.cpd.decorators.SumDuplicationsDecorator;

@@ -64,19 +64,7 @@ import java.util.List;
module = true,
global = true)
})
public class CpdPlugin implements Plugin {

public String getKey() {
return CoreProperties.CPD_PLUGIN;
}

public String getName() {
return "Duplications";
}

public String getDescription() {
return "Find duplicated source code within project.";
}
public class CpdPlugin extends SonarPlugin {

public List getExtensions() {
return Arrays.asList(CpdSensor.class, SumDuplicationsDecorator.class, DuplicationDensityDecorator.class, JavaCpdMapping.class);

+ 2
- 19
plugins/sonar-dbcleaner-plugin/src/main/java/org/sonar/plugins/dbcleaner/DbCleanerPlugin.java View File

@@ -19,9 +19,9 @@
*/
package org.sonar.plugins.dbcleaner;

import org.sonar.api.Plugin;
import org.sonar.api.Properties;
import org.sonar.api.Property;
import org.sonar.api.SonarPlugin;
import org.sonar.plugins.dbcleaner.api.DbCleanerConstants;
import org.sonar.plugins.dbcleaner.period.DefaultPeriodCleaner;
import org.sonar.plugins.dbcleaner.period.PeriodPurge;
@@ -43,24 +43,7 @@ import java.util.List;
@Property(key = DbCleanerConstants.MONTHS_BEFORE_DELETING_ALL_SNAPSHOTS, defaultValue = DbCleanerConstants.FIVE_YEARS,
name = "Number of months before starting to delete all remaining snapshots",
description = "After this number of months, all snapshots are fully deleted.", global = true, project = true)})
public final class DbCleanerPlugin implements Plugin {

@Override
public String toString() {
return DbCleanerConstants.PLUGIN_NAME;
}

public String getKey() {
return DbCleanerConstants.PLUGIN_KEY;
}

public String getName() {
return DbCleanerConstants.PLUGIN_NAME;
}

public String getDescription() {
return "The DbCleaner optimizes the Sonar DB performances by removing old and useless quality snapshots.";
}
public final class DbCleanerPlugin extends SonarPlugin {

public List getExtensions() {
return Arrays.asList(

+ 1
- 18
plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/DesignPlugin.java View File

@@ -40,19 +40,7 @@ import java.util.List;
project = true,
global = true)
})
public class DesignPlugin implements Plugin {

public String getKey() {
return "design";
}

public String getName() {
return "Design";
}

public String getDescription() {
return "";
}
public class DesignPlugin extends SonarPlugin {

public List<Class<? extends Extension>> getExtensions() {
List<Class<? extends Extension>> extensions = new ArrayList<Class<? extends Extension>>();
@@ -75,9 +63,4 @@ public class DesignPlugin implements Plugin {

return extensions;
}

@Override
public String toString() {
return getKey();
}
}

+ 33
- 0
plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/DesignPluginTest.java View File

@@ -0,0 +1,33 @@
/*
* Sonar, open source software quality management tool.
* Copyright (C) 2008-2011 SonarSource
* 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.plugins.design;

import static org.hamcrest.number.OrderingComparisons.greaterThan;
import static org.junit.Assert.assertThat;
import org.junit.Test;

public class DesignPluginTest {

@Test
public void getExtensions() {
DesignPlugin plugin = new DesignPlugin();
assertThat(plugin.getExtensions().size(), greaterThan(1));
}
}

+ 1
- 14
plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsPlugin.java View File

@@ -39,20 +39,7 @@ import java.util.List;
description = "Specifies the amount of time, in milliseconds, that FindBugs may run before it is assumed to be hung and is terminated. " +
"The default is 600,000 milliseconds, which is ten minutes.",
project = true, module = true, global = true) })
public class FindbugsPlugin implements Plugin {

public String getKey() {
return CoreProperties.FINDBUGS_PLUGIN;
}

public String getName() {
return "Findbugs";
}

public String getDescription() {
return "FindBugs is a program that uses static analysis to look for bugs in Java code. It can detect a variety of common coding mistakes, " +
"including thread synchronization problems, misuse of API methods... You can find more by going to the <a href='http://findbugs.sourceforge.net'>Findbugs web site</a>.";
}
public class FindbugsPlugin extends SonarPlugin {

public List<Class<? extends Extension>> getExtensions() {
List<Class<? extends Extension>> list = new ArrayList<Class<? extends Extension>>();

+ 34
- 0
plugins/sonar-findbugs-plugin/src/test/java/org/sonar/plugins/findbugs/FindbugsPluginTest.java View File

@@ -0,0 +1,34 @@
/*
* Sonar, open source software quality management tool.
* Copyright (C) 2008-2011 SonarSource
* 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.plugins.findbugs;

import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertThat;

import org.junit.Test;

public class FindbugsPluginTest {

@Test
public void testGetExtensions() {
assertThat(new FindbugsPlugin().getExtensions().size(), greaterThan(1));
}

}

+ 1
- 17
plugins/sonar-googleanalytics-plugin/src/main/java/org/sonar/plugins/googleanalytics/GoogleAnalyticsPlugin.java View File

@@ -30,19 +30,7 @@ import java.util.List;
name = "Account key",
description = "Example : UA-1234567-8")
})
public class GoogleAnalyticsPlugin implements Plugin {

public String getKey() {
return CoreProperties.GOOGLE_ANALYTICS_PLUGIN;
}

public String getName() {
return "Google analytics";
}

public String getDescription() {
return "Google analytics is a tool that collects data on the traffic of web sites and then, through a powerful interface, enables to get reporting, segmentation, chart, .. on the traffic. You can find more by going to the <a href='http://www.google.com/analytics/'>Google analytics web site</a>.";
}
public class GoogleAnalyticsPlugin extends SonarPlugin {

public List<Class<? extends Extension>> getExtensions() {
List<Class<? extends Extension>> list = new ArrayList<Class<? extends Extension>>();
@@ -50,8 +38,4 @@ public class GoogleAnalyticsPlugin implements Plugin {
return list;
}

@Override
public String toString() {
return getKey();
}
}

+ 7
- 19
plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdPlugin.java View File

@@ -19,33 +19,21 @@
*/
package org.sonar.plugins.pmd;

import org.sonar.api.SonarPlugin;

import java.util.Arrays;
import java.util.List;

import org.sonar.api.Plugin;

public class PmdPlugin implements Plugin {

public String getKey() {
return PmdConstants.PLUGIN_KEY;
}

public String getName() {
return PmdConstants.PLUGIN_NAME;
}

public String getDescription() {
return "PMD is a tool that looks for potential problems like possible bugs, dead code, suboptimal code, overcomplicated expressions or duplicate code. You can find more by going to the <a href='http://pmd.sourceforge.net'>PMD web site</a>.";
}
public class PmdPlugin extends SonarPlugin {

public List getExtensions() {
return Arrays.asList(
PmdSensor.class,
PmdConfiguration.class,
PmdExecutor.class,
PmdSensor.class,
PmdConfiguration.class,
PmdExecutor.class,
PmdRuleRepository.class,
PmdProfileExporter.class,
PmdProfileImporter.class,
PmdProfileImporter.class,
SonarWayProfile.class,
SonarWayWithFindbugsProfile.class,
SunConventionsProfile.class

+ 35
- 0
plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdPluginTest.java View File

@@ -0,0 +1,35 @@
/*
* Sonar, open source software quality management tool.
* Copyright (C) 2008-2011 SonarSource
* 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.plugins.pmd;

import static org.hamcrest.number.OrderingComparisons.greaterThan;
import static org.junit.Assert.assertThat;

import org.junit.Test;

public class PmdPluginTest {

@Test
public void testGetExtensions() {
PmdPlugin plugin = new PmdPlugin();
assertThat(plugin.getExtensions().size(), greaterThan(1));
}

}

+ 2
- 19
plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/SquidPlugin.java View File

@@ -19,10 +19,9 @@
*/
package org.sonar.plugins.squid;

import org.sonar.api.CoreProperties;
import org.sonar.api.Plugin;
import org.sonar.api.Properties;
import org.sonar.api.Property;
import org.sonar.api.SonarPlugin;
import org.sonar.plugins.squid.decorators.*;

import java.util.Arrays;
@@ -44,19 +43,7 @@ import java.util.List;
+ "The best example is a logger used by all methods of a class. " +
"All field names to exclude from LCOM4 computation must be separated by a comma.",
project = true, global = true)})
public class SquidPlugin implements Plugin {

public String getKey() {
return CoreProperties.SQUID_PLUGIN;
}

public String getName() {
return "Squid";
}

public String getDescription() {
return "Squid collects standard metrics on source code, such as lines of code, cyclomatic complexity, documentation level...";
}
public class SquidPlugin extends SonarPlugin {

public List getExtensions() {
return Arrays.asList(SquidSensor.class, SquidRuleRepository.class, JavaSourceImporter.class,
@@ -64,8 +51,4 @@ public class SquidPlugin implements Plugin {
ChidamberKemererDistributionBuilder.class, FunctionsDecorator.class);
}

@Override
public String toString() {
return getKey();
}
}

+ 2
- 5
plugins/sonar-squid-java-plugin/src/test/java/org/sonar/plugins/squid/SquidPluginTest.java View File

@@ -19,18 +19,15 @@
*/
package org.sonar.plugins.squid;

import org.junit.Test;

import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.core.IsNot.not;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import org.junit.Test;

public class SquidPluginTest {

@Test
public void coverageForFun() {
assertThat(new SquidPlugin().getKey(), not(nullValue()));
assertThat(new SquidPlugin().getExtensions().size(), is(8));
}
}

+ 1
- 13
plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/SurefirePlugin.java View File

@@ -32,19 +32,7 @@ import java.util.List;
project = true,
global = false)
})
public class SurefirePlugin implements Plugin {

public String getKey() {
return CoreProperties.SUREFIRE_PLUGIN;
}

public String getName() {
return "Surefire";
}

public String getDescription() {
return "<a href=' http://maven.apache.org/plugins/maven-surefire-plugin/'>Surefire</a> is a test framework for Maven.";
}
public class SurefirePlugin extends SonarPlugin {

public List<Class<? extends Extension>> getExtensions() {
List<Class<? extends Extension>> extensions = new ArrayList<Class<? extends Extension>>();

+ 35
- 0
plugins/sonar-surefire-plugin/src/test/java/org/sonar/plugins/surefire/SurefirePluginTest.java View File

@@ -0,0 +1,35 @@
/*
* Sonar, open source software quality management tool.
* Copyright (C) 2008-2011 SonarSource
* 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.plugins.surefire;

import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertThat;

import org.junit.Test;

public class SurefirePluginTest {

@Test
public void testGetExtensions() {
SurefirePlugin plugin = new SurefirePlugin();
assertThat(plugin.getExtensions().size(), greaterThan(0));
}

}

+ 1
- 0
sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java View File

@@ -29,6 +29,7 @@ import java.util.List;
*
* @see org.sonar.api.Extension
* @since 1.10
* @deprecated in 2.8. Use {@link SonarPlugin} instead.
*/
public interface Plugin {


+ 49
- 0
sonar-plugin-api/src/main/java/org/sonar/api/SonarPlugin.java View File

@@ -0,0 +1,49 @@
/*
* Sonar, open source software quality management tool.
* Copyright (C) 2008-2011 SonarSource
* 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;

/**
* A plugin is a group of extensions. See {@link Extension} interface to get all extension points.
*
* @since 2.8
*/
public abstract class SonarPlugin implements Plugin {

public final String getKey() {
throw new UnsupportedOperationException();
}

public final String getName() {
throw new UnsupportedOperationException();
}

public final String getDescription() {
throw new UnsupportedOperationException();
}

/**
* Returns a string representation of the plugin, suitable for debugging purposes only.
*/
@Override
public String toString() {
return getClass().getSimpleName();
}

}

Loading…
Cancel
Save