aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2011-08-02 19:31:32 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2011-08-02 19:31:32 +0200
commit9a4e0131a585315318fe4aabf7dc0a7f95fd7433 (patch)
tree737b081acdb4af7f1c44ca2856cc6c6f4b517d1c
parent1f5682409af97410aca5e545ccbd40b6b037e6a9 (diff)
downloadsonarqube-9a4e0131a585315318fe4aabf7dc0a7f95fd7433.tar.gz
sonarqube-9a4e0131a585315318fe4aabf7dc0a7f95fd7433.zip
Some code improvements
-rw-r--r--plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/BytecodeVisitorsTest.java39
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Reactor.java2
-rw-r--r--sonar-graph/src/test/java/org/sonar/graph/DsmCellTest.java45
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractDirectoriesDecorator.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java3
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java7
-rw-r--r--sonar-server/src/main/java/org/sonar/server/startup/ActivateDefaultProfiles.java3
-rw-r--r--sonar-server/src/main/java/org/sonar/server/startup/RegisterProvidedProfiles.java8
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewUpdateQuery.java2
11 files changed, 26 insertions, 93 deletions
diff --git a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/BytecodeVisitorsTest.java b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/BytecodeVisitorsTest.java
index 6ac724dc307..2ced1147d4b 100644
--- a/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/BytecodeVisitorsTest.java
+++ b/plugins/sonar-squid-java-plugin/src/test/java/org/sonar/java/bytecode/BytecodeVisitorsTest.java
@@ -19,35 +19,23 @@
*/
package org.sonar.java.bytecode;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.List;
-import java.util.Set;
-
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.util.TraceClassVisitor;
import org.sonar.java.ast.JavaAstScanner;
import org.sonar.java.ast.SquidTestUtils;
import org.sonar.java.bytecode.asm.AsmResource;
import org.sonar.java.squid.JavaSquidConfiguration;
import org.sonar.squid.Squid;
-import org.sonar.squid.api.SourceClass;
import org.sonar.squid.api.SourceCode;
import org.sonar.squid.api.SourceCodeEdgeUsage;
-import org.sonar.squid.api.SourceFile;
import org.sonar.squid.measures.Metric;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
public class BytecodeVisitorsTest {
static Squid squid;
@@ -237,19 +225,4 @@ public class BytecodeVisitorsTest {
public void testEfferentCouplingAtPackageLevel() {
assertEquals(0, pacTag.getInt(Metric.CE));
}
-
- @Test
- @Ignore
- public void testClassWithEnum() throws IOException {
- SourceFile classWithEnum = (SourceFile) squid.search("specialCases/ClassWithEnum.java");
- SourceClass myEnum = (SourceClass) squid.search("specialCases/ClassWithEnum$MyEnum");
-
- ClassReader asmReader = new ClassReader(new FileInputStream(SquidTestUtils.getFile("/bytecode/bin/specialCases/ClassWithEnum$MyEnum.class")));
- TraceClassVisitor classVisitor = new TraceClassVisitor(new PrintWriter(System.out));
- asmReader.accept(classVisitor, 0);
- classVisitor.print(new PrintWriter(System.out));
-
- assertThat(classWithEnum, is(notNullValue()));
- assertThat(myEnum, is(notNullValue()));
- }
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java b/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java
index 6f848ce7e37..10548b7169e 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/ProjectTree.java
@@ -40,8 +40,10 @@ public class ProjectTree {
private List<Project> projects;
private Map<ProjectDefinition, Project> projectsByDef;
-
- public ProjectTree(ProjectReactor projectReactor, DatabaseSession databaseSession, /* Must be executed after ProjectBuilders */ ProjectBuilder[] builders) {
+
+ public ProjectTree(ProjectReactor projectReactor, //NOSONAR the unused parameter 'builders' is used for the startup order of components
+ DatabaseSession databaseSession,
+ /* Must be executed after ProjectBuilders */ ProjectBuilder[] builders) {
this(projectReactor, databaseSession);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Reactor.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Reactor.java
index 9301cd0ce48..216996a9343 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Reactor.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Reactor.java
@@ -36,7 +36,7 @@ public class Reactor {
this.root = root;
}
- public Reactor(List<ProjectDefinition> sortedProjects) {
+ public Reactor(List<ProjectDefinition> sortedProjects) {//NOSONAR unused parameter is kept for backward-compatibility of API
throw new IllegalArgumentException("This constructor is not supported anymore");
}
diff --git a/sonar-graph/src/test/java/org/sonar/graph/DsmCellTest.java b/sonar-graph/src/test/java/org/sonar/graph/DsmCellTest.java
deleted file mode 100644
index 24fd45df840..00000000000
--- a/sonar-graph/src/test/java/org/sonar/graph/DsmCellTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.graph;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.sonar.graph.DsmCell;
-import org.sonar.graph.StringEdge;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertThat;
-
-public class DsmCellTest {
-
- @Test
- @Ignore
- public void testEquals() {
- DsmCell cell1 = new DsmCell(new StringEdge("A", "B", 1), true);
- DsmCell cell1bis = new DsmCell(new StringEdge("A", "B", 1), false);
- DsmCell cell4 = new DsmCell(new StringEdge("B", "A", 4), true);
-
- assertThat(cell1, equalTo(cell1));
- assertThat(cell1, equalTo(cell1bis));
- assertThat(cell1, not(equalTo(cell4)));
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractDirectoriesDecorator.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractDirectoriesDecorator.java
index df91617c705..9389c08819c 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractDirectoriesDecorator.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractDirectoriesDecorator.java
@@ -36,7 +36,7 @@ public abstract class AbstractDirectoriesDecorator implements Decorator {
/**
* @param language this will be use to defined whether the decorator should be executed on a project
*/
- public AbstractDirectoriesDecorator(Language language) {
+ public AbstractDirectoriesDecorator(Language language) {//NOSONAR this unused parameter is kept for backward-compatibility of API
}
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java
index 2afffb5e307..c0a56de9dd3 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/MeasureModel.java
@@ -78,7 +78,7 @@ public class MeasureModel implements Cloneable {
*/
@Deprecated
@Column(name = "rules_category_id", nullable = true)
- private Integer rulesCategoryId;
+ private Integer rulesCategoryId;//NOSONAR this field is kept for backward-compatiblity of API
@Column(name = "rule_priority", updatable = false, nullable = true)
@Enumerated(EnumType.ORDINAL)
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java
index a3893cd227c..097fa7a2ba9 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java
@@ -76,9 +76,8 @@ public class HttpDownloader implements BatchComponent, ServerComponent {
}
private void initUserAgent(String sonarVersion) {
- String userAgent = (sonarVersion == null ? "Sonar" : String.format("Sonar %s", sonarVersion));
+ userAgent = (sonarVersion == null ? "Sonar" : String.format("Sonar %s", sonarVersion));
System.setProperty("http.agent", userAgent);
- this.userAgent = userAgent;
}
public String getProxySynthesis(URI uri) {
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java
index 9b1d470afef..8e386c8603f 100644
--- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java
+++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/HttpDownloaderTest.java
@@ -22,6 +22,7 @@ package org.sonar.api.utils;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.SystemUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
@@ -36,14 +37,15 @@ import java.util.Arrays;
import java.util.Properties;
import static org.hamcrest.Matchers.greaterThan;
+import static org.hamcrest.Matchers.not;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assume.assumeThat;
import static org.junit.internal.matchers.StringContains.containsString;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-@Ignore("Temporarily deactivated because it sometimes freezes on MS Windows")
public class HttpDownloaderTest {
private static ServletTester tester;
@@ -51,6 +53,9 @@ public class HttpDownloaderTest {
@BeforeClass
public static void startServer() throws Exception {
+ // Temporarily deactivated on Windows because it sometimes freezes
+ assumeThat(SystemUtils.IS_OS_WINDOWS, is(false));
+
tester = new ServletTester();
tester.setContextPath("/");
tester.addServlet(RedirectServlet.class, "/redirect/");
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/ActivateDefaultProfiles.java b/sonar-server/src/main/java/org/sonar/server/startup/ActivateDefaultProfiles.java
index c780c14e719..6fd37a917b4 100644
--- a/sonar-server/src/main/java/org/sonar/server/startup/ActivateDefaultProfiles.java
+++ b/sonar-server/src/main/java/org/sonar/server/startup/ActivateDefaultProfiles.java
@@ -33,8 +33,7 @@ public final class ActivateDefaultProfiles {
private final DatabaseSessionFactory sessionFactory;
private final Language[] languages;
- // NOSONAR the parameter registerProfilesBefore is used to define the execution order of startup components
- public ActivateDefaultProfiles(DatabaseSessionFactory sessionFactory, Language[] languages, RegisterProvidedProfiles registerProfilesBefore) {
+ public ActivateDefaultProfiles(DatabaseSessionFactory sessionFactory, Language[] languages, RegisterProvidedProfiles registerProfilesBefore) {// NOSONAR the parameter registerProfilesBefore is used to define the execution order of startup components
this.sessionFactory = sessionFactory;
this.languages = languages;
}
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterProvidedProfiles.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterProvidedProfiles.java
index 1c69748debc..2da46a9255f 100644
--- a/sonar-server/src/main/java/org/sonar/server/startup/RegisterProvidedProfiles.java
+++ b/sonar-server/src/main/java/org/sonar/server/startup/RegisterProvidedProfiles.java
@@ -43,16 +43,16 @@ public final class RegisterProvidedProfiles {
private List<ProfileDefinition> definitions = Lists.newArrayList();
private RuleFinder ruleFinder;
- public RegisterProvidedProfiles(RuleFinder ruleFinder, DatabaseSessionFactory sessionFactory,
- RegisterRules registerRulesBefore,// NOSONAR the parameter registerRulesBefore is unused must be declared for execution order of tasks
+ public RegisterProvidedProfiles(RuleFinder ruleFinder, DatabaseSessionFactory sessionFactory,// NOSONAR the parameter registerRulesBefore is unused must be declared for execution order of tasks
+ RegisterRules registerRulesBefore,
ProfileDefinition[] definitions) {
this.ruleFinder = ruleFinder;
this.sessionFactory = sessionFactory;
this.definitions.addAll(Arrays.asList(definitions));
}
- public RegisterProvidedProfiles(RuleFinder ruleFinder, DatabaseSessionFactory sessionFactory,
- RegisterRules registerRulesBefore) {// NOSONAR the parameter registerRulesBefore is unused must be declared for execution order of tasks
+ public RegisterProvidedProfiles(RuleFinder ruleFinder, DatabaseSessionFactory sessionFactory,// NOSONAR the parameter registerRulesBefore is unused must be declared for execution order of tasks
+ RegisterRules registerRulesBefore) {
this.ruleFinder = ruleFinder;
this.sessionFactory = sessionFactory;
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewUpdateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewUpdateQuery.java
index 62e8cdd583a..2050ce0b0ac 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewUpdateQuery.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewUpdateQuery.java
@@ -22,7 +22,7 @@ package org.sonar.wsclient.services;
/**
* @since 2.9
*/
-public class ReviewUpdateQuery extends UpdateQuery<Review> {
+public final class ReviewUpdateQuery extends UpdateQuery<Review> {
private long reviewId;
private String action;