From e0a73badff633721360fd042b0c3bb3a581e052c Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Thu, 6 Feb 2014 10:50:29 +0100 Subject: [PATCH] Fix quality flaws --- .../profiling/AbstractTimeProfiling.java | 11 +++------- .../org/sonar/colorizer/HtmlDecorator.java | 4 +++- .../org/sonar/api/server/ws/WsTester.java | 3 ++- .../org/sonar/api/server/ws/package-info.java | 22 +++++++++++++++++++ 4 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 sonar-testing-harness/src/main/java/org/sonar/api/server/ws/package-info.java diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java index 88bce9a51cf..19d65ba1436 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java +++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/AbstractTimeProfiling.java @@ -24,13 +24,7 @@ import org.sonar.api.utils.TimeUtils; import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.util.*; public abstract class AbstractTimeProfiling { @@ -94,9 +88,10 @@ public abstract class AbstractTimeProfiling { List result = new ArrayList(maxSize); int i = 0; for (G item : sortedList) { - if (i++ >= maxSize || item.totalTime() == 0) { + if (i >= maxSize || item.totalTime() == 0) { return result; } + i++; result.add(item); } return result; diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlDecorator.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlDecorator.java index 1090700f6a8..3726104ec6c 100644 --- a/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlDecorator.java +++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/HtmlDecorator.java @@ -67,7 +67,9 @@ public class HtmlDecorator extends Tokenizer { } public String getTagBefore() { - return "
";
+    String tag = "
";
+    lineId++;
+    return tag;
   }
 
   public String getTagAfter() {
diff --git a/sonar-testing-harness/src/main/java/org/sonar/api/server/ws/WsTester.java b/sonar-testing-harness/src/main/java/org/sonar/api/server/ws/WsTester.java
index 568f0b4cb7e..dd66f4ae43a 100644
--- a/sonar-testing-harness/src/main/java/org/sonar/api/server/ws/WsTester.java
+++ b/sonar-testing-harness/src/main/java/org/sonar/api/server/ws/WsTester.java
@@ -26,6 +26,7 @@ import org.sonar.api.utils.text.JsonWriter;
 import org.sonar.api.utils.text.XmlWriter;
 
 import javax.annotation.CheckForNull;
+
 import java.io.ByteArrayOutputStream;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
@@ -83,7 +84,7 @@ public class WsTester {
       return params.get(key);
     }
 
-    public Result execute() throws Exception {
+    public Result execute() {
       TestResponse response = new TestResponse();
       action.handler().handle(this, response);
       return new Result(response);
diff --git a/sonar-testing-harness/src/main/java/org/sonar/api/server/ws/package-info.java b/sonar-testing-harness/src/main/java/org/sonar/api/server/ws/package-info.java
new file mode 100644
index 00000000000..40cefaf5428
--- /dev/null
+++ b/sonar-testing-harness/src/main/java/org/sonar/api/server/ws/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 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.
+ */
+
+@javax.annotation.ParametersAreNonnullByDefault
+package org.sonar.api.server.ws;
-- 
2.39.5