<packaging>sonar-plugin</packaging>
<version>0.1-SNAPSHOT</version>
- <name>HelloWorld Plugin for SonarQube</name>
+ <name>HelloWorld</name>
<description>HelloWorld example plugin for SonarQube</description>
<url>https://gumartinm.name/</url>
<organization>
<version>${java.plugin.version}</version>
<scope>provided</scope>
</dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.6.2</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>19.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.sonarsource.sslr-squid-bridge</groupId>
+ <artifactId>sslr-squid-bridge</artifactId>
+ <version>2.6.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.sonar.sslr</groupId>
+ <artifactId>sslr-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.sonar</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.sonar.sslr</groupId>
+ <artifactId>sslr-xpath</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.sonarsource.java</groupId>
+ <artifactId>java-frontend</artifactId>
+ <version>4.0</version>
+ </dependency>
+
+
+
<!-- unit tests -->
<dependency>
import java.util.List;
-import org.sonar.api.internal.google.common.collect.ImmutableList;
import org.sonar.plugins.java.api.JavaCheck;
+import com.google.common.collect.ImmutableList;
+
public final class CheckList {
- public static final String REPOSITORY_KEY = "gushelloworld";
+ public static final String REPOSITORY_KEY = "helloworld";
+ public static final String REPOSITORY_NAME = "Hello World";
private CheckList() {
}
import com.google.common.collect.ImmutableList;
-@Rule(key = "HELLOWORLDO001")
+@Rule(key = "HELLOWORLD0001")
public class HelloWorldCheck extends IssuableSubscriptionVisitor {
@Override
* Definition of rules.
*/
public class HelloWorldRulesDefinition implements RulesDefinition {
- private static final String RESOURCE_BASE_PATH = "/de/example/l10n/helloworld/rules/gushelloworld";
+ private static final String RESOURCE_BASE_PATH = "/de/example/l10n/helloworld/rules/helloworld";
+
private final Gson gson = new Gson();
@Override
public void define(Context context) {
- NewRepository repository = context.createRepository(CheckList.REPOSITORY_KEY, Java.KEY).setName("Gus HelloWorld Definition");
+ NewRepository repository = context
+ .createRepository(CheckList.REPOSITORY_KEY, Java.KEY)
+ .setName(CheckList.REPOSITORY_NAME);
List<Class> checks = CheckList.getChecks();
new RulesDefinitionAnnotationLoader().load(repository, Iterables.toArray(checks, Class.class));
for (Class ruleClass : checks) {
+++ /dev/null
-<p>HelloWorld rule description.</p>
-<h2>Noncompliant Code Example</h2>
-<pre>
-public class MyServlet extends HttpServlet {
- private String userName; //As this field is shared by all users, it's obvious that this piece of information should be managed differently
- ...
-}
-</pre>
-<p>or </p>
-<pre>
-public class MyAction extends Action {
- private String userName; //Same reason
- ...
-}
-</pre>
-<h2>See</h2>
-<ul>
- <li> <a href="https://www.securecoding.cert.org/confluence/x/EYBUC">CERT, MSC11-J.</a> - Do not let session information leak within a servlet </li>
-</ul>
-
+++ /dev/null
-{
- "title": "HelloWorld SonarQube rule",
- "status": "ready",
- "remediation": {
- "func": "Constant\/Issue",
- "constantCost": "5min"
- },
- "tags": [
- "bad-practice"
- ],
- "defaultSeverity": "Major"
-}
--- /dev/null
+<p>HelloWorld rule description.</p>
+<h2>Noncompliant Code Example</h2>
+<pre>
+class MyClass {
+
+ int foo1(int value) { return 0; }
+
+ MyClass foo2(MyClass value) { return null; }
+
+ ...
+
+}
+</pre>
+<h2>See</h2>
+<ul>
+ <li> <a href="https://www.securecoding.cert.org/confluence/x/EYBUC">CERT, MSC11-J.</a> - Do not let session information leak within a servlet </li>
+</ul>
+
--- /dev/null
+{
+ "title": "HelloWorld SonarQube rule",
+ "status": "ready",
+ "remediation": {
+ "func": "Constant\/Issue",
+ "constantCost": "5min"
+ },
+ "tags": [
+ "bad-practice"
+ ],
+ "defaultSeverity": "Major"
+}