Merge pull request #405 from awhitford/StringToChar

One character String constants with char constants
This commit is contained in:
Jeremy Long
2015-11-03 05:43:41 -05:00
11 changed files with 31 additions and 32 deletions

View File

@@ -840,8 +840,7 @@ public class DependencyCheckScanAgent {
*/ */
private Engine executeDependencyCheck() throws DatabaseException { private Engine executeDependencyCheck() throws DatabaseException {
populateSettings(); populateSettings();
Engine engine = null; final Engine engine = new Engine();
engine = new Engine();
engine.setDependencies(this.dependencies); engine.setDependencies(this.dependencies);
engine.analyzeDependencies(); engine.analyzeDependencies();
return engine; return engine;

View File

@@ -335,7 +335,7 @@ public class CPEAnalyzer implements Analyzer {
* @return if the append was successful. * @return if the append was successful.
*/ */
private boolean appendWeightedSearch(StringBuilder sb, String field, String searchText, Set<String> weightedText) { private boolean appendWeightedSearch(StringBuilder sb, String field, String searchText, Set<String> weightedText) {
sb.append(" ").append(field).append(":( "); sb.append(' ').append(field).append(":( ");
final String cleanText = cleanseText(searchText); final String cleanText = cleanseText(searchText);
@@ -364,7 +364,7 @@ public class CPEAnalyzer implements Analyzer {
break; break;
} }
} }
sb.append(" "); sb.append(' ');
if (temp == null) { if (temp == null) {
LuceneUtils.appendEscapedLuceneQuery(sb, word); LuceneUtils.appendEscapedLuceneQuery(sb, word);
} else { } else {
@@ -522,7 +522,7 @@ public class CPEAnalyzer implements Analyzer {
for (VulnerableSoftware vs : cpes) { for (VulnerableSoftware vs : cpes) {
DependencyVersion dbVer; DependencyVersion dbVer;
if (vs.getUpdate() != null && !vs.getUpdate().isEmpty()) { if (vs.getUpdate() != null && !vs.getUpdate().isEmpty()) {
dbVer = DependencyVersionUtil.parseVersion(vs.getVersion() + "." + vs.getUpdate()); dbVer = DependencyVersionUtil.parseVersion(vs.getVersion() + '.' + vs.getUpdate());
} else { } else {
dbVer = DependencyVersionUtil.parseVersion(vs.getVersion()); dbVer = DependencyVersionUtil.parseVersion(vs.getVersion());
} }

View File

@@ -113,7 +113,7 @@ public class FalsePositiveAnalyzer extends AbstractAnalyzer {
for (Identifier i : dependency.getIdentifiers()) { for (Identifier i : dependency.getIdentifiers()) {
if ("maven".contains(i.getType())) { if ("maven".contains(i.getType())) {
if (i.getValue() != null && i.getValue().startsWith("org.springframework.")) { if (i.getValue() != null && i.getValue().startsWith("org.springframework.")) {
final int endPoint = i.getValue().indexOf(":", 19); final int endPoint = i.getValue().indexOf(':', 19);
if (endPoint >= 0) { if (endPoint >= 0) {
mustContain = i.getValue().substring(19, endPoint).toLowerCase(); mustContain = i.getValue().substring(19, endPoint).toLowerCase();
break; break;
@@ -472,8 +472,8 @@ public class FalsePositiveAnalyzer extends AbstractAnalyzer {
*/ */
private String trimCpeToVendor(String value) { private String trimCpeToVendor(String value) {
//cpe:/a:jruby:jruby:1.0.8 //cpe:/a:jruby:jruby:1.0.8
final int pos1 = value.indexOf(":", 7); //right of vendor final int pos1 = value.indexOf(':', 7); //right of vendor
final int pos2 = value.indexOf(":", pos1 + 1); //right of product final int pos2 = value.indexOf(':', pos1 + 1); //right of product
if (pos2 < 0) { if (pos2 < 0) {
return value; return value;
} else { } else {

View File

@@ -48,7 +48,7 @@ public class IndexEntry implements Serializable {
*/ */
public String getDocumentId() { public String getDocumentId() {
if (documentId == null && vendor != null && product != null) { if (documentId == null && vendor != null && product != null) {
documentId = vendor + ":" + product; documentId = vendor + ':' + product;
} }
return documentId; return documentId;
} }

View File

@@ -94,13 +94,13 @@ public class MavenArtifact {
} }
if (jarAvailable) { if (jarAvailable) {
//org/springframework/spring-core/3.2.0.RELEASE/spring-core-3.2.0.RELEASE.pom //org/springframework/spring-core/3.2.0.RELEASE/spring-core-3.2.0.RELEASE.pom
this.artifactUrl = base + groupId.replace('.', '/') + "/" + artifactId + "/" this.artifactUrl = base + groupId.replace('.', '/') + '/' + artifactId + '/'
+ version + "/" + artifactId + "-" + version + ".jar"; + version + '/' + artifactId + '-' + version + ".jar";
} }
if (pomAvailable) { if (pomAvailable) {
//org/springframework/spring-core/3.2.0.RELEASE/spring-core-3.2.0.RELEASE.pom //org/springframework/spring-core/3.2.0.RELEASE/spring-core-3.2.0.RELEASE.pom
this.pomUrl = base + groupId.replace('.', '/') + "/" + artifactId + "/" this.pomUrl = base + groupId.replace('.', '/') + '/' + artifactId + '/'
+ version + "/" + artifactId + "-" + version + ".pom"; + version + '/' + artifactId + '-' + version + ".pom";
} }
} }

View File

@@ -392,7 +392,7 @@ public class CveDB {
if (cwe != null) { if (cwe != null) {
final String name = CweDB.getCweName(cwe); final String name = CweDB.getCweName(cwe);
if (name != null) { if (name != null) {
cwe += " " + name; cwe += ' ' + name;
} }
} }
final int cveId = rsV.getInt(1); final int cveId = rsV.getInt(1);

View File

@@ -68,8 +68,8 @@ public class DownloadTask implements Callable<Future<ProcessTask>> {
final File file2; final File file2;
try { try {
file1 = File.createTempFile("cve" + nvdCveInfo.getId() + "_", ".xml", Settings.getTempDirectory()); file1 = File.createTempFile("cve" + nvdCveInfo.getId() + '_', ".xml", Settings.getTempDirectory());
file2 = File.createTempFile("cve_1_2_" + nvdCveInfo.getId() + "_", ".xml", Settings.getTempDirectory()); file2 = File.createTempFile("cve_1_2_" + nvdCveInfo.getId() + '_', ".xml", Settings.getTempDirectory());
} catch (IOException ex) { } catch (IOException ex) {
throw new UpdateException("Unable to create temporary files", ex); throw new UpdateException("Unable to create temporary files", ex);
} }

View File

@@ -114,10 +114,10 @@ public class NvdCve12Handler extends DefaultHandler {
in the nvd cve 2.0. */ in the nvd cve 2.0. */
String cpe = "cpe:/a:" + vendor + ":" + product; String cpe = "cpe:/a:" + vendor + ":" + product;
if (num != null) { if (num != null) {
cpe += ":" + num; cpe += ':' + num;
} }
if (edition != null) { if (edition != null) {
cpe += ":" + edition; cpe += ':' + edition;
} }
final VulnerableSoftware vs = new VulnerableSoftware(); final VulnerableSoftware vs = new VulnerableSoftware();
vs.setCpe(cpe); vs.setCpe(cpe);

View File

@@ -420,43 +420,43 @@ public class SuppressionRule {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append("SuppressionRule{"); sb.append("SuppressionRule{");
if (filePath != null) { if (filePath != null) {
sb.append("filePath=").append(filePath).append(","); sb.append("filePath=").append(filePath).append(',');
} }
if (sha1 != null) { if (sha1 != null) {
sb.append("sha1=").append(sha1).append(","); sb.append("sha1=").append(sha1).append(',');
} }
if (gav != null) { if (gav != null) {
sb.append("gav=").append(gav).append(","); sb.append("gav=").append(gav).append(',');
} }
if (cpe != null && !cpe.isEmpty()) { if (cpe != null && !cpe.isEmpty()) {
sb.append("cpe={"); sb.append("cpe={");
for (PropertyType pt : cpe) { for (PropertyType pt : cpe) {
sb.append(pt).append(","); sb.append(pt).append(',');
} }
sb.append("}"); sb.append('}');
} }
if (cwe != null && !cwe.isEmpty()) { if (cwe != null && !cwe.isEmpty()) {
sb.append("cwe={"); sb.append("cwe={");
for (String s : cwe) { for (String s : cwe) {
sb.append(s).append(","); sb.append(s).append(',');
} }
sb.append("}"); sb.append('}');
} }
if (cve != null && !cve.isEmpty()) { if (cve != null && !cve.isEmpty()) {
sb.append("cve={"); sb.append("cve={");
for (String s : cve) { for (String s : cve) {
sb.append(s).append(","); sb.append(s).append(',');
} }
sb.append("}"); sb.append('}');
} }
if (cvssBelow != null && !cvssBelow.isEmpty()) { if (cvssBelow != null && !cvssBelow.isEmpty()) {
sb.append("cvssBelow={"); sb.append("cvssBelow={");
for (Float s : cvssBelow) { for (Float s : cvssBelow) {
sb.append(s).append(","); sb.append(s).append(',');
} }
sb.append("}"); sb.append('}');
} }
sb.append("}"); sb.append('}');
return sb.toString(); return sb.toString();
} }
} }

View File

@@ -115,7 +115,7 @@ public class DependencyVersion implements Iterable<String>, Comparable<Dependenc
*/ */
@Override @Override
public String toString() { public String toString() {
return StringUtils.join(versionParts.toArray(), "."); return StringUtils.join(versionParts, '.');
} }
/** /**

View File

@@ -51,7 +51,7 @@ public class BaseDependencyCheckMojoTest extends BaseTest {
*/ */
public boolean canRun() { public boolean canRun() {
String version = System.getProperty("java.version"); String version = System.getProperty("java.version");
int length = version.indexOf(".", version.indexOf(".") + 1); int length = version.indexOf('.', version.indexOf('.') + 1);
version = version.substring(0, length); version = version.substring(0, length);
double v = Double.parseDouble(version); double v = Double.parseDouble(version);