From ee925d0a8d31556a37f98b6738e6f767b489e288 Mon Sep 17 00:00:00 2001
From: Simon Brandhof The manifest property
+ * public class Foo implements BatchComponent {
+ *
+ * }
+ * public class Bar implements BatchComponent {
+ * private final Foo foo;
+ * public Bar(Foo f) {
+ * this.foo = f;
+ * }
+ * }
+ *
+ *
*
* @since 2.2
*/
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/BatchExtension.java b/sonar-plugin-api/src/main/java/org/sonar/api/BatchExtension.java
index 6867cdd88b5..95cc1c0f8f7 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/BatchExtension.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/BatchExtension.java
@@ -20,7 +20,8 @@
package org.sonar.api;
/**
- * Batch extension point.
+ * Marker interface for all the batch extension points, which are aimed to be implemented
+ * by plugins.
*
* @since 1.10
*/
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
index 7016d777d8a..0705779f120 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
@@ -20,8 +20,7 @@
package org.sonar.api;
/**
- * CoreProperties is used to group various properties of Sonar as well
- * as default values of configuration in a single place
+ * Non-exhaustive list of constants of core properties.
*
* @since 1.11
*/
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/Extension.java b/sonar-plugin-api/src/main/java/org/sonar/api/Extension.java
index a0ccc09fddc..1c5c8a52c07 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/Extension.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/Extension.java
@@ -20,7 +20,7 @@
package org.sonar.api;
/**
- * Extension point.
+ * Plugin extension point
*
* @since 1.10
*/
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java b/sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java
index c0c1340b387..ea7bbc755e9 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java
@@ -22,10 +22,11 @@ package org.sonar.api;
import java.util.List;
/**
- * A plugin is a group of extensions. See org.sonar.api.Extension
interface to get all extension points.
+ * A plugin is a group of extensions. See org.sonar.api.Extension
interface to browse
+ * available extension points.
*
* Plugin-Class
must declare the name of the implementation class.
- * See META-INF/MANIFEST.MF.
org.sonar.api.resources.Project
- * (see method getConfiguration()
).
- *
- * Must be used in org.sonar.api.Plugin
classes only.
The JAR manifest must declare the name of the implementation class in the property Plugin-Class
.
+ * This property is automatically set by sonar-packaging-maven-plugin when building plugin.
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java
new file mode 100644
index 00000000000..05c96078eca
--- /dev/null
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java
@@ -0,0 +1,35 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.api.config;
+
+/**
+ * @since 3.7
+ */
+class SubCategory extends Category {
+
+ SubCategory(String originalKey) {
+ super(originalKey);
+ }
+
+ SubCategory(String originalKey, boolean special) {
+ super(originalKey, special);
+ }
+
+}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/Category.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/Category.java
deleted file mode 100644
index c8990213204..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/Category.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.config.internal;
-
-import org.apache.commons.lang.StringUtils;
-
-import java.util.Locale;
-
-/**
- * @since 3.7
- */
-public class Category {
-
- private final String originalKey;
- private final boolean special;
-
- public Category(String originalKey) {
- this(originalKey, false);
- }
-
- public Category(String originalKey, boolean special) {
- this.originalKey = originalKey;
- this.special = special;
- }
-
- public String originalKey() {
- return originalKey;
- }
-
- public String key() {
- return StringUtils.lowerCase(originalKey, Locale.ENGLISH);
- }
-
- public boolean isSpecial() {
- return special;
- }
-
- @Override
- public int hashCode() {
- return key().hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof Category)) {
- return false;
- }
- return StringUtils.equalsIgnoreCase(((Category) obj).originalKey, this.originalKey);
- }
-
- @Override
- public String toString() {
- return this.originalKey;
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/SubCategory.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/SubCategory.java
deleted file mode 100644
index 8dfbcc16d10..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/SubCategory.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.config.internal;
-
-
-/**
- * @since 3.7
- */
-public class SubCategory extends Category {
-
- public SubCategory(String originalKey) {
- super(originalKey);
- }
-
- public SubCategory(String originalKey, boolean special) {
- super(originalKey, special);
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/package-info.java
deleted file mode 100644
index 25458dc6179..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/config/internal/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.api.config.internal;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/charts/AbstractChartTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/charts/AbstractChartTest.java
deleted file mode 100644
index eba63156d5f..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/charts/AbstractChartTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.charts;
-
-import org.apache.commons.io.FileUtils;
-import org.jfree.chart.ChartUtilities;
-import org.jfree.ui.ApplicationFrame;
-import org.jfree.ui.RefineryUtilities;
-
-import javax.swing.JPanel;
-
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import static org.junit.Assert.assertTrue;
-
-public abstract class AbstractChartTest {
- protected void assertChartSizeGreaterThan(BufferedImage img, int size) throws IOException {
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- ChartUtilities.writeBufferedImageAsPNG(output, img);
- assertTrue("PNG size in bits=" + output.size(), output.size() > size);
- }
-
- protected void assertChartSizeLesserThan(BufferedImage img, int size) throws IOException {
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- ChartUtilities.writeBufferedImageAsPNG(output, img);
- assertTrue("PNG size in bits=" + output.size(), output.size() < size);
- }
-
- protected void saveChart(BufferedImage img, String name) throws IOException {
- File target = new File("target/tmp-chart", name);
- FileUtils.forceMkdir(target.getParentFile());
- ByteArrayOutputStream imgOutput = new ByteArrayOutputStream();
- ChartUtilities.writeBufferedImageAsPNG(imgOutput, img);
- OutputStream out = new FileOutputStream(target);
- out.write(imgOutput.toByteArray());
- out.close();
-
- }
-
- protected static void displayTestPanel(BufferedImage image) {
- ApplicationFrame frame = new ApplicationFrame("testframe");
- BufferedPanel imgPanel = new BufferedPanel(image);
- frame.setContentPane(imgPanel);
- frame.pack();
- RefineryUtilities.centerFrameOnScreen(frame);
- frame.setVisible(true);
- }
-
- protected static Date stringToDate(String sDate) throws ParseException {
- SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yy hh'h'mm");
- return sdf.parse(sDate);
- }
-
- private static class BufferedPanel extends JPanel {
- private final BufferedImage chartImage;
-
- public BufferedPanel(BufferedImage chartImage) {
- this.chartImage = chartImage;
- }
-
- @Override
- protected void paintComponent(Graphics graphics) {
- super.paintComponent(graphics);
- graphics.drawImage(chartImage, 0, 0, null);
- }
-
- @Override
- public Dimension getPreferredSize() {
- return new Dimension(chartImage.getWidth(), chartImage.getHeight());
- }
- }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/charts/ChartParametersTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/charts/ChartParametersTest.java
deleted file mode 100644
index 40fbe94c3b5..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/charts/ChartParametersTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.charts;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-
-import java.util.Locale;
-
-public class ChartParametersTest {
- @Test
- public void shouldForbidHighSizeForSecurityReasons() {
- String url = ChartParameters.PARAM_WIDTH + "=100000&" + ChartParameters.PARAM_HEIGHT + "=9999999";
- ChartParameters params = new ChartParameters(url);
- assertEquals(ChartParameters.MAX_WIDTH, params.getWidth());
- assertEquals(ChartParameters.MAX_HEIGHT, params.getHeight());
- }
-
- @Test
- public void shouldReadImageSizeFromParameters() {
- String url = ChartParameters.PARAM_WIDTH + "=200&" + ChartParameters.PARAM_HEIGHT + "=300";
- ChartParameters params = new ChartParameters(url);
- assertEquals(200, params.getWidth());
- assertEquals(300, params.getHeight());
- }
-
- @Test
- public void shouldGetDefaultSizesIfNoParameters() {
- ChartParameters params = new ChartParameters("foo=bar");
- assertEquals(ChartParameters.DEFAULT_WIDTH, params.getWidth());
- assertEquals(ChartParameters.DEFAULT_HEIGHT, params.getHeight());
- }
-
- @Test
- public void shouldDecodeValue() {
- ChartParameters params = new ChartParameters("foo=0%3D10,3%3D8");
- assertEquals("0=10,3=8", params.getValue("foo", "", true));
- assertEquals("0%3D10,3%3D8", params.getValue("foo"));
- assertNull(params.getValue("bar", null, true));
- }
-
- @Test
- public void shouldDecodeValues() {
- ChartParameters params = new ChartParameters("foo=0%3D10,3%3D8|5%3D5,7%3D17");
- assertArrayEquals(new String[]{"0%3D10,3%3D8", "5%3D5,7%3D17"}, params.getValues("foo", "|"));
- assertArrayEquals(new String[]{"0=10,3=8", "5=5,7=17"}, params.getValues("foo", "|", true));
- assertArrayEquals(new String[0], params.getValues("bar", "|", true));
- }
-
- @Test
- public void getLocale() {
- ChartParameters params = new ChartParameters("foo=0&locale=fr");
- assertEquals(Locale.FRENCH, params.getLocale());
-
- params = new ChartParameters("foo=0&locale=fr-CH");
- assertEquals("fr-ch", params.getLocale().getLanguage());
-
- params = new ChartParameters("foo=0");
- assertEquals(Locale.ENGLISH, params.getLocale());
- }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/NoSonarFilterTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/NoSonarFilterTest.java
deleted file mode 100644
index 7f4793b77cd..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/NoSonarFilterTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube 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.
- *
- * SonarQube 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 this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.checks;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.batch.SensorContext;
-import org.sonar.api.resources.File;
-import org.sonar.api.rules.Rule;
-import org.sonar.api.rules.Violation;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.fest.assertions.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class NoSonarFilterTest {
-
- private SensorContext sensorContext = mock(SensorContext.class);
- NoSonarFilter filter = new NoSonarFilter(sensorContext);
- private File javaFile;
-
- @Before
- public void prepare() {
- javaFile = new File("org.foo.Bar");
- when(sensorContext.getResource(javaFile)).thenReturn(javaFile);
- }
-
- @Test
- public void ignoreLinesCommentedWithNoSonar() {
- Set