]> source.dussan.org Git - sonarqube.git/commitdiff
Fix Quality flaws
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 30 Sep 2016 08:03:37 +0000 (10:03 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 30 Sep 2016 08:03:37 +0000 (10:03 +0200)
server/sonar-ce/src/main/java/org/sonar/ce/app/StartupBarrier.java
server/sonar-server/src/main/java/org/sonar/server/organization/package-info.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/project/ws/SearchMyProjectsData.java
server/sonar-server/src/main/java/org/sonar/server/rule/ws/SearchAction.java
sonar-db/src/main/java/org/sonar/db/permission/template/PermissionTemplateDao.java
sonar-db/src/main/java/org/sonar/db/permission/template/PermissionTemplateMapper.java
sonar-db/src/main/resources/org/sonar/db/permission/template/PermissionTemplateMapper.xml
sonar-db/src/test/java/org/sonar/db/permission/template/PermissionTemplateDaoTest.java

index a430a10ab271461a703a5d26187f720b0abf0965..5620fa6fa5e1409b37d00d667b498ade9302e143 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.ce.app;
 
-@FunctionalInterface
 interface StartupBarrier {
   /**
    * This blocking call, waits for a process (or anything) to be operational until either it is actually operational, or
diff --git a/server/sonar-server/src/main/java/org/sonar/server/organization/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/organization/package-info.java
new file mode 100644 (file)
index 0000000..5e125d1
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+@ParametersAreNonnullByDefault
+package org.sonar.server.organization;
+
+import javax.annotation.ParametersAreNonnullByDefault;
index c0d90af4fc1eeb60241cc49612e8fa02c5a21065..630a09beff573799471f23581e84d2e869b98e10 100644 (file)
@@ -88,7 +88,7 @@ class SearchMyProjectsData {
 
   private static Map<String, String> buildQualityGateStatuses(List<MeasureDto> measures) {
     return ImmutableMap.copyOf(measures.stream()
-      .collect(Collectors.toMap(measure -> measure.getComponentUuid(), MeasureDto::getData)));
+      .collect(Collectors.toMap(MeasureDto::getComponentUuid, MeasureDto::getData)));
   }
 
   static class Builder {
index ae7a0b8600d3402f8c2a596d4d4eaaee6369ff66..dca7ae7671d71582fe9b72bab68364298dd07ab7 100644 (file)
@@ -354,7 +354,7 @@ public class SearchAction implements RulesWsAction {
     List<RuleKey> ruleKeys = result.getIds();
     // rule order is managed by ES
     Map<RuleKey, RuleDto> rulesByRuleKey = Maps.uniqueIndex(
-      dbClient.ruleDao().selectByKeys(dbSession, ruleKeys), input -> input.getKey());
+      dbClient.ruleDao().selectByKeys(dbSession, ruleKeys), RuleDto::getKey);
     List<RuleDto> rules = new ArrayList<>();
     for (RuleKey ruleKey : ruleKeys) {
       RuleDto rule = rulesByRuleKey.get(ruleKey);
index a4e79acef6dda291a18dc79de59d67195ade5ed6..e10c3bd0ec76def886ab422bbdc79a34d6895cbe 100644 (file)
@@ -67,7 +67,7 @@ public class PermissionTemplateDao implements Dao {
     return executeLargeInputs(logins, l -> mapper(dbSession).selectUserPermissionsByTemplateIdAndUserLogins(templateId, l));
   }
 
-  private List<PermissionTemplateUserDto> selectUserPermissionsByTemplateId(DbSession dbSession, long templateId) {
+  private static List<PermissionTemplateUserDto> selectUserPermissionsByTemplateId(DbSession dbSession, long templateId) {
     return mapper(dbSession).selectUserPermissionsByTemplateIdAndUserLogins(templateId, Collections.emptyList());
   }
 
@@ -126,12 +126,6 @@ public class PermissionTemplateDao implements Dao {
     return mapper(session).selectAll(null);
   }
 
-  public int countAll(DbSession dbSession, String nameQuery) {
-    String upperCasedNameQuery = toUppercaseSqlQuery(nameQuery);
-
-    return mapper(dbSession).countAll(upperCasedNameQuery);
-  }
-
   private static String toUppercaseSqlQuery(String nameMatch) {
     String wildcard = "%";
     return format("%s%s%s", wildcard, nameMatch.toUpperCase(Locale.ENGLISH), wildcard);
index 395ade1a69d0109f6cb3c7962abb7290c0b97a8d..d2d6ef3064c24af54e1992a20395fcddcbf253fa 100644 (file)
@@ -74,8 +74,6 @@ public interface PermissionTemplateMapper {
 
   List<PermissionTemplateDto> selectAll(@Nullable @Param("nameMatch") String nameMatch);
 
-  int countAll(@Param("nameMatch") String nameMatch);
-
   void usersCountByTemplateIdAndPermission(Map<String, Object> parameters, ResultHandler resultHandler);
 
   void groupsCountByTemplateIdAndPermission(Map<String, Object> parameters, ResultHandler resultHandler);
index 224c7f453e80c7c140a24bfabfb2a8e131e87578..985a8e0bf4c48a093f2819e2602b16a6a795372a 100644 (file)
     ORDER BY UPPER(name), name
   </select>
 
-  <select id="countAll" parameterType="String" resultType="int">
-    SELECT count(1)
-    FROM permission_templates
-    <where>
-      <if test="nameMatch!=null">
-        AND (UPPER(name) LIKE #{nameMatch} ESCAPE '/')
-      </if>
-    </where>
-  </select>
-
   <select id="selectByName" parameterType="String" resultType="PermissionTemplate">
     SELECT
     <include refid="templateColumns"/>
index b65ad38ef85a2ae43bbe6cad0befd1200b82d75a..c8fca46b7df05b260de84c134e613f5519e61708 100644 (file)
@@ -329,10 +329,8 @@ public class PermissionTemplateDaoTest {
     templateDb.insertTemplate(newPermissionTemplateDto().setName("aaaccc"));
 
     List<PermissionTemplateDto> templates = underTest.selectAll(dbSession, "aaa");
-    int count = underTest.countAll(dbSession, "aaa");
 
     assertThat(templates.get(0).getName()).isEqualTo("aaabbb");
-    assertThat(count).isEqualTo(2);
   }
 
   @Test