Method getValueSource
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
MapBasedValueSource getValueSource(GitRepository repository)
throws GitRepositoryException {
GitTagDescription description = repository.describe();
String abbrevId = repository.getAbbreviatedCommitId();
Avoid excessively long variable names like tempSourceFileStream Open
try (FileOutputStream tempSourceFileStream = new FileOutputStream(tempSourceFile)) {
- Read upRead up
- Exclude checks
LongVariable
Since: PMD 0.3
Priority: Medium
Categories: Style
Remediation Points: 50000
Fields, formal arguments, or local variable names that are too long can make the code difficult to follow.
Example:
public class Something {
int reallyLongIntName = -3; // VIOLATION - Field
public static void main( String argumentsList[] ) { // VIOLATION - Formal
int otherReallyLongName = -5; // VIOLATION - Local
for (int interestingIntIndex = 0; // VIOLATION - For
interestingIntIndex < 10;
interestingIntIndex ++ ) {
}
}
When instantiating a SimpleDateFormat object, specify a Locale Open
values.put("TIMESTAMP", new SimpleDateFormat(dateFormat).format(new Date()));
- Read upRead up
- Exclude checks
SimpleDateFormatNeedsLocale
Since: PMD 2.0
Priority: Medium
Categories: Style
Remediation Points: 50000
Be sure to specify a Locale when creating SimpleDateFormat instances to ensure that locale-appropriate formatting is used.
Example:
public class Foo {
// Should specify Locale.US (or whatever)
private SimpleDateFormat sdf = new SimpleDateFormat('pattern');
}
Prefer StringBuilder (non-synchronized) or StringBuffer (synchronized) over += for concatenating strings Open
shaId += dirtyFlag;
- Read upRead up
- Exclude checks
UseStringBufferForStringAppends
Since: PMD 3.1
Priority: Medium
Categories: Style
Remediation Points: 50000
The use of the '+=' operator for appending strings causes the JVM to create and use an internal StringBuffer. If a non-trivial number of these concatenations are being used then the explicit use of a StringBuilder or threadsafe StringBuffer is recommended to avoid this.
Example:
public class Foo {
void bar() {
String a;
a = 'foo';
a += ' bar';
// better would be:
// StringBuilder a = new StringBuilder('foo');
// a.append(' bar');
}
}
Prefer StringBuilder (non-synchronized) or StringBuffer (synchronized) over += for concatenating strings Open
abbrevId += dirtyFlag;
- Read upRead up
- Exclude checks
UseStringBufferForStringAppends
Since: PMD 3.1
Priority: Medium
Categories: Style
Remediation Points: 50000
The use of the '+=' operator for appending strings causes the JVM to create and use an internal StringBuffer. If a non-trivial number of these concatenations are being used then the explicit use of a StringBuilder or threadsafe StringBuffer is recommended to avoid this.
Example:
public class Foo {
void bar() {
String a;
a = 'foo';
a += ' bar';
// better would be:
// StringBuilder a = new StringBuilder('foo');
// a.append(' bar');
}
}
Prefer StringBuilder (non-synchronized) or StringBuffer (synchronized) over += for concatenating strings Open
describe += dirtyFlag;
- Read upRead up
- Exclude checks
UseStringBufferForStringAppends
Since: PMD 3.1
Priority: Medium
Categories: Style
Remediation Points: 50000
The use of the '+=' operator for appending strings causes the JVM to create and use an internal StringBuffer. If a non-trivial number of these concatenations are being used then the explicit use of a StringBuilder or threadsafe StringBuffer is recommended to avoid this.
Example:
public class Foo {
void bar() {
String a;
a = 'foo';
a += ' bar';
// better would be:
// StringBuilder a = new StringBuilder('foo');
// a.append(' bar');
}
}
Avoid excessively long variable names like BUILTIN_TEMPLATE_PATH Open
private static final String BUILTIN_TEMPLATE_PATH = "TemplateGitInfoClass.java";
- Read upRead up
- Exclude checks
LongVariable
Since: PMD 0.3
Priority: Medium
Categories: Style
Remediation Points: 50000
Fields, formal arguments, or local variable names that are too long can make the code difficult to follow.
Example:
public class Something {
int reallyLongIntName = -3; // VIOLATION - Field
public static void main( String argumentsList[] ) { // VIOLATION - Formal
int otherReallyLongName = -5; // VIOLATION - Local
for (int interestingIntIndex = 0; // VIOLATION - For
interestingIntIndex < 10;
interestingIntIndex ++ ) {
}
}