]> source.dussan.org Git - sonarqube.git/commitdiff
Drop dead code
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 22 Feb 2017 10:50:12 +0000 (11:50 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Wed, 22 Feb 2017 16:10:15 +0000 (17:10 +0100)
12 files changed:
server/sonar-server/src/main/java/org/sonar/server/debt/DebtModelPluginRepository.java
server/sonar-server/src/main/java/org/sonar/server/es/SearchOptions.java
server/sonar-server/src/main/java/org/sonar/server/es/StickyFacetBuilder.java
server/sonar-server/src/main/java/org/sonar/server/issue/IssueQuery.java
server/sonar-server/src/main/java/org/sonar/server/issue/workflow/OrCondition.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLoader.java
server/sonar-server/src/test/java/org/sonar/server/es/SearchOptionsTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/workflow/OrConditionTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileServiceMediumTest.java
server/sonar-server/src/test/resources/org/sonar/server/db/BaseDaoTest/schema.sql [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/fake/FakeMapper.xml [deleted file]
server/sonar-server/src/test/resources/org/sonar/server/db/invalid_db_data_file [deleted file]

index 79621a562cbf5624666222f625ea90d393d282dd..16e11c66229ec9641987bc9f1598d1c65fd2b49d 100644 (file)
@@ -83,7 +83,7 @@ public class DebtModelPluginRepository implements Startable {
     findAvailableXMLFiles();
   }
 
-  protected void findAvailableXMLFiles() {
+  private void findAvailableXMLFiles() {
     if (contributingPluginKeyToClassLoader == null) {
       contributingPluginKeyToClassLoader = Maps.newTreeMap();
       // Add default model
index 7eff79ece1ef55980acbad23d47033edd26a5e5e..84c828d5cd871279612e4e10dc0e44346162b288 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.es;
 
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
@@ -99,15 +98,6 @@ public class SearchOptions {
     return this;
   }
 
-  /**
-   * WARNING - dangerous
-   */
-  @Deprecated
-  public SearchOptions disableLimit() {
-    this.limit = 999_999;
-    return this;
-  }
-
   /**
    * Lists selected facets.
    */
@@ -134,10 +124,6 @@ public class SearchOptions {
     return fieldsToReturn;
   }
 
-  public boolean hasField(String key) {
-    return fieldsToReturn.isEmpty() || fieldsToReturn.contains(key);
-  }
-
   public SearchOptions addFields(@Nullable Collection<String> c) {
     if (c != null) {
       for (String s : c) {
@@ -149,33 +135,10 @@ public class SearchOptions {
     return this;
   }
 
-  public SearchOptions addFields(String... array) {
-    return addFields(Arrays.asList(array));
-  }
-
   public SearchOptions writeJson(JsonWriter json, long totalHits) {
     json.prop("total", totalHits);
     json.prop(WebService.Param.PAGE, getPage());
     json.prop(WebService.Param.PAGE_SIZE, getLimit());
     return this;
   }
-
-  @Deprecated
-  public SearchOptions writeDeprecatedJson(JsonWriter json, long totalHits) {
-    int pages = 0;
-    if (limit > 0) {
-      pages = (int) (totalHits / limit);
-      if (totalHits % limit > 0) {
-        pages++;
-      }
-    }
-    json.name("paging").beginObject()
-      .prop("pageIndex", getPage())
-      .prop("pageSize", getLimit())
-      .prop("total", totalHits)
-      .prop("fTotal", String.valueOf(totalHits))
-      .prop("pages", pages)
-      .endObject();
-    return this;
-  }
 }
index c1c691b61772c5300d79f6a17163b9fc6cbe8a9f..e34ee1f98bafc705227b1a8580c1f29803fabfe7 100644 (file)
@@ -61,14 +61,6 @@ public class StickyFacetBuilder {
     this.order = order;
   }
 
-  public QueryBuilder query() {
-    return query;
-  }
-
-  public Map<String, QueryBuilder> filters() {
-    return filters;
-  }
-
   public AggregationBuilder buildStickyFacet(String fieldName, String facetName, Object... selected) {
     return buildStickyFacet(fieldName, facetName, FACET_DEFAULT_SIZE, selected);
   }
index 59fe76a5ade1c67fd2ea950f8b0a58e4703feb9e..d02969cacef9d40f490a7288fd99177b325f384d 100644 (file)
@@ -473,6 +473,6 @@ public class IssueQuery {
   }
 
   private static <T> Collection<T> defaultCollection(@Nullable Collection<T> c) {
-    return c == null ? Collections.<T>emptyList() : Collections.unmodifiableCollection(c);
+    return c == null ? Collections.emptyList() : Collections.unmodifiableCollection(c);
   }
 }
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/workflow/OrCondition.java b/server/sonar-server/src/main/java/org/sonar/server/issue/workflow/OrCondition.java
deleted file mode 100644 (file)
index 8364c77..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info 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.server.issue.workflow;
-
-import org.sonar.api.issue.Issue;
-import org.sonar.api.issue.condition.Condition;
-
-public class OrCondition implements Condition {
-  private final Condition[] conditions;
-
-  public OrCondition(Condition... conditions) {
-    this.conditions = conditions;
-  }
-
-  @Override
-  public boolean matches(Issue issue) {
-    for (Condition condition : conditions) {
-      if (condition.matches(issue)) {
-        return true;
-      }
-    }
-    return false;
-  }
-
-}
index f3653ce65aeab3463346fa5a46be3b9185da4e0f..9fb2f2876a704b5dfca42a752132a2d9b3f3ba50 100644 (file)
  */
 package org.sonar.server.qualityprofile;
 
-import com.google.common.collect.Lists;
 import com.google.common.collect.Multimap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
-import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.server.ServerSide;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.qualityprofile.QualityProfileDto;
-import org.sonar.server.es.SearchOptions;
 import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
-import org.sonar.server.rule.index.RuleIndex;
-import org.sonar.server.rule.index.RuleQuery;
 import org.sonar.server.search.FacetValue;
 
 @ServerSide
@@ -40,12 +35,10 @@ public class QProfileLoader {
 
   private final DbClient dbClient;
   private final ActiveRuleIndex activeRuleIndex;
-  private final RuleIndex ruleIndex;
 
-  public QProfileLoader(DbClient dbClient, ActiveRuleIndex activeRuleIndex, RuleIndex ruleIndex) {
+  public QProfileLoader(DbClient dbClient, ActiveRuleIndex activeRuleIndex) {
     this.dbClient = dbClient;
     this.activeRuleIndex = activeRuleIndex;
-    this.ruleIndex = ruleIndex;
   }
 
   public Map<String, Multimap<String, FacetValue>> getAllProfileStats() {
@@ -55,13 +48,4 @@ public class QProfileLoader {
     }
   }
 
-  public long countDeprecatedActiveRulesByProfile(String key) {
-    return ruleIndex.search(
-      new RuleQuery()
-        .setQProfileKey(key)
-        .setActivation(true)
-        .setStatuses(Lists.newArrayList(RuleStatus.DEPRECATED)),
-      new SearchOptions().setLimit(0)).getTotal();
-  }
-
 }
index 4ebfb0297b5b436193e968117797668f2d101e31..cb2fbd9c7c994fd7ea4c122145db623b3bb6cdad 100644 (file)
@@ -96,12 +96,6 @@ public class SearchOptionsTest {
     assertThat(options.getLimit()).isEqualTo(SearchOptions.MAX_LIMIT);
   }
 
-  @Test
-  public void disable_limit() {
-    SearchOptions options = new SearchOptions().disableLimit();
-    assertThat(options.getLimit()).isEqualTo(999999);
-  }
-
   @Test
   public void max_page_size() {
     SearchOptions options = new SearchOptions().setPage(3, SearchOptions.MAX_LIMIT + 10);
@@ -109,23 +103,6 @@ public class SearchOptionsTest {
     assertThat(options.getLimit()).isEqualTo(SearchOptions.MAX_LIMIT);
   }
 
-  @Test
-  public void hasField() {
-    // parameter is missing -> all the fields are returned by default
-    SearchOptions options = new SearchOptions();
-    assertThat(options.hasField("repo")).isTrue();
-
-    // parameter is set to empty -> all the fields are returned by default
-    options = new SearchOptions().addFields("");
-    assertThat(options.hasField("repo")).isTrue();
-
-    // parameter is set -> return only the selected fields
-    options = new SearchOptions().addFields("name", "repo");
-    assertThat(options.hasField("name")).isTrue();
-    assertThat(options.hasField("repo")).isTrue();
-    assertThat(options.hasField("severity")).isFalse();
-  }
-
   @Test
   public void writeJson() {
     SearchOptions options = new SearchOptions().setPage(3, 10);
@@ -137,28 +114,6 @@ public class SearchOptionsTest {
     JsonAssert.assertJson(json.toString()).isSimilarTo("{\"total\": 42, \"p\": 3, \"ps\": 10}");
   }
 
-  @Test
-  public void writeDeprecatedJson() {
-    SearchOptions options = new SearchOptions().setPage(3, 10);
-    StringWriter json = new StringWriter();
-    JsonWriter jsonWriter = JsonWriter.of(json).beginObject();
-    options.writeDeprecatedJson(jsonWriter, 42L);
-    jsonWriter.endObject().close();
-
-    JsonAssert.assertJson(json.toString()).isSimilarTo("{\"paging\": {\"pageIndex\": 3, \"pageSize\": 10, \"total\": 42, \"fTotal\": \"42\", \"pages\": 5}}");
-  }
-
-  @Test
-  public void writeDeprecatedJson_exact_nb_of_pages() {
-    SearchOptions options = new SearchOptions().setPage(3, 10);
-    StringWriter json = new StringWriter();
-    JsonWriter jsonWriter = JsonWriter.of(json).beginObject();
-    options.writeDeprecatedJson(jsonWriter, 30L);
-    jsonWriter.endObject().close();
-
-    JsonAssert.assertJson(json.toString()).isSimilarTo("{\"paging\": {\"pageIndex\": 3, \"pageSize\": 10, \"total\": 30, \"fTotal\": \"30\", \"pages\": 3}}");
-  }
-
   @Test
   public void fail_if_result_after_first_10_000() {
     expectedException.expect(IllegalArgumentException.class);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/workflow/OrConditionTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/workflow/OrConditionTest.java
deleted file mode 100644 (file)
index 772e76c..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info 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.server.issue.workflow;
-
-import org.junit.Test;
-import org.sonar.api.issue.Issue;
-import org.sonar.api.issue.condition.Condition;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-
-public class OrConditionTest {
-
-  private static final Condition TRUE_CONDITION = new BooleanCondition(true);
-  private static final Condition FALSE_CONDITION = new BooleanCondition(false);
-  Issue issue = mock(Issue.class);
-
-  @Test
-  public void match() {
-    assertThat(new OrCondition(TRUE_CONDITION).matches(issue)).isTrue();
-    assertThat(new OrCondition(FALSE_CONDITION).matches(issue)).isFalse();
-    assertThat(new OrCondition(FALSE_CONDITION, TRUE_CONDITION).matches(issue)).isTrue();
-    assertThat(new OrCondition(FALSE_CONDITION, FALSE_CONDITION).matches(issue)).isFalse();
-  }
-
-  private static class BooleanCondition implements Condition {
-    private final boolean b;
-
-    public BooleanCondition(boolean b) {
-      this.b = b;
-    }
-
-    @Override
-    public boolean matches(Issue issue) {
-      return b;
-    }
-  }
-}
index fb7b970a7751270a9222086e8b7578462f84936e..b01cbc25a9caff7575f4713e353d78054ef5ceaf 100644 (file)
@@ -31,7 +31,6 @@ import org.junit.Test;
 import org.sonar.api.profiles.ProfileExporter;
 import org.sonar.api.profiles.ProfileImporter;
 import org.sonar.api.profiles.RulesProfile;
-import org.sonar.api.rule.RuleKey;
 import org.sonar.api.rule.RuleStatus;
 import org.sonar.api.rules.Rule;
 import org.sonar.api.rules.RulePriority;
@@ -160,25 +159,6 @@ public class QProfileServiceMediumTest {
     assertThat(stats.get(XOO_P1_KEY).get("countActiveRules").size()).isEqualTo(1);
   }
 
-  @Test
-  public void count_by_deprecated() {
-    logInAsQProfileAdministrator();
-
-    // create deprecated rule
-    RuleDto deprecatedXooRule = RuleTesting.newDto(RuleKey.of("xoo", "deprecated1"))
-      .setSeverity("MINOR").setLanguage("xoo").setStatus(RuleStatus.DEPRECATED);
-    dbClient.ruleDao().insert(dbSession, deprecatedXooRule);
-    dbSession.commit();
-    ruleIndexer.index();
-
-    // active some rules
-    service.activate(XOO_P1_KEY, new RuleActivation(deprecatedXooRule.getKey()).setSeverity("BLOCKER"));
-    service.activate(XOO_P1_KEY, new RuleActivation(RuleTesting.XOO_X1).setSeverity("BLOCKER"));
-    dbSession.commit();
-
-    assertThat(loader.countDeprecatedActiveRulesByProfile(XOO_P1_KEY)).isEqualTo(1);
-  }
-
   public static class XooExporter extends ProfileExporter {
     public XooExporter() {
       super("xootool", "Xoo Tool");
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/BaseDaoTest/schema.sql b/server/sonar-server/src/test/resources/org/sonar/server/db/BaseDaoTest/schema.sql
deleted file mode 100644 (file)
index bf7df35..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-CREATE TABLE "FAKE" (
-  "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
-  "KEE" VARCHAR(200) NOT NULL,
-  "CREATED_AT" TIMESTAMP,
-  "UPDATED_AT" TIMESTAMP
-);
\ No newline at end of file
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/fake/FakeMapper.xml b/server/sonar-server/src/test/resources/org/sonar/server/db/fake/FakeMapper.xml
deleted file mode 100644 (file)
index ade4087..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="org.sonar.server.db.fake.FakeMapper">
-
-  <sql id="selectColumns">
-    f.id,
-    f.kee as "key",
-    f.created_at as "createdAt",
-    f.updated_at as "updatedAt"
-  </sql>
-
-  <select id="selectByKey" parameterType="String" resultType="fake">
-    select
-    <include refid="selectColumns"/>
-    from fake f WHERE f.kee=#{key}
-  </select>
-
-  <insert id="insert" parameterType="fake" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
-    insert into fake (kee, created_at, updated_at)
-    values (#{key}, #{createdAt}, #{updatedAt})
-  </insert>
-
-  <select id="selectAfterDate" resultType="fake" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
-    select
-    <include refid="selectColumns"/>
-    from fake f
-    <where>
-      <if test="date != null">
-        f.updated_at IS NULL or f.updated_at &gt;= #{date}
-      </if>
-    </where>
-  </select>
-
-</mapper>
diff --git a/server/sonar-server/src/test/resources/org/sonar/server/db/invalid_db_data_file b/server/sonar-server/src/test/resources/org/sonar/server/db/invalid_db_data_file
deleted file mode 100644 (file)
index e69de29..0000000