aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-12-07 09:29:57 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-12-07 09:29:57 +0100
commit169c63d511d2f657520c0c301da6ba984fb3b253 (patch)
tree0cce3904cae1454aae27d86dc5d1e1277261334b
parentd25b9bf9edc9561a6d8917f2c236725d05256053 (diff)
downloadsonarqube-169c63d511d2f657520c0c301da6ba984fb3b253.tar.gz
sonarqube-169c63d511d2f657520c0c301da6ba984fb3b253.zip
Fix some quality flaws
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ProfileEventsSensor.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java3
-rw-r--r--sonar-core/src/test/java/org/sonar/core/persistence/dialect/PostgreSQLSequenceGeneratorTest.java12
5 files changed, 19 insertions, 8 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ProfileEventsSensor.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ProfileEventsSensor.java
index 81fd8710fd4..5347109477c 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ProfileEventsSensor.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ProfileEventsSensor.java
@@ -49,12 +49,14 @@ public class ProfileEventsSensor implements Sensor {
Measure pastProfileMeasure = getPreviousMeasure(project, CoreMetrics.PROFILE);
if (pastProfileMeasure == null) {
- return; // first analysis
+ // first analysis
+ return;
}
int pastProfileId = pastProfileMeasure.getIntValue();
Measure pastProfileVersionMeasure = getPreviousMeasure(project, CoreMetrics.PROFILE_VERSION);
final int pastProfileVersion;
- if (pastProfileVersionMeasure == null) { // first analysis with versions
+ // first analysis with versions
+ if (pastProfileVersionMeasure == null) {
pastProfileVersion = 1;
} else {
pastProfileVersion = pastProfileVersionMeasure.getIntValue();
diff --git a/sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java b/sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java
index c0c00ae9be3..f08e78de9a4 100644
--- a/sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java
+++ b/sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java
@@ -188,7 +188,8 @@ public class DefaultPluginMetadata implements PluginMetadata, Comparable<PluginM
*/
public boolean isCompatibleWith(String sonarVersion) {
if (null == this.sonarVersion) {
- return true; // Plugins without sonar version are so old, they are compatible with a version containing this code
+ // Plugins without sonar version are so old, they are compatible with a version containing this code
+ return true;
}
Version minimumVersion = Version.createRelease(this.sonarVersion);
diff --git a/sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java b/sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java
index a5aaf015c3d..62d9219919e 100644
--- a/sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java
+++ b/sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java
@@ -149,7 +149,8 @@ public class PluginClassloaders {
LOG.warn("Plugin " + plugin.getKey() + " is ignored because base plugin is not installed: " + plugin.getBasePlugin());
return false;
}
- base.createChildRealm(plugin.getKey()); // we create new realm to be able to return it by key without conversion to baseKey
+ // we create new realm to be able to return it by key without conversion to baseKey
+ base.createChildRealm(plugin.getKey());
for (File file : plugin.getDeployedFiles()) {
base.addURL(file.toURI().toURL());
}
diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
index 56c09193bac..d24b1194510 100644
--- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
@@ -127,7 +127,8 @@ public class PurgeDao {
List<PurgeableSnapshotDto> result = Lists.newArrayList();
result.addAll(mapper.selectPurgeableSnapshotsWithEvents(resourceId));
result.addAll(mapper.selectPurgeableSnapshotsWithoutEvents(resourceId));
- Collections.sort(result);// sort by date
+ // sort by date
+ Collections.sort(result);
return result;
} finally {
MyBatis.closeQuietly(session);
diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/dialect/PostgreSQLSequenceGeneratorTest.java b/sonar-core/src/test/java/org/sonar/core/persistence/dialect/PostgreSQLSequenceGeneratorTest.java
index 70502a7f5a1..fd7d34270f9 100644
--- a/sonar-core/src/test/java/org/sonar/core/persistence/dialect/PostgreSQLSequenceGeneratorTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/persistence/dialect/PostgreSQLSequenceGeneratorTest.java
@@ -24,8 +24,7 @@ import org.junit.Test;
import java.util.Properties;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
public class PostgreSQLSequenceGeneratorTest {
@@ -37,7 +36,14 @@ public class PostgreSQLSequenceGeneratorTest {
PostgreSQLSequenceGenerator generator = new PostgreSQLSequenceGenerator();
generator.configure(null, props, new PostgreSql.PostgreSQLWithDecimalDialect());
- assertThat(generator.getSequenceName(), is("my_table_id_seq"));
+ assertThat(generator.getSequenceName()).isEqualTo("my_table_id_seq");
}
+ @Test
+ public void should_not_fail_if_table_name_can_not_be_loaded() {
+ Properties props = new Properties();
+ PostgreSQLSequenceGenerator generator = new PostgreSQLSequenceGenerator();
+ generator.configure(null, props, new PostgreSql.PostgreSQLWithDecimalDialect());
+ assertThat(generator.getSequenceName()).isNotEmpty();
+ }
}