From 169c63d511d2f657520c0c301da6ba984fb3b253 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Fri, 7 Dec 2012 09:29:57 +0100 Subject: [PATCH] Fix some quality flaws --- .../plugins/core/sensors/ProfileEventsSensor.java | 6 ++++-- .../sonar/core/plugins/DefaultPluginMetadata.java | 3 ++- .../org/sonar/core/plugins/PluginClassloaders.java | 3 ++- .../src/main/java/org/sonar/core/purge/PurgeDao.java | 3 ++- .../dialect/PostgreSQLSequenceGeneratorTest.java | 12 +++++++++--- 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 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(); + } } -- 2.39.5