]> source.dussan.org Git - sonarqube.git/commitdiff
Fix quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 22 Feb 2016 18:42:42 +0000 (19:42 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 22 Feb 2016 18:42:42 +0000 (19:42 +0100)
server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelXMLExporter.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/ShowActionTest.java
sonar-plugin-api/src/main/java/org/sonar/api/server/debt/DebtCharacteristic.java
sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java [deleted file]
sonar-plugin-api/src/test/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristicTest.java [deleted file]

index 1df20276b186793837f4c25b3d99ca9c143d8742..ff69e9c0f22f6fc67f62dfa84d5496aea8ed35a3 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.debt;
 
-import com.google.common.collect.Ordering;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.nio.charset.StandardCharsets;
@@ -39,7 +38,6 @@ import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.server.ServerSide;
-import org.sonar.api.server.debt.DebtCharacteristic;
 import org.xml.sax.InputSource;
 
 /**
@@ -199,24 +197,4 @@ public class DebtModelXMLExporter {
         '}';
     }
   }
-
-  private static class SortByOrder extends Ordering<DebtCharacteristic> {
-    @Override
-    public int compare(@Nullable DebtCharacteristic left, @Nullable DebtCharacteristic right) {
-      if (left == null || left.order() == null || right == null || right.order() == null) {
-        return -1;
-      }
-      return left.order() - right.order();
-    }
-  }
-
-  private static class SortByName extends Ordering<DebtCharacteristic> {
-    @Override
-    public int compare(@Nullable DebtCharacteristic left, @Nullable DebtCharacteristic right) {
-      if (left == null || right == null) {
-        return -1;
-      }
-      return StringUtils.defaultString(left.name()).compareTo(StringUtils.defaultString(right.name()));
-    }
-  }
 }
index 8c3cf8fab17b2b9d39e2122957bc435bb499d067..973defab5c9cbc6f766e0e34be0906a48c1d1512 100644 (file)
@@ -32,7 +32,6 @@ import org.mockito.runners.MockitoJUnitRunner;
 import org.sonar.api.i18n.I18n;
 import org.sonar.api.issue.Issue;
 import org.sonar.api.rule.RuleKey;
-import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic;
 import org.sonar.api.user.User;
 import org.sonar.api.user.UserFinder;
 import org.sonar.api.utils.DateUtils;
@@ -49,7 +48,6 @@ import org.sonar.db.DbSession;
 import org.sonar.db.component.ComponentDao;
 import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.ComponentTesting;
-import org.sonar.server.debt.DebtModelService;
 import org.sonar.server.issue.ActionService;
 import org.sonar.server.issue.IssueChangelog;
 import org.sonar.server.issue.IssueChangelogService;
index 261da4e87d77df921ca4a28f3634907aa1079143..52d9cd48a6d465a8d091c928ae3dd411ecdf8381 100644 (file)
@@ -29,7 +29,7 @@ import javax.annotation.CheckForNull;
 public interface DebtCharacteristic {
 
   /**
-   * Only used when a characteristic is disabled (id is -1 in dto) by the user. see {@link org.sonar.server.rule.index.RuleNormalizer}
+   * Only used when a characteristic is disabled (id is -1 in dto) by the user.
    */
   String NONE = "NONE";
 
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristic.java
deleted file mode 100644 (file)
index 4c6154e..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.debt.internal;
-
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-import org.sonar.api.server.debt.DebtCharacteristic;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.util.Date;
-
-/**
- * @since 4.3
- */
-public class DefaultDebtCharacteristic implements DebtCharacteristic {
-
-  private Integer id;
-  private String key;
-  private String name;
-  private Integer order;
-  private Integer parentId;
-  private Date createdAt;
-  private Date updatedAt;
-
-  public Integer id() {
-    return id;
-  }
-
-  public DefaultDebtCharacteristic setId(Integer id) {
-    this.id = id;
-    return this;
-  }
-
-  @Override
-  public String key() {
-    return key;
-  }
-
-  public DefaultDebtCharacteristic setKey(String key) {
-    this.key = key;
-    return this;
-  }
-
-  @Override
-  public String name() {
-    return name;
-  }
-
-  public DefaultDebtCharacteristic setName(String name) {
-    this.name = name;
-    return this;
-  }
-
-  @Override
-  @CheckForNull
-  public Integer order() {
-    return order;
-  }
-
-  public DefaultDebtCharacteristic setOrder(@Nullable Integer order) {
-    this.order = order;
-    return this;
-  }
-
-  @CheckForNull
-  public Integer parentId() {
-    return parentId;
-  }
-
-  public DefaultDebtCharacteristic setParentId(@Nullable Integer parentId) {
-    this.parentId = parentId;
-    return this;
-  }
-
-  public Date createdAt() {
-    return createdAt;
-  }
-
-  public DefaultDebtCharacteristic setCreatedAt(Date createdAt) {
-    this.createdAt = createdAt;
-    return this;
-  }
-
-  @CheckForNull
-  public Date updatedAt() {
-    return updatedAt;
-  }
-
-  public DefaultDebtCharacteristic setUpdatedAt(@Nullable Date updatedAt) {
-    this.updatedAt = updatedAt;
-    return this;
-  }
-
-  @Override
-  public boolean isSub(){
-    return parentId != null;
-  }
-
-  @Override
-  public String toString() {
-    return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
-  }
-
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristicTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/server/debt/internal/DefaultDebtCharacteristicTest.java
deleted file mode 100644 (file)
index dcaa96a..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program 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.
- *
- * This program 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.server.debt.internal;
-
-import org.junit.Test;
-
-import java.util.Date;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class DefaultDebtCharacteristicTest {
-
-  @Test
-  public void setter_and_getter_on_characteristic() {
-    DefaultDebtCharacteristic debtCharacteristic = new DefaultDebtCharacteristic()
-      .setId(1)
-      .setKey("PORTABILITY")
-      .setName("Portability")
-      .setOrder(1)
-      .setCreatedAt(new Date())
-      .setUpdatedAt(new Date());
-
-    assertThat(debtCharacteristic.id()).isEqualTo(1);
-    assertThat(debtCharacteristic.key()).isEqualTo("PORTABILITY");
-    assertThat(debtCharacteristic.name()).isEqualTo("Portability");
-    assertThat(debtCharacteristic.order()).isEqualTo(1);
-    assertThat(debtCharacteristic.parentId()).isNull();
-    assertThat(debtCharacteristic.isSub()).isFalse();
-    assertThat(debtCharacteristic.createdAt()).isNotNull();
-    assertThat(debtCharacteristic.updatedAt()).isNotNull();
-  }
-
-  @Test
-  public void setter_and_getter_on_sub_characteristic() {
-    DefaultDebtCharacteristic debtCharacteristic = new DefaultDebtCharacteristic()
-      .setId(1)
-      .setKey("COMPILER")
-      .setName("Compiler")
-      .setParentId(2)
-      .setCreatedAt(new Date())
-      .setUpdatedAt(new Date());
-
-    assertThat(debtCharacteristic.id()).isEqualTo(1);
-    assertThat(debtCharacteristic.key()).isEqualTo("COMPILER");
-    assertThat(debtCharacteristic.name()).isEqualTo("Compiler");
-    assertThat(debtCharacteristic.order()).isNull();
-    assertThat(debtCharacteristic.parentId()).isEqualTo(2);
-    assertThat(debtCharacteristic.isSub()).isTrue();
-    assertThat(debtCharacteristic.createdAt()).isNotNull();
-    assertThat(debtCharacteristic.updatedAt()).isNotNull();
-  }
-
-  @Test
-  public void to_string() {
-    assertThat(new DefaultDebtCharacteristic()
-      .setId(1)
-      .setKey("PORTABILITY")
-      .setName("Portability")
-      .setOrder(1)
-      .setCreatedAt(new Date())
-      .setUpdatedAt(new Date())).isNotNull();
-  }
-}