diff options
author | David Gageot <david@gageot.net> | 2012-04-30 07:41:40 +0200 |
---|---|---|
committer | David Gageot <david@gageot.net> | 2012-04-30 07:42:50 +0200 |
commit | bd01ac1036d4a85c1cc434d720f0897a3f7b5fd3 (patch) | |
tree | 1a68ff2029bff8d373d6592a007c722fc9bf8667 /plugins/sonar-pmd-plugin | |
parent | 3737f347c08fc3ada5eb98a0126a513f7baeafc8 (diff) | |
download | sonarqube-bd01ac1036d4a85c1cc434d720f0897a3f7b5fd3.tar.gz sonarqube-bd01ac1036d4a85c1cc434d720f0897a3f7b5fd3.zip |
A singleton is not needed. The code can be simpler
Diffstat (limited to 'plugins/sonar-pmd-plugin')
-rw-r--r-- | plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdVersion.java | 17 | ||||
-rw-r--r-- | plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdVersionTest.java | 2 |
2 files changed, 6 insertions, 13 deletions
diff --git a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdVersion.java b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdVersion.java index abbb79a34e9..0b70b225453 100644 --- a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdVersion.java +++ b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdVersion.java @@ -26,29 +26,22 @@ import java.io.IOException; import java.io.InputStream; import java.util.Properties; -public enum PmdVersion { - INSTANCE; - +public final class PmdVersion { private static final String PROPERTIES_PATH = "/org/sonar/plugins/pmd/pmd-plugin.properties"; - private String version; - - public static String getVersion() { - return INSTANCE.version; - } private PmdVersion() { - version = readVersion(); + // Static utility class } - public String readVersion() { + public static String getVersion() { Properties properties = new Properties(); InputStream input = null; try { - input = getClass().getResourceAsStream(PROPERTIES_PATH); + input = PmdVersion.class.getResourceAsStream(PROPERTIES_PATH); properties.load(input); } catch (IOException e) { - LoggerFactory.getLogger(getClass()).warn("Can not load the PMD version from the file " + PROPERTIES_PATH); + LoggerFactory.getLogger(PmdVersion.class).warn("Can not load the PMD version from the file " + PROPERTIES_PATH); } finally { Closeables.closeQuietly(input); } diff --git a/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdVersionTest.java b/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdVersionTest.java index 2b325d5e7e7..c373456029c 100644 --- a/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdVersionTest.java +++ b/plugins/sonar-pmd-plugin/src/test/java/org/sonar/plugins/pmd/PmdVersionTest.java @@ -26,6 +26,6 @@ import static org.fest.assertions.Assertions.assertThat; public class PmdVersionTest { @Test public void should_get_pmd_version() { - assertThat(PmdVersion.getVersion()).isNotEmpty().isSameAs(PmdVersion.getVersion()); + assertThat(PmdVersion.getVersion()).isNotEmpty(); } } |