]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 9 Oct 2014 21:35:41 +0000 (23:35 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 9 Oct 2014 21:35:41 +0000 (23:35 +0200)
38 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyAnalyser.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java
plugins/sonar-email-notifications-plugin/pom.xml
plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/AlertsEmailTemplate.java [new file with mode: 0644]
plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/EmailNotificationsPlugin.java
plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/api/package-info.java [new file with mode: 0644]
plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/package-info.java [new file with mode: 0644]
plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/templates/alerts/AlertsEmailTemplate.java [deleted file]
plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/AlertsEmailTemplateTest.java [new file with mode: 0644]
plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/templates/alerts/AlertsEmailTemplateTest.java [deleted file]
plugins/sonar-l10n-en-plugin/src/main/java/org/sonar/plugins/l10n/package-info.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/config/ws/package-info.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/package-info.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/index/ActiveRuleNormalizer.java
server/sonar-server/src/main/java/org/sonar/server/test/package-info.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/user/ws/package-info.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/computation/AnalysisReportTaskLauncherTest.java
sonar-application/src/main/java/org/sonar/application/JdbcSettings.java
sonar-application/src/test/java/org/sonar/application/JdbcSettingsTest.java
sonar-application/src/test/java/org/sonar/application/PropsBuilderTest.java
sonar-batch/src/main/java/org/sonar/batch/design/BaseTangleIndexDecorator.java [new file with mode: 0644]
sonar-batch/src/main/java/org/sonar/batch/design/DirectoryTangleIndexDecorator.java
sonar-batch/src/main/java/org/sonar/batch/design/FileTangleIndexDecorator.java
sonar-batch/src/main/java/org/sonar/batch/design/TangleIndexDecorator.java [deleted file]
sonar-batch/src/main/java/org/sonar/batch/scm/package-info.java [new file with mode: 0644]
sonar-colorizer/src/main/java/org/sonar/colorizer/CodeColorizer.java
sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlCodeBuilder.java
sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlOptions.java
sonar-core/src/main/java/org/sonar/core/dependency/package-info.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/duplication/package-info.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/persistence/dialect/package-info.java [new file with mode: 0644]
sonar-duplications/src/test/java/org/sonar/duplications/detector/suffixtree/StringSuffixTree.java
sonar-graph/pom.xml
sonar-graph/src/main/java/org/sonar/graph/package-info.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/internal/package-info.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/package-info.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/package-info.java [new file with mode: 0644]
sonar-plugin-api/src/main/java/org/sonar/api/utils/package-info.java [new file with mode: 0644]

index 8a5ac59c66bdd4e5e77627437c606b2719de4ea8..32b760bc463dd457f557bb901d3f908ff96c7988 100644 (file)
@@ -19,6 +19,9 @@
  */
 package org.sonar.plugins.core.timemachine;
 
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
 import java.util.List;
 
 public class TendencyAnalyser {
@@ -142,11 +145,12 @@ public class TendencyAnalyser {
       this.yIntercept = yIntercept;
     }
 
+    @CheckForNull
     public Double getSlope() {
       return slope;
     }
 
-    public void setSlope(Double slope) {
+    public void setSlope(@Nullable Double slope) {
       this.slope = slope;
     }
 
index 8f54748066f7c78ff07fd72ad10b005af1577a74..5d08e83cd93f882577b06894378a2bb969af62cc 100644 (file)
@@ -160,7 +160,7 @@ public class VariationDecorator implements Decorator {
       ruleId = PastMeasuresLoader.getRuleId(pastFields);
     }
 
-    MeasureKey(int metricId, Integer characteristicId, Integer personId, @Nullable Integer ruleId) {
+    MeasureKey(int metricId, @Nullable Integer characteristicId, @Nullable Integer personId, @Nullable Integer ruleId) {
       this.metricId = metricId;
       this.characteristicId = characteristicId;
       this.personId = personId;
index adcf67041a804418c5ef26b782c64a45964ed364..474d5bcff2049b9e6c0e1dc711ea9136f84ef348 100644 (file)
       <artifactId>sonar-plugin-api</artifactId>
       <scope>provided</scope>
     </dependency>
-    <dependency>
-      <groupId>commons-lang</groupId>
-      <artifactId>commons-lang</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-email</artifactId>
@@ -80,7 +76,7 @@
             <configuration>
               <rules>
                 <requireFilesSize>
-                  <maxsize>600000</maxsize>
+                  <maxsize>620000</maxsize>
                   <minsize>590000</minsize>
                   <files>
                     <file>${project.build.directory}/${project.build.finalName}.jar</file>
diff --git a/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/AlertsEmailTemplate.java b/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/AlertsEmailTemplate.java
new file mode 100644 (file)
index 0000000..542d352
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * 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.plugins.emailnotifications;
+
+import org.apache.commons.lang.StringUtils;
+import org.sonar.api.config.EmailSettings;
+import org.sonar.api.measures.Metric;
+import org.sonar.api.notifications.Notification;
+import org.sonar.plugins.emailnotifications.api.EmailMessage;
+import org.sonar.plugins.emailnotifications.api.EmailTemplate;
+
+/**
+ * Creates email message for notification "alerts".
+ *
+ * @since 3.5
+ */
+public class AlertsEmailTemplate extends EmailTemplate {
+
+  private EmailSettings configuration;
+
+  public AlertsEmailTemplate(EmailSettings configuration) {
+    this.configuration = configuration;
+  }
+
+  @Override
+  public EmailMessage format(Notification notification) {
+    if (!"alerts".equals(notification.getType())) {
+      return null;
+    }
+
+    // Retrieve useful values
+    String projectId = notification.getFieldValue("projectId");
+    String projectKey = notification.getFieldValue("projectKey");
+    String projectName = notification.getFieldValue("projectName");
+    String alertName = notification.getFieldValue("alertName");
+    String alertText = notification.getFieldValue("alertText");
+    String alertLevel = notification.getFieldValue("alertLevel");
+    boolean isNewAlert = Boolean.valueOf(notification.getFieldValue("isNewAlert"));
+
+    // Generate text
+    String subject = generateSubject(projectName, alertLevel, isNewAlert);
+    String messageBody = generateMessageBody(projectName, projectKey, alertName, alertText, isNewAlert);
+
+    // And finally return the email that will be sent
+    return new EmailMessage()
+        .setMessageId("alerts/" + projectId)
+        .setSubject(subject)
+        .setMessage(messageBody);
+  }
+
+  private String generateSubject(String projectName, String alertLevel, boolean isNewAlert) {
+    StringBuilder subjectBuilder = new StringBuilder();
+    if (Metric.Level.OK.toString().equals(alertLevel)) {
+      subjectBuilder.append("\"").append(projectName).append("\" is back to green");
+    } else if (isNewAlert) {
+      subjectBuilder.append("New quality gate threshold reached on \"").append(projectName).append("\"");
+    } else {
+      subjectBuilder.append("Quality gate status changed on \"").append(projectName).append("\"");
+    }
+    return subjectBuilder.toString();
+  }
+
+  private String generateMessageBody(String projectName, String projectKey, String alertName, String alertText, boolean isNewAlert) {
+    StringBuilder messageBody = new StringBuilder();
+    messageBody.append("Project: ").append(projectName).append("\n");
+    messageBody.append("Quality gate status: ").append(alertName).append("\n\n");
+
+    String[] alerts = StringUtils.split(alertText, ",");
+    if (alerts.length > 0) {
+      if (isNewAlert) {
+        messageBody.append("New quality gate threshold");
+      } else {
+        messageBody.append("Quality gate threshold");
+      }
+      if (alerts.length == 1) {
+        messageBody.append(": ").append(alerts[0].trim()).append("\n");
+      } else {
+        messageBody.append("s:\n");
+        for (String alert : alerts) {
+          messageBody.append("  - ").append(alert.trim()).append("\n");
+        }
+      }
+    }
+
+    messageBody.append("\n").append("See it in SonarQube: ").append(configuration.getServerBaseURL()).append("/dashboard/index/").append(projectKey);
+
+    return messageBody.toString();
+  }
+
+}
index 01bf79e4f11f5fdc03a7ff48c8db68a037289461..ddd9a536dd6cf36e791577b1c47a0523271666e0 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.plugins.emailnotifications;
 
 import com.google.common.collect.ImmutableList;
 import org.sonar.api.SonarPlugin;
-import org.sonar.plugins.emailnotifications.templates.alerts.AlertsEmailTemplate;
 
 import java.util.List;
 
diff --git a/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/api/package-info.java b/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/api/package-info.java
new file mode 100644 (file)
index 0000000..ef80b86
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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.plugins.emailnotifications.api;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/package-info.java b/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/package-info.java
new file mode 100644 (file)
index 0000000..db67dd7
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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.plugins.emailnotifications;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/templates/alerts/AlertsEmailTemplate.java b/plugins/sonar-email-notifications-plugin/src/main/java/org/sonar/plugins/emailnotifications/templates/alerts/AlertsEmailTemplate.java
deleted file mode 100644 (file)
index bd7fa46..0000000
+++ /dev/null
@@ -1,107 +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.plugins.emailnotifications.templates.alerts;
-
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.config.EmailSettings;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.notifications.Notification;
-import org.sonar.plugins.emailnotifications.api.EmailMessage;
-import org.sonar.plugins.emailnotifications.api.EmailTemplate;
-
-/**
- * Creates email message for notification "alerts".
- *
- * @since 3.5
- */
-public class AlertsEmailTemplate extends EmailTemplate {
-
-  private EmailSettings configuration;
-
-  public AlertsEmailTemplate(EmailSettings configuration) {
-    this.configuration = configuration;
-  }
-
-  @Override
-  public EmailMessage format(Notification notification) {
-    if (!"alerts".equals(notification.getType())) {
-      return null;
-    }
-
-    // Retrieve useful values
-    String projectId = notification.getFieldValue("projectId");
-    String projectKey = notification.getFieldValue("projectKey");
-    String projectName = notification.getFieldValue("projectName");
-    String alertName = notification.getFieldValue("alertName");
-    String alertText = notification.getFieldValue("alertText");
-    String alertLevel = notification.getFieldValue("alertLevel");
-    boolean isNewAlert = Boolean.valueOf(notification.getFieldValue("isNewAlert"));
-
-    // Generate text
-    String subject = generateSubject(projectName, alertLevel, isNewAlert);
-    String messageBody = generateMessageBody(projectName, projectKey, alertName, alertText, isNewAlert);
-
-    // And finally return the email that will be sent
-    return new EmailMessage()
-        .setMessageId("alerts/" + projectId)
-        .setSubject(subject)
-        .setMessage(messageBody);
-  }
-
-  private String generateSubject(String projectName, String alertLevel, boolean isNewAlert) {
-    StringBuilder subjectBuilder = new StringBuilder();
-    if (Metric.Level.OK.toString().equals(alertLevel)) {
-      subjectBuilder.append("\"").append(projectName).append("\" is back to green");
-    } else if (isNewAlert) {
-      subjectBuilder.append("New quality gate threshold reached on \"").append(projectName).append("\"");
-    } else {
-      subjectBuilder.append("Quality gate status changed on \"").append(projectName).append("\"");
-    }
-    return subjectBuilder.toString();
-  }
-
-  private String generateMessageBody(String projectName, String projectKey, String alertName, String alertText, boolean isNewAlert) {
-    StringBuilder messageBody = new StringBuilder();
-    messageBody.append("Project: ").append(projectName).append("\n");
-    messageBody.append("Quality gate status: ").append(alertName).append("\n\n");
-
-    String[] alerts = StringUtils.split(alertText, ",");
-    if (alerts.length > 0) {
-      if (isNewAlert) {
-        messageBody.append("New quality gate threshold");
-      } else {
-        messageBody.append("Quality gate threshold");
-      }
-      if (alerts.length == 1) {
-        messageBody.append(": ").append(alerts[0].trim()).append("\n");
-      } else {
-        messageBody.append("s:\n");
-        for (String alert : alerts) {
-          messageBody.append("  - ").append(alert.trim()).append("\n");
-        }
-      }
-    }
-
-    messageBody.append("\n").append("See it in SonarQube: ").append(configuration.getServerBaseURL()).append("/dashboard/index/").append(projectKey);
-
-    return messageBody.toString();
-  }
-
-}
diff --git a/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/AlertsEmailTemplateTest.java b/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/AlertsEmailTemplateTest.java
new file mode 100644 (file)
index 0000000..5b42a2a
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * 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.plugins.emailnotifications;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.config.EmailSettings;
+import org.sonar.api.notifications.Notification;
+import org.sonar.plugins.emailnotifications.api.EmailMessage;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class AlertsEmailTemplateTest {
+
+  private AlertsEmailTemplate template;
+
+  @Before
+  public void setUp() {
+    EmailSettings configuration = mock(EmailSettings.class);
+    when(configuration.getServerBaseURL()).thenReturn("http://nemo.sonarsource.org");
+    template = new AlertsEmailTemplate(configuration);
+  }
+
+  @Test
+  public void shouldNotFormatIfNotCorrectNotification() {
+    Notification notification = new Notification("other-notif");
+    EmailMessage message = template.format(notification);
+    assertThat(message, nullValue());
+  }
+
+  @Test
+  public void shouldFormatAlertWithSeveralMessages() {
+    Notification notification = createNotification("Orange (was Red)", "violations > 4, coverage < 75%", "WARN", "false");
+
+    EmailMessage message = template.format(notification);
+    assertThat(message.getMessageId(), is("alerts/45"));
+    assertThat(message.getSubject(), is("Quality gate status changed on \"Foo\""));
+    assertThat(message.getMessage(), is("" +
+      "Project: Foo\n" +
+      "Quality gate status: Orange (was Red)\n" +
+      "\n" +
+      "Quality gate thresholds:\n" +
+      "  - violations > 4\n" +
+      "  - coverage < 75%\n" +
+      "\n" +
+      "See it in SonarQube: http://nemo.sonarsource.org/dashboard/index/org.sonar.foo:foo"));
+  }
+
+  @Test
+  public void shouldFormatNewAlertWithSeveralMessages() {
+    Notification notification = createNotification("Orange (was Red)", "violations > 4, coverage < 75%", "WARN", "true");
+
+    EmailMessage message = template.format(notification);
+    assertThat(message.getMessageId(), is("alerts/45"));
+    assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo\""));
+    assertThat(message.getMessage(), is("" +
+      "Project: Foo\n" +
+      "Quality gate status: Orange (was Red)\n" +
+      "\n" +
+      "New quality gate thresholds:\n" +
+      "  - violations > 4\n" +
+      "  - coverage < 75%\n" +
+      "\n" +
+      "See it in SonarQube: http://nemo.sonarsource.org/dashboard/index/org.sonar.foo:foo"));
+  }
+
+  @Test
+  public void shouldFormatNewAlertWithOneMessage() {
+    Notification notification = createNotification("Orange (was Red)", "violations > 4", "WARN", "true");
+
+    EmailMessage message = template.format(notification);
+    assertThat(message.getMessageId(), is("alerts/45"));
+    assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo\""));
+    assertThat(message.getMessage(), is("" +
+      "Project: Foo\n" +
+      "Quality gate status: Orange (was Red)\n" +
+      "\n" +
+      "New quality gate threshold: violations > 4\n" +
+      "\n" +
+      "See it in SonarQube: http://nemo.sonarsource.org/dashboard/index/org.sonar.foo:foo"));
+  }
+
+  @Test
+  public void shouldFormatBackToGreenMessage() {
+    Notification notification = createNotification("Green (was Red)", "", "OK", "false");
+
+    EmailMessage message = template.format(notification);
+    assertThat(message.getMessageId(), is("alerts/45"));
+    assertThat(message.getSubject(), is("\"Foo\" is back to green"));
+    assertThat(message.getMessage(), is("" +
+      "Project: Foo\n" +
+      "Quality gate status: Green (was Red)\n" +
+      "\n" +
+      "\n" +
+      "See it in SonarQube: http://nemo.sonarsource.org/dashboard/index/org.sonar.foo:foo"));
+  }
+
+  private Notification createNotification(String alertName, String alertText, String alertLevel, String isNewAlert) {
+    Notification notification = new Notification("alerts")
+        .setFieldValue("projectName", "Foo")
+        .setFieldValue("projectKey", "org.sonar.foo:foo")
+        .setFieldValue("projectId", "45")
+        .setFieldValue("alertName", alertName)
+        .setFieldValue("alertText", alertText)
+        .setFieldValue("alertLevel", alertLevel)
+        .setFieldValue("isNewAlert", isNewAlert);
+    return notification;
+  }
+
+}
diff --git a/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/templates/alerts/AlertsEmailTemplateTest.java b/plugins/sonar-email-notifications-plugin/src/test/java/org/sonar/plugins/emailnotifications/templates/alerts/AlertsEmailTemplateTest.java
deleted file mode 100644 (file)
index 5cd4f0c..0000000
+++ /dev/null
@@ -1,131 +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.plugins.emailnotifications.templates.alerts;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.config.EmailSettings;
-import org.sonar.api.notifications.Notification;
-import org.sonar.plugins.emailnotifications.api.EmailMessage;
-
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.nullValue;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class AlertsEmailTemplateTest {
-
-  private AlertsEmailTemplate template;
-
-  @Before
-  public void setUp() {
-    EmailSettings configuration = mock(EmailSettings.class);
-    when(configuration.getServerBaseURL()).thenReturn("http://nemo.sonarsource.org");
-    template = new AlertsEmailTemplate(configuration);
-  }
-
-  @Test
-  public void shouldNotFormatIfNotCorrectNotification() {
-    Notification notification = new Notification("other-notif");
-    EmailMessage message = template.format(notification);
-    assertThat(message, nullValue());
-  }
-
-  @Test
-  public void shouldFormatAlertWithSeveralMessages() {
-    Notification notification = createNotification("Orange (was Red)", "violations > 4, coverage < 75%", "WARN", "false");
-
-    EmailMessage message = template.format(notification);
-    assertThat(message.getMessageId(), is("alerts/45"));
-    assertThat(message.getSubject(), is("Quality gate status changed on \"Foo\""));
-    assertThat(message.getMessage(), is("" +
-      "Project: Foo\n" +
-      "Quality gate status: Orange (was Red)\n" +
-      "\n" +
-      "Quality gate thresholds:\n" +
-      "  - violations > 4\n" +
-      "  - coverage < 75%\n" +
-      "\n" +
-      "See it in SonarQube: http://nemo.sonarsource.org/dashboard/index/org.sonar.foo:foo"));
-  }
-
-  @Test
-  public void shouldFormatNewAlertWithSeveralMessages() {
-    Notification notification = createNotification("Orange (was Red)", "violations > 4, coverage < 75%", "WARN", "true");
-
-    EmailMessage message = template.format(notification);
-    assertThat(message.getMessageId(), is("alerts/45"));
-    assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo\""));
-    assertThat(message.getMessage(), is("" +
-      "Project: Foo\n" +
-      "Quality gate status: Orange (was Red)\n" +
-      "\n" +
-      "New quality gate thresholds:\n" +
-      "  - violations > 4\n" +
-      "  - coverage < 75%\n" +
-      "\n" +
-      "See it in SonarQube: http://nemo.sonarsource.org/dashboard/index/org.sonar.foo:foo"));
-  }
-
-  @Test
-  public void shouldFormatNewAlertWithOneMessage() {
-    Notification notification = createNotification("Orange (was Red)", "violations > 4", "WARN", "true");
-
-    EmailMessage message = template.format(notification);
-    assertThat(message.getMessageId(), is("alerts/45"));
-    assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo\""));
-    assertThat(message.getMessage(), is("" +
-      "Project: Foo\n" +
-      "Quality gate status: Orange (was Red)\n" +
-      "\n" +
-      "New quality gate threshold: violations > 4\n" +
-      "\n" +
-      "See it in SonarQube: http://nemo.sonarsource.org/dashboard/index/org.sonar.foo:foo"));
-  }
-
-  @Test
-  public void shouldFormatBackToGreenMessage() {
-    Notification notification = createNotification("Green (was Red)", "", "OK", "false");
-
-    EmailMessage message = template.format(notification);
-    assertThat(message.getMessageId(), is("alerts/45"));
-    assertThat(message.getSubject(), is("\"Foo\" is back to green"));
-    assertThat(message.getMessage(), is("" +
-      "Project: Foo\n" +
-      "Quality gate status: Green (was Red)\n" +
-      "\n" +
-      "\n" +
-      "See it in SonarQube: http://nemo.sonarsource.org/dashboard/index/org.sonar.foo:foo"));
-  }
-
-  private Notification createNotification(String alertName, String alertText, String alertLevel, String isNewAlert) {
-    Notification notification = new Notification("alerts")
-        .setFieldValue("projectName", "Foo")
-        .setFieldValue("projectKey", "org.sonar.foo:foo")
-        .setFieldValue("projectId", "45")
-        .setFieldValue("alertName", alertName)
-        .setFieldValue("alertText", alertText)
-        .setFieldValue("alertLevel", alertLevel)
-        .setFieldValue("isNewAlert", isNewAlert);
-    return notification;
-  }
-
-}
diff --git a/plugins/sonar-l10n-en-plugin/src/main/java/org/sonar/plugins/l10n/package-info.java b/plugins/sonar-l10n-en-plugin/src/main/java/org/sonar/plugins/l10n/package-info.java
new file mode 100644 (file)
index 0000000..332d583
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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.plugins.l10n;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/config/ws/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/config/ws/package-info.java
new file mode 100644 (file)
index 0000000..050a4cb
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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.server.config.ws;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/package-info.java
new file mode 100644 (file)
index 0000000..181396f
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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.server.db.migrations.v50;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
index 007641dedef4a01f57ad88240d6e902bff15878c..01936878674e0e027201e1b35be0aeedac073d51 100644 (file)
@@ -58,7 +58,7 @@ public class ActiveRuleNormalizer extends BaseNormalizer<ActiveRuleDto, ActiveRu
     public static final IndexField CREATED_AT = addSortable(IndexField.Type.DATE, "createdAt");
     public static final IndexField UPDATED_AT = addSortable(IndexField.Type.DATE, UPDATED_AT_FIELD);
 
-    public static Set<IndexField> ALL_FIELDS = getAllFields();
+    public static final Set<IndexField> ALL_FIELDS = getAllFields();
 
     private static Set<IndexField> getAllFields() {
       Set<IndexField> fields = new HashSet<IndexField>();
diff --git a/server/sonar-server/src/main/java/org/sonar/server/test/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/test/package-info.java
new file mode 100644 (file)
index 0000000..42383de
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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.server.test;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
diff --git a/server/sonar-server/src/main/java/org/sonar/server/user/ws/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/user/ws/package-info.java
new file mode 100644 (file)
index 0000000..a7a5a29
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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.server.user.ws;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
index afb9ec162b6bdf06fdbc653712fa19c56a252eab..62564671abc16e255c848dbb171ee57bef910533 100644 (file)
@@ -34,6 +34,7 @@ public class AnalysisReportTaskLauncherTest {
 
   @Rule
   public Timeout timeout = new Timeout(5000);
+
   private AnalysisReportTaskLauncher sut;
   private ComputationService service;
 
@@ -72,7 +73,7 @@ public class AnalysisReportTaskLauncherTest {
 
   private void sleep() {
     try {
-      TimeUnit.MILLISECONDS.sleep(5L);
+      TimeUnit.MILLISECONDS.sleep(50L);
     } catch (InterruptedException e) {
       e.printStackTrace();
     }
index 294eed9a108b668f067e730c758dc2f2e9c16880..4a34e55a642fc28df3a92487b005d96a03a88462 100644 (file)
@@ -20,6 +20,7 @@
 package org.sonar.application;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
 import org.slf4j.LoggerFactory;
 import org.sonar.process.MessageException;
 import org.sonar.process.ProcessConstants;
@@ -27,10 +28,8 @@ import org.sonar.process.Props;
 
 import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
-
 import java.io.File;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -38,8 +37,8 @@ import java.util.regex.Pattern;
 public class JdbcSettings {
 
   static enum Provider {
-    h2(null), jtds("lib/jdbc/jtds"), mysql("lib/jdbc/mysql"), oracle("extensions/jdbc-driver/oracle"),
-    postgresql("lib/jdbc/postgresql");
+    H2(null), JTDS("lib/jdbc/jtds"), MYSQL("lib/jdbc/mysql"), ORACLE("extensions/jdbc-driver/oracle"),
+    POSTGRESQL("lib/jdbc/postgresql");
 
     final String path;
 
@@ -86,15 +85,14 @@ public class JdbcSettings {
     }
     String key = matcher.group(1);
     try {
-      return Provider.valueOf(key);
+      return Provider.valueOf(StringUtils.upperCase(key));
     } catch (IllegalArgumentException e) {
-      throw new MessageException(String.format(String.format("Unsupported JDBC driver provider: %s. Accepted values are %s", key,
-        Arrays.toString(Provider.values()))));
+      throw new MessageException(String.format(String.format("Unsupported JDBC driver provider: %s", key)));
     }
   }
 
   void checkUrlParameters(Provider provider, String url) {
-    if (Provider.mysql.equals(provider)) {
+    if (Provider.MYSQL.equals(provider)) {
       checkRequiredParameter(url, "useUnicode=true");
       checkRequiredParameter(url, "characterEncoding=utf8");
       checkRecommendedParameter(url, "rewriteBatchedStatements=true");
index edca761aa987dce39e3218aa0d3517964cc07a91..5a2708ab5c89460bb83df04dac48b0e52ff24c8f 100644 (file)
@@ -42,14 +42,14 @@ public class JdbcSettingsTest {
 
   @Test
   public void driver_provider() throws Exception {
-    assertThat(settings.driverProvider("jdbc:oracle:thin:@localhost/XE")).isEqualTo(JdbcSettings.Provider.oracle);
+    assertThat(settings.driverProvider("jdbc:oracle:thin:@localhost/XE")).isEqualTo(JdbcSettings.Provider.ORACLE);
     assertThat(settings.driverProvider("jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance"))
-      .isEqualTo(JdbcSettings.Provider.mysql);
+      .isEqualTo(JdbcSettings.Provider.MYSQL);
     try {
       settings.driverProvider("jdbc:sqlserver://localhost");
       fail();
     } catch (MessageException e) {
-      assertThat(e).hasMessage("Unsupported JDBC driver provider: sqlserver. Accepted values are [h2, jtds, mysql, oracle, postgresql]");
+      assertThat(e).hasMessage("Unsupported JDBC driver provider: sqlserver");
     }
     try {
       settings.driverProvider("oracle:thin:@localhost/XE");
@@ -64,16 +64,16 @@ public class JdbcSettingsTest {
     Props props = new Props(new Properties());
 
     // minimal -> ok
-    settings.checkUrlParameters(JdbcSettings.Provider.mysql,
+    settings.checkUrlParameters(JdbcSettings.Provider.MYSQL,
       "jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8");
 
     // full -> ok
-    settings.checkUrlParameters(JdbcSettings.Provider.mysql,
+    settings.checkUrlParameters(JdbcSettings.Provider.MYSQL,
       "jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance");
 
     // missing required -> ko
     try {
-      settings.checkUrlParameters(JdbcSettings.Provider.mysql,
+      settings.checkUrlParameters(JdbcSettings.Provider.MYSQL,
         "jdbc:mysql://localhost:3306/sonar?characterEncoding=utf8");
       fail();
     } catch (MessageException e) {
@@ -132,7 +132,7 @@ public class JdbcSettingsTest {
     File driverFile = new File(home, "extensions/jdbc-driver/oracle/ojdbc6.jar");
     FileUtils.touch(driverFile);
 
-    String path = settings.driverPath(home, JdbcSettings.Provider.oracle);
+    String path = settings.driverPath(home, JdbcSettings.Provider.ORACLE);
     assertThat(path).isEqualTo(driverFile.getAbsolutePath());
   }
 
@@ -140,7 +140,7 @@ public class JdbcSettingsTest {
   public void driver_dir_does_not_exist() throws Exception {
     File home = temp.newFolder();
     try {
-      settings.driverPath(home, JdbcSettings.Provider.oracle);
+      settings.driverPath(home, JdbcSettings.Provider.ORACLE);
       fail();
     } catch (MessageException e) {
       assertThat(e).hasMessage("Directory does not exist: extensions/jdbc-driver/oracle");
@@ -152,7 +152,7 @@ public class JdbcSettingsTest {
     File home = temp.newFolder();
     FileUtils.forceMkdir(new File(home, "extensions/jdbc-driver/oracle"));
     try {
-      settings.driverPath(home, JdbcSettings.Provider.oracle);
+      settings.driverPath(home, JdbcSettings.Provider.ORACLE);
       fail();
     } catch (MessageException e) {
       assertThat(e).hasMessage("Directory does not contain JDBC driver: extensions/jdbc-driver/oracle");
@@ -166,7 +166,7 @@ public class JdbcSettingsTest {
     FileUtils.touch(new File(home, "extensions/jdbc-driver/oracle/ojdbc6.jar"));
 
     try {
-      settings.driverPath(home, JdbcSettings.Provider.oracle);
+      settings.driverPath(home, JdbcSettings.Provider.ORACLE);
       fail();
     } catch (MessageException e) {
       assertThat(e).hasMessage("Directory must contain only one JAR file: extensions/jdbc-driver/oracle");
index be6387c212c2e83c42105337538960c11d79cee8..7c37363bb68fad3bc074afd7c1a04464ffe87068 100644 (file)
@@ -117,4 +117,10 @@ public class PropsBuilderTest {
     // command-line arguments override sonar.properties file
     assertThat(props.value("sonar.origin")).isEqualTo("raw");
   }
+
+  @Test
+  public void detectHomeDir() throws Exception {
+    assertThat(PropsBuilder.detectHomeDir()).isDirectory().exists();
+
+  }
 }
diff --git a/sonar-batch/src/main/java/org/sonar/batch/design/BaseTangleIndexDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/design/BaseTangleIndexDecorator.java
new file mode 100644 (file)
index 0000000..c550c31
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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.batch.design;
+
+import org.sonar.api.batch.Decorator;
+import org.sonar.api.batch.DecoratorContext;
+import org.sonar.api.batch.DependedUpon;
+import org.sonar.api.batch.DependsUpon;
+import org.sonar.api.measures.Measure;
+import org.sonar.api.measures.MeasureUtils;
+import org.sonar.api.measures.Metric;
+import org.sonar.api.resources.Project;
+import org.sonar.api.resources.Resource;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class BaseTangleIndexDecorator implements Decorator {
+
+  private final Metric tanglesMetric;
+  private final Metric edgesWeightMetric;
+  private final Metric tangleIndexMetric;
+
+  protected BaseTangleIndexDecorator(Metric tanglesMetric, Metric edgesWeightMetric, Metric tangleIndexMetric) {
+    this.tanglesMetric = tanglesMetric;
+    this.edgesWeightMetric = edgesWeightMetric;
+    this.tangleIndexMetric = tangleIndexMetric;
+  }
+
+  @DependsUpon
+  public final List<Metric> dependsUponMetrics() {
+    return Arrays.asList(tanglesMetric, edgesWeightMetric);
+  }
+
+  /**
+   * Used to define downstream dependencies
+   */
+  @DependedUpon
+  public final Metric generatesMetric() {
+    return tangleIndexMetric;
+  }
+
+  public final boolean shouldExecuteOnProject(Project project) {
+    return true;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public final void decorate(Resource resource, DecoratorContext context) {
+    if (!shouldDecorateResource(context)) {
+      return;
+    }
+    Measure tangles = context.getMeasure(tanglesMetric);
+    Measure totalweight = context.getMeasure(edgesWeightMetric);
+
+    if (MeasureUtils.hasValue(totalweight)) {
+      context.saveMeasure(new Measure(tangleIndexMetric, compute(MeasureUtils.getValue(tangles, 0.0), totalweight.getValue())));
+    }
+  }
+
+  private boolean shouldDecorateResource(DecoratorContext context) {
+    return context.getMeasure(tangleIndexMetric) == null;
+  }
+
+
+  private double compute(double tangles, double totalWeight) {
+    if (totalWeight==0.0) {
+      return 0.0;
+    }
+    double result = 2 * tangles / totalWeight;
+    return result * 100;
+  }
+}
index f242722d25cd78125985f8c34eb6c42ad49f0432..8d8b5c580c4cbaca4d0ef9229610aa532a01dab9 100644 (file)
@@ -21,7 +21,7 @@ package org.sonar.batch.design;
 
 import org.sonar.api.measures.CoreMetrics;
 
-public class DirectoryTangleIndexDecorator extends TangleIndexDecorator {
+public class DirectoryTangleIndexDecorator extends BaseTangleIndexDecorator {
 
   public DirectoryTangleIndexDecorator() {
     super(CoreMetrics.DIRECTORY_TANGLES, CoreMetrics.DIRECTORY_EDGES_WEIGHT, CoreMetrics.DIRECTORY_TANGLE_INDEX);
index 079e3774ebde5ea5ce47abc7da52c20d91aae039..b4d46f85e1199ebd18ff630396224f6f62ef012e 100644 (file)
@@ -21,7 +21,7 @@ package org.sonar.batch.design;
 
 import org.sonar.api.measures.CoreMetrics;
 
-public class FileTangleIndexDecorator extends TangleIndexDecorator {
+public class FileTangleIndexDecorator extends BaseTangleIndexDecorator {
 
   public FileTangleIndexDecorator() {
     super(CoreMetrics.FILE_TANGLES, CoreMetrics.FILE_EDGES_WEIGHT, CoreMetrics.FILE_TANGLE_INDEX);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/design/TangleIndexDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/design/TangleIndexDecorator.java
deleted file mode 100644 (file)
index c4c1cc3..0000000
+++ /dev/null
@@ -1,91 +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.batch.design;
-
-import org.sonar.api.batch.Decorator;
-import org.sonar.api.batch.DecoratorContext;
-import org.sonar.api.batch.DependedUpon;
-import org.sonar.api.batch.DependsUpon;
-import org.sonar.api.measures.Measure;
-import org.sonar.api.measures.MeasureUtils;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-
-import java.util.Arrays;
-import java.util.List;
-
-public abstract class TangleIndexDecorator implements Decorator {
-
-  private Metric tanglesMetric;
-  private Metric edgesWeightMetric;
-  private Metric tangleIndexMetric;
-
-  protected TangleIndexDecorator(Metric tanglesMetric, Metric edgesWeightMetric, Metric tangleIndexMetric) {
-    this.tanglesMetric = tanglesMetric;
-    this.edgesWeightMetric = edgesWeightMetric;
-    this.tangleIndexMetric = tangleIndexMetric;
-  }
-
-  @DependsUpon
-  public final List<Metric> dependsUponMetrics() {
-    return Arrays.asList(tanglesMetric, edgesWeightMetric);
-  }
-
-  /**
-   * Used to define downstream dependencies
-   */
-  @DependedUpon
-  public final Metric generatesMetric() {
-    return tangleIndexMetric;
-  }
-
-  public final boolean shouldExecuteOnProject(Project project) {
-    return true;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public final void decorate(Resource resource, DecoratorContext context) {
-    if (!shouldDecorateResource(context)) {
-      return;
-    }
-    Measure tangles = context.getMeasure(tanglesMetric);
-    Measure totalweight = context.getMeasure(edgesWeightMetric);
-
-    if (MeasureUtils.hasValue(totalweight)) {
-      context.saveMeasure(new Measure(tangleIndexMetric, compute(MeasureUtils.getValue(tangles, 0.0), totalweight.getValue())));
-    }
-  }
-
-  private boolean shouldDecorateResource(DecoratorContext context) {
-    return context.getMeasure(tangleIndexMetric) == null;
-  }
-
-
-  private double compute(double tangles, double totalWeight) {
-    if (totalWeight==0.0) {
-      return 0.0;
-    }
-    double result = 2 * tangles / totalWeight;
-    return result * 100;
-  }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scm/package-info.java b/sonar-batch/src/main/java/org/sonar/batch/scm/package-info.java
new file mode 100644 (file)
index 0000000..efefb8a
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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.batch.scm;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index bf1fe61df7464b823ee914db595e3137b7b46b05..4c8695843c3be53dec2542542190642992996eab 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.colorizer;
 
+import javax.annotation.Nullable;
+
 import java.io.Reader;
 import java.util.List;
 
@@ -38,7 +40,7 @@ public class CodeColorizer {
     return toHtml(code, null);
   }
 
-  public String toHtml(Reader code, HtmlOptions options) {
+  public String toHtml(Reader code, @Nullable HtmlOptions options) {
     HtmlOptions opts = options == null ? HtmlOptions.DEFAULT : options;
     return new HtmlRenderer(opts).render(code, tokenizers);
   }
index e6755e7b7e779170c14b7b2ee1106300262c2b8d..c7f9f3d3a7ed60ef412cbef06efdb30bf1554c20 100644 (file)
@@ -19,6 +19,9 @@
  */
 package org.sonar.colorizer;
 
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
 import java.util.HashMap;
 import java.util.Map;
 
@@ -75,13 +78,14 @@ public class HtmlCodeBuilder implements Appendable {
    * @param value
    *          can be null
    */
-  public void setVariable(Object key, Object value) {
+  public void setVariable(Object key, @Nullable Object value) {
     variables.put(key, value);
   }
 
   /**
    * Get a stateful variable. Return null if not found.
    */
+  @CheckForNull
   public Object getVariable(Object key) {
     return variables.get(key);
   }
index d91d89bf5e7c06e13bbb8bfd5fc7803acec8a31e..da86bc689c0c292c9d3f794d8be6c94ede79f68d 100644 (file)
@@ -19,6 +19,9 @@
  */
 package org.sonar.colorizer;
 
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
 public class HtmlOptions {
   public static final HtmlOptions DEFAULT = new HtmlOptions(true, null, true);
   public static final OnlySyntaxHtmlOptions ONLY_SYNTAX = new OnlySyntaxHtmlOptions();
@@ -31,7 +34,7 @@ public class HtmlOptions {
   public HtmlOptions() {
   }
 
-  public HtmlOptions(boolean generateTable, String tableId, boolean generateHtmlHeader) {
+  public HtmlOptions(boolean generateTable, @Nullable String tableId, boolean generateHtmlHeader) {
     this.generateTable = generateTable;
     this.generateHtmlHeader = generateHtmlHeader;
     this.tableId = tableId;
@@ -61,6 +64,7 @@ public class HtmlOptions {
     return this;
   }
 
+  @CheckForNull
   public String getTableId() {
     return tableId;
   }
diff --git a/sonar-core/src/main/java/org/sonar/core/dependency/package-info.java b/sonar-core/src/main/java/org/sonar/core/dependency/package-info.java
new file mode 100644 (file)
index 0000000..ade6644
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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.core.dependency;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-core/src/main/java/org/sonar/core/duplication/package-info.java b/sonar-core/src/main/java/org/sonar/core/duplication/package-info.java
new file mode 100644 (file)
index 0000000..ed92061
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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.core.duplication;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/dialect/package-info.java b/sonar-core/src/main/java/org/sonar/core/persistence/dialect/package-info.java
new file mode 100644 (file)
index 0000000..b61912c
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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.core.persistence.dialect;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index b03eb7f6caf3c4ef8830d5ba18cb2c7f98fc7b10..b30747121465cc546dd7fbe385550cd1eef8d189 100644 (file)
  */
 package org.sonar.duplications.detector.suffixtree;
 
+import com.google.common.base.Objects;
+
 import java.util.LinkedList;
 import java.util.Queue;
 
-import org.sonar.duplications.detector.suffixtree.Edge;
-import org.sonar.duplications.detector.suffixtree.Node;
-import org.sonar.duplications.detector.suffixtree.SuffixTree;
-import org.sonar.duplications.detector.suffixtree.Text;
-
-import com.google.common.base.Objects;
-
 public class StringSuffixTree {
 
   private final SuffixTree suffixTree;
index ffc47c481b40c000b73e3fe67d2e5b90f02a5e89..132a7ea540f6ed66011e06dc573fe8ba3c53c30d 100644 (file)
@@ -7,7 +7,6 @@
     <version>5.0-SNAPSHOT</version>
     <relativePath>..</relativePath>
   </parent>
-  <groupId>org.codehaus.sonar</groupId>
   <artifactId>sonar-graph</artifactId>
   <packaging>jar</packaging>
   <name>SonarQube :: Graph</name>
       <groupId>com.google.guava</groupId>
       <artifactId>guava</artifactId>
     </dependency>
+    <dependency>
+      <groupId>com.google.code.findbugs</groupId>
+      <artifactId>jsr305</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
diff --git a/sonar-graph/src/main/java/org/sonar/graph/package-info.java b/sonar-graph/src/main/java/org/sonar/graph/package-info.java
new file mode 100644 (file)
index 0000000..e1f395a
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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.graph;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/internal/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/internal/package-info.java
new file mode 100644 (file)
index 0000000..ca62131
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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.batch.debt.internal;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/debt/package-info.java
new file mode 100644 (file)
index 0000000..eceb0e9
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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.batch.debt;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/package-info.java
new file mode 100644 (file)
index 0000000..005f17d
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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;
+
+import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/package-info.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/package-info.java
new file mode 100644 (file)
index 0000000..e493fc8
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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.utils;
+
+import javax.annotation.ParametersAreNonnullByDefault;
+