]> source.dussan.org Git - sonarqube.git/commitdiff
Fix some quality flaws
authorSimon Brandhof <simon.brandhof@gmail.com>
Fri, 7 Dec 2012 08:29:57 +0000 (09:29 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Fri, 7 Dec 2012 08:29:57 +0000 (09:29 +0100)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/sensors/ProfileEventsSensor.java
sonar-core/src/main/java/org/sonar/core/plugins/DefaultPluginMetadata.java
sonar-core/src/main/java/org/sonar/core/plugins/PluginClassloaders.java
sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
sonar-core/src/test/java/org/sonar/core/persistence/dialect/PostgreSQLSequenceGeneratorTest.java

index 81fd8710fd49e6773268e503f1580cc5a9597e75..5347109477c7e6d40f08cd477f1a0f8bf4b96d19 100644 (file)
@@ -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();
index c0c00ae9be3e41d6597427f4b6985f91b49d5454..f08e78de9a40a0b070553fd7b791003e8279d997 100644 (file)
@@ -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);
index a5aaf015c3d42d4c7ad99fb2b73cf54df302b60d..62d9219919e7c1e38942623c3e06812a0d993ee4 100644 (file)
@@ -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());
       }
index 56c09193bac304225f6d83d7edd752d88e832ad1..d24b11945104e74a90200a0c84dcb5fe0a1d6882 100644 (file)
@@ -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);
index 70502a7f5a1b5a829370c3359ef6172167b9175d..fd7d34270f9574d0e52ee2c9b5bc25504b27fb6e 100644 (file)
@@ -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();
+  }
 }