*/
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;
+ "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(
*/
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));
}
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>>();
list.add(CoberturaMavenInitializer.class);
return list;
}
-
- @Override
- public String toString() {
- return getKey();
- }
}
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;
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();
return extensions;
}
-
- @Override
- public String toString() {
- return getKey();
- }
}
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;
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);
*/
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;
@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(
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>>();
return extensions;
}
-
- @Override
- public String toString() {
- return getKey();
- }
}
--- /dev/null
+/*
+ * 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));
+ }
+}
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>>();
--- /dev/null
+/*
+ * 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));
+ }
+
+}
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>>();
return list;
}
- @Override
- public String toString() {
- return getKey();
- }
}
*/
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
--- /dev/null
+/*
+ * 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));
+ }
+
+}
*/
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;
+ "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,
ChidamberKemererDistributionBuilder.class, FunctionsDecorator.class);
}
- @Override
- public String toString() {
- return getKey();
- }
}
*/
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));
}
}
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>>();
--- /dev/null
+/*
+ * 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));
+ }
+
+}
*
* @see org.sonar.api.Extension
* @since 1.10
+ * @deprecated in 2.8. Use {@link SonarPlugin} instead.
*/
public interface Plugin {
--- /dev/null
+/*
+ * 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();
+ }
+
+}