]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorJulien Lancelot <julien.lancelot@gmail.com>
Thu, 30 May 2013 09:44:22 +0000 (11:44 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Thu, 30 May 2013 09:44:22 +0000 (11:44 +0200)
sonar-core/src/main/java/org/sonar/core/issue/ActionPlanDeadlineComparator.java
sonar-core/src/main/java/org/sonar/core/issue/DefaultIssueBuilder.java
sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
sonar-core/src/test/java/org/sonar/core/issue/DefaultIssueBuilderTest.java
sonar-server/src/main/java/org/sonar/server/issue/IssuesFinderSort.java

index 0deb1837dbf7bbc70bc24c5b21036121109976b3..6078aaed3d74c3ca043ea20cfaedd539e4fb3505 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.core.issue;
 
 import org.sonar.api.issue.ActionPlan;
 
+import java.io.Serializable;
 import java.util.Comparator;
 import java.util.Date;
 
@@ -28,7 +29,7 @@ import java.util.Date;
  * Sort action plans by chronological deadlines. Plans without deadline are
  * located after plans with deadline.
  */
-public class ActionPlanDeadlineComparator implements Comparator<ActionPlan> {
+public class ActionPlanDeadlineComparator implements Comparator<ActionPlan>, Serializable {
 
   @Override
   public int compare(ActionPlan a1, ActionPlan a2) {
index e187b923dd28fc110dc5507bcd55720f73e09471..1c4dcf208fb2e087fb72bc038fbc3ab72498a7ae 100644 (file)
@@ -27,6 +27,7 @@ import org.sonar.api.issue.Issue;
 import org.sonar.api.rule.RuleKey;
 
 import javax.annotation.Nullable;
+
 import java.util.Map;
 import java.util.UUID;
 
@@ -104,8 +105,7 @@ public class DefaultIssueBuilder implements Issuable.IssueBuilder {
   @Override
   public DefaultIssue build() {
     Preconditions.checkNotNull(componentKey, "Component key must be set");
-    // TODO
-    //Preconditions.checkNotNull(projectKey, "Project key must be set");
+    Preconditions.checkNotNull(projectKey, "Project key must be set");
     Preconditions.checkNotNull(ruleKey, "Rule key must be set");
 
     DefaultIssue issue = new DefaultIssue();
index af3619bd53c8249332276214b18e66557d50a495..a1660f4a28e78fc8009ee42d9576b1411f89046d 100644 (file)
@@ -120,12 +120,15 @@ public class MyBatis implements BatchComponent, ServerComponent {
     loadAlias(conf, "ActionPlanStats", ActionPlanStatsDto.class);
 
     Class<?>[] mappers = {ActiveDashboardMapper.class, AuthorMapper.class, DashboardMapper.class,
-      DependencyMapper.class, DuplicationMapper.class, GraphDtoMapper.class, IssueMapper.class, IssueStatsMapper.class, IssueChangeMapper.class, LoadedTemplateMapper.class,
-      MeasureFilterMapper.class, PropertiesMapper.class, PurgeMapper.class, ResourceKeyUpdaterMapper.class, ResourceIndexerMapper.class, ResourceMapper.class,
+      DependencyMapper.class, DuplicationMapper.class, GraphDtoMapper.class,
+      // ResourceMapper has to be loaded before IssueMapper because this last one used it
+      ResourceMapper.class, IssueMapper.class, IssueStatsMapper.class, IssueChangeMapper.class,
+      LoadedTemplateMapper.class, MeasureFilterMapper.class, PropertiesMapper.class, PurgeMapper.class, ResourceKeyUpdaterMapper.class, ResourceIndexerMapper.class,
       ResourceSnapshotMapper.class, RoleMapper.class, RuleMapper.class, SchemaMigrationMapper.class,
       SemaphoreMapper.class, UserMapper.class, WidgetMapper.class, WidgetPropertyMapper.class, MeasureMapper.class, SnapshotDataMapper.class,
       SnapshotSourceMapper.class, ActionPlanMapper.class, ActionPlanStatsMapper.class
     };
+    // AuthorizationMapper has to be loaded before IssueMapper because this last one used it
     loadMapper(conf, "org.sonar.core.user.AuthorizationMapper");
     loadMappers(conf, mappers);
     configureLogback(mappers);
index eb55c784461bf89442352044d3c8cb5e4271273a..61d3db092f9424b69aab7187db0b51b9e7414959 100644 (file)
@@ -33,6 +33,7 @@ public class DefaultIssueBuilderTest {
     String componentKey = "org.apache.struts:struts-core:Action.java";
     DefaultIssue issue = (DefaultIssue) new DefaultIssueBuilder()
       .componentKey(componentKey)
+      .projectKey("org.apache.struts:struts-parent")
       .message("the message")
       .line(123)
       .effortToFix(10000.0)
@@ -64,6 +65,7 @@ public class DefaultIssueBuilderTest {
   public void should_not_set_default_severity() {
     DefaultIssue issue = (DefaultIssue) new DefaultIssueBuilder()
       .componentKey("Action.java")
+      .projectKey("org.apache.struts:struts-parent")
       .ruleKey(RuleKey.of("squid", "NullDereference"))
       .build();
 
index 64e394bb7311b62601619a66829920be8f14ab48..9862a23d8ef68848127cafde4f668e20c4e0837f 100644 (file)
@@ -41,8 +41,9 @@ class IssuesFinderSort {
 
   public List<IssueDto> sort() {
     String sort = query.sort();
-    if (sort != null) {
-      return getIssueProcessor(sort).sort(issues, query.asc());
+    Boolean asc = query.asc();
+    if (sort != null && asc != null) {
+      return getIssueProcessor(sort).sort(issues, asc);
     }
     return issues;
   }