aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2014-01-23 11:52:43 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2014-01-23 11:52:43 +0100
commit21e68cde8a2b1f4d8d89105be49ef2787d151c2b (patch)
tree604a2c5bb6c70727feb2ebd00100625bc3a14c8a
parent66bc1a5209be23f425bdd63cccb26f5dcc272697 (diff)
downloadsonarqube-21e68cde8a2b1f4d8d89105be49ef2787d151c2b.tar.gz
sonarqube-21e68cde8a2b1f4d8d89105be49ef2787d151c2b.zip
Fix some quality flaws
-rw-r--r--plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Response.java1
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java22
-rw-r--r--sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Referentials.java3
-rw-r--r--sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/startup/RegisterNewDashboards.java3
7 files changed, 20 insertions, 17 deletions
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java
index d4d545d34d0..d82132e8d15 100644
--- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java
+++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/SonarEngine.java
@@ -105,7 +105,7 @@ public class SonarEngine extends CpdEngine {
return;
}
SonarDuplicationsIndex index = createIndex(project, sourceFiles);
- detect(index, context, project, sourceFiles);
+ detect(index, context, sourceFiles);
}
private SonarDuplicationsIndex createIndex(Project project, Iterable<InputFile> sourceFiles) {
@@ -138,7 +138,7 @@ public class SonarEngine extends CpdEngine {
return index;
}
- private void detect(SonarDuplicationsIndex index, SensorContext context, Project project, Iterable<InputFile> sourceFiles) {
+ private void detect(SonarDuplicationsIndex index, SensorContext context, Iterable<InputFile> sourceFiles) {
ExecutorService executorService = Executors.newSingleThreadExecutor();
try {
for (InputFile inputFile : sourceFiles) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java
index 573679e95a4..b56ac4480fc 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceType.java
@@ -61,7 +61,7 @@ public class ResourceType {
private String qualifier;
private String iconPath;
private boolean hasSourceCode = false;
- private Map<String, String> properties = Maps.newHashMap();
+ private final Map<String, String> properties = Maps.newHashMap();
/**
* Creates a new {@link Builder}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Response.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Response.java
index fb22807ed67..6ca4184bd17 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Response.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Response.java
@@ -23,7 +23,6 @@ import org.sonar.api.utils.text.JsonWriter;
import org.sonar.api.utils.text.XmlWriter;
import java.io.OutputStream;
-import java.io.Writer;
/**
* HTTP response
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java
index d29b30c2208..12977638fdf 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/ZipUtils.java
@@ -96,15 +96,7 @@ public final class ZipUtils {
throw new IOException(ERROR_CREATING_DIRECTORY + parent);
}
- FileOutputStream fos = new FileOutputStream(to);
- InputStream input = null;
- try {
- input = zipFile.getInputStream(entry);
- IOUtils.copy(input, fos);
- } finally {
- IOUtils.closeQuietly(input);
- IOUtils.closeQuietly(fos);
- }
+ copy(zipFile, entry, to);
}
}
}
@@ -115,6 +107,18 @@ public final class ZipUtils {
}
}
+ private static void copy(ZipFile zipFile, ZipEntry entry, File to) throws IOException {
+ FileOutputStream fos = new FileOutputStream(to);
+ InputStream input = null;
+ try {
+ input = zipFile.getInputStream(entry);
+ IOUtils.copy(input, fos);
+ } finally {
+ IOUtils.closeQuietly(input);
+ IOUtils.closeQuietly(fos);
+ }
+ }
+
public static void zipDir(File dir, File zip) throws IOException {
OutputStream out = null;
ZipOutputStream zout = null;
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Referentials.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Referentials.java
index df64c46aacd..4cf805a40e6 100644
--- a/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Referentials.java
+++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/violation/Referentials.java
@@ -113,7 +113,8 @@ class Referentials {
long[] block = new long[VIOLATION_GROUP_SIZE];
int cursor = 0;
while (rs.next()) {
- block[cursor++] = rs.getLong(1);
+ block[cursor] = rs.getLong(1);
+ cursor++;
totalViolations++;
if (cursor == VIOLATION_GROUP_SIZE) {
queue.add(block);
diff --git a/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java b/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java
index 2b481d4c45c..41178cb097b 100644
--- a/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java
+++ b/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java
@@ -43,8 +43,6 @@ import java.util.regex.PatternSyntaxException;
*/
public class InternalPermissionTemplateService implements ServerComponent {
- private static final Logger LOG = LoggerFactory.getLogger(InternalPermissionTemplateService.class);
-
private final PermissionTemplateDao permissionTemplateDao;
private final UserDao userDao;
private final PermissionFinder finder;
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewDashboards.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewDashboards.java
index c94d88a714d..ec3c4cf1d75 100644
--- a/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewDashboards.java
+++ b/sonar-server/src/main/java/org/sonar/server/startup/RegisterNewDashboards.java
@@ -79,7 +79,8 @@ public final class RegisterNewDashboards {
int nextOrderIndex = activeDashboardDao.selectMaxOrderIndexForNullUser() + 1;
for (DashboardDto dashboardDto : new DashboardOrdering().sortedCopy(loadedDashboards)) {
- activate(dashboardDto, nextOrderIndex++);
+ activate(dashboardDto, nextOrderIndex);
+ nextOrderIndex++;
}
}