minor codacy suggested changes

This commit is contained in:
Jeremy Long
2017-06-04 08:13:59 -04:00
parent 31ad7adadd
commit 422418f396
4 changed files with 18 additions and 20 deletions

View File

@@ -37,6 +37,16 @@ import org.owasp.dependencycheck.utils.Settings;
*/ */
public class FileNameAnalyzer extends AbstractAnalyzer { public class FileNameAnalyzer extends AbstractAnalyzer {
/**
* Python init files
*/
//CSOFF: WhitespaceAfter
private static final NameFileFilter IGNORED_FILES = new NameFileFilter(new String[]{
"__init__.py",
"__init__.pyc",
"__init__.pyo",});
//CSON: WhitespaceAfter
//<editor-fold defaultstate="collapsed" desc="All standard implementation details of Analyzer"> //<editor-fold defaultstate="collapsed" desc="All standard implementation details of Analyzer">
/** /**
* The name of the analyzer. * The name of the analyzer.
@@ -78,16 +88,6 @@ public class FileNameAnalyzer extends AbstractAnalyzer {
} }
//</editor-fold> //</editor-fold>
/**
* Python init files
*/
//CSOFF: WhitespaceAfter
private static final NameFileFilter IGNORED_FILES = new NameFileFilter(new String[]{
"__init__.py",
"__init__.pyc",
"__init__.pyo",});
//CSON: WhitespaceAfter
/** /**
* Collects information about the file name. * Collects information about the file name.
* *

View File

@@ -73,6 +73,7 @@ public class NuspecAnalyzer extends AbstractFileTypeAnalyzer {
*/ */
@Override @Override
public void initializeFileTypeAnalyzer() throws InitializationException { public void initializeFileTypeAnalyzer() throws InitializationException {
//nothing to initialize
} }
/** /**

View File

@@ -802,10 +802,8 @@ public final class CveDB implements AutoCloseable {
try { try {
final PreparedStatement cs = getPreparedStatement(COUNT_CPE); final PreparedStatement cs = getPreparedStatement(COUNT_CPE);
rs = cs.executeQuery(); rs = cs.executeQuery();
if (rs.next()) { if (rs.next() && rs.getInt(1) > 0) {
if (rs.getInt(1) > 0) { return true;
return true;
}
} }
} catch (Exception ex) { } catch (Exception ex) {
String dd; String dd;
@@ -911,10 +909,9 @@ public final class CveDB implements AutoCloseable {
} }
//this can't dereference a null 'identifiedVersion' because if it was null we would have exited //this can't dereference a null 'identifiedVersion' because if it was null we would have exited
//in the above loop or just after loop (if matchesAnyPrevious return null). //in the above loop or just after loop (if matchesAnyPrevious return null).
if (entry.getValue() && identifiedVersion != null && identifiedVersion.compareTo(v) <= 0) { if (entry.getValue() && identifiedVersion != null && identifiedVersion.compareTo(v) <= 0
if (!(isVersionTwoADifferentProduct && !identifiedVersion.getVersionParts().get(0).equals(v.getVersionParts().get(0)))) { && !(isVersionTwoADifferentProduct && !identifiedVersion.getVersionParts().get(0).equals(v.getVersionParts().get(0)))) {
return entry; return entry;
}
} }
} }
} }

View File

@@ -56,12 +56,12 @@ public class UrlStringUtilsTest {
@Test @Test
public void testExtractImportantUrlData() throws Exception { public void testExtractImportantUrlData() throws Exception {
String text = "http://github.com/jeremylong/DependencyCheck/index.html"; String text = "http://github.com/jeremylong/DependencyCheck/index.html";
List<String> expResult = Arrays.asList("github", "jeremylong", "DependencyCheck", "index");; List<String> expResult = Arrays.asList("github", "jeremylong", "DependencyCheck", "index");
List<String> result = UrlStringUtils.extractImportantUrlData(text); List<String> result = UrlStringUtils.extractImportantUrlData(text);
assertEquals(expResult, result); assertEquals(expResult, result);
text = "http://github.com/jeremylong/DependencyCheck/.gitignore"; text = "http://github.com/jeremylong/DependencyCheck/.gitignore";
expResult = Arrays.asList("github", "jeremylong", "DependencyCheck", "gitignore");; expResult = Arrays.asList("github", "jeremylong", "DependencyCheck", "gitignore");
result = UrlStringUtils.extractImportantUrlData(text); result = UrlStringUtils.extractImportantUrlData(text);
assertEquals(expResult, result); assertEquals(expResult, result);