PMD optimizations.

This commit is contained in:
Erik C. Thauvin 2016-01-25 11:57:18 -08:00
parent 4c66bf6299
commit 5683ff853c
8 changed files with 70 additions and 18 deletions

View file

@ -69,7 +69,7 @@ bintray {
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
publications = ['MyPublication'] publications = ['MyPublication']
dryRun = false dryRun = true
pkg { pkg {
repo = 'maven' repo = 'maven'
name = mavenName name = mavenName

View file

@ -19,7 +19,7 @@
<orderEntry type="library" name="Gradle: org.apache.velocity:velocity:1.7" level="project" /> <orderEntry type="library" name="Gradle: org.apache.velocity:velocity:1.7" level="project" />
<orderEntry type="library" name="Gradle: commons-collections:commons-collections:3.2.1" level="project" /> <orderEntry type="library" name="Gradle: commons-collections:commons-collections:3.2.1" level="project" />
<orderEntry type="library" name="Gradle: commons-lang:commons-lang:2.4" level="project" /> <orderEntry type="library" name="Gradle: commons-lang:commons-lang:2.4" level="project" />
<orderEntry type="library" name="Gradle: net.thauvin.erik:semver:0.9.0-beta" level="project" /> <orderEntry type="library" name="Gradle: net.thauvin.erik:semver:0.9.1-beta" level="project" />
</component> </component>
<component name="org.twodividedbyzero.idea.findbugs"> <component name="org.twodividedbyzero.idea.findbugs">
<option name="_basePreferences"> <option name="_basePreferences">

View file

@ -13,7 +13,7 @@ import java.util.Date;
*/ */
public final class GeneratedVersion { public final class GeneratedVersion {
private final static String buildmeta = ""; private final static String buildmeta = "";
private final static Date date = new Date(1453601787705L); private final static Date date = new Date(1453751280926L);
private final static int major = 3; private final static int major = 3;
private final static int minor = 1; private final static int minor = 1;
private final static int patch = 37; private final static int patch = 37;
@ -30,12 +30,28 @@ public final class GeneratedVersion {
} }
/** /**
* Returns the full version. * Returns the full version string.
* <p>
* Formatted as:
* <blockquote>
* <code>MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]</code>
* </blockquote>
* <p>
* For example:
* <ul>
* <li><code>1.0.0</code></li>
* <li><code>1.0.0-beta</code></li>
* <li><code>1.0.0+20160124144700</code></li>
* <li><code>1.0.0-alpha+001</code></li>
* </ul>
* *
* @return The full version string. * @return The version string.
*/ */
public static String getVersion() { public static String getVersion() {
return "" + getMajor() + '.' + getMinor() + '.' + getPatch() + getPreRelease() + getBuildMetadata(); return Integer.toString(getMajor()) + '.'
+ Integer.toString(getMinor()) + '.'
+ Integer.toString(getPatch())
+ getPreRelease() + getBuildMetadata();
} }
/** /**
@ -99,4 +115,14 @@ public final class GeneratedVersion {
return ""; return "";
} }
/**
* Disables the default constructor.
*
* @throws UnsupportedOperationException if the constructor is called.
*/
private GeneratedVersion()
throws UnsupportedOperationException {
throw new UnsupportedOperationException("Illegal constructor call.");
}
} }

View file

@ -357,13 +357,13 @@
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/commons-lang/commons-lang/2.4/2b8c4b3035e45520ef42033e823c7d33e4b4402c/commons-lang-2.4-sources.jar!/" /> <root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/commons-lang/commons-lang/2.4/2b8c4b3035e45520ef42033e823c7d33e4b4402c/commons-lang-2.4-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
<library name="Gradle: net.thauvin.erik:semver:0.9.0-beta"> <library name="Gradle: net.thauvin.erik:semver:0.9.1-beta">
<CLASSES> <CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/thauvin/erik/semver/0.9.0-beta/semver-0.9.0-beta.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/net/thauvin/erik/semver/0.9.1-beta/semver-0.9.1-beta.jar!/" />
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/thauvin/erik/semver/0.9.0-beta/semver-0.9.0-beta-sources.jar!/" /> <root url="jar://$MAVEN_REPOSITORY$/net/thauvin/erik/semver/0.9.1-beta/semver-0.9.1-beta-sources.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
<library name="Gradle: org.apache.velocity:velocity:1.7"> <library name="Gradle: org.apache.velocity:velocity:1.7">

View file

@ -108,7 +108,7 @@ public final class Constants
/** /**
* Disables the default constructor. * Disables the default constructor.
* *
* @throws UnsupportedOperationException if an error occurred. if the constructor is called. * @throws UnsupportedOperationException if the constructor is called.
*/ */
private Constants() private Constants()
throws UnsupportedOperationException throws UnsupportedOperationException

View file

@ -207,7 +207,7 @@ public class VersionInfo
* *
* @param project The new project name. * @param project The new project name.
*/ */
public void setProject(String project) public void setProject(final String project)
{ {
this.project = project; this.project = project;
} }
@ -230,7 +230,7 @@ public class VersionInfo
*/ */
public String getVersion() public String getVersion()
{ {
return "" + major + '.' + minor + '.' + patch + (prerelease.length() > 0 ? '-' + prerelease : "") + ( return Integer.toString(major) + '.' + Integer.toString(minor) + '.' + Integer.toString(patch) + (
buildmeta.length() > 0 ? '+' + buildmeta : ""); prerelease.length() > 0 ? '-' + prerelease : "") + (buildmeta.length() > 0 ? '+' + buildmeta : "");
} }
} }

View file

@ -170,7 +170,7 @@ public class VersionProcessor extends AbstractProcessor
} }
catch (IOException e) catch (IOException e)
{ {
error("IOException occurred while running annotation processor", e); error("IOException occurred while running the annotation processor", e);
} }
} }
} }
@ -192,7 +192,7 @@ public class VersionProcessor extends AbstractProcessor
{ {
try try
{ {
return Integer.parseInt(p.getProperty(property, "" + defaultValue)); return Integer.parseInt(p.getProperty(property, Integer.toString(defaultValue)));
} }
catch (NumberFormatException ignore) catch (NumberFormatException ignore)
{ {

View file

@ -30,12 +30,28 @@ public final class ${className} {
} }
/** /**
* Returns the full version. * Returns the full version string.
* <p>
* Formatted as:
* <blockquote>
* <code>MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]</code>
* </blockquote>
* <p>
* For example:
* <ul>
* <li><code>1.0.0</code></li>
* <li><code>1.0.0-beta</code></li>
* <li><code>1.0.0+20160124144700</code></li>
* <li><code>1.0.0-alpha+001</code></li>
* </ul>
* *
* @return The full version string. * @return The version string.
*/ */
public static String getVersion() { public static String getVersion() {
return "" + getMajor() + '.' + getMinor() + '.' + getPatch() + getPreRelease() + getBuildMetadata(); return Integer.toString(getMajor()) + '.'
+ Integer.toString(getMinor()) + '.'
+ Integer.toString(getPatch())
+ getPreRelease() + getBuildMetadata();
} }
/** /**
@ -99,4 +115,14 @@ public final class ${className} {
return ""; return "";
} }
/**
* Disables the default constructor.
*
* @throws UnsupportedOperationException if the constructor is called.
*/
private ${className}()
throws UnsupportedOperationException {
throw new UnsupportedOperationException("Illegal constructor call.");
}
} }