various updates recommended by intelliJ

Former-commit-id: 298ccc5ba67197542c729911b5b2222363833530
This commit is contained in:
Jeremy Long
2013-05-20 22:17:19 -04:00
parent 75da352806
commit a31a73320b
20 changed files with 51 additions and 37 deletions

View File

@@ -52,16 +52,16 @@ public class Engine {
/**
* The list of dependencies.
*/
private List<Dependency> dependencies = new ArrayList<Dependency>();
private final List<Dependency> dependencies = new ArrayList<Dependency>();
/**
* A Map of analyzers grouped by Analysis phase.
*/
private EnumMap<AnalysisPhase, List<Analyzer>> analyzers =
private final EnumMap<AnalysisPhase, List<Analyzer>> analyzers =
new EnumMap<AnalysisPhase, List<Analyzer>>(AnalysisPhase.class);
/**
* A set of extensions supported by the analyzers.
*/
private Set<String> extensions = new HashSet<String>();
private final Set<String> extensions = new HashSet<String>();
/**
* Creates a new Engine.
@@ -161,11 +161,13 @@ public class Engine {
*/
protected void scanDirectory(File dir) {
final File[] files = dir.listFiles();
for (File f : files) {
if (f.isDirectory()) {
scanDirectory(f);
} else {
scanFile(f);
if (files != null) {
for (File f : files) {
if (f.isDirectory()) {
scanDirectory(f);
} else {
scanFile(f);
}
}
}
}

View File

@@ -33,7 +33,7 @@ public class CweHandler extends DefaultHandler {
/**
* a HashMap containing the CWE data.
*/
private HashMap<String, String> cwe = new HashMap<String, String>();
private final HashMap<String, String> cwe = new HashMap<String, String>();
/**
* Returns the HashMap of CWE entries (CWE-ID, Full CWE Name).

View File

@@ -41,7 +41,7 @@ public class FieldAnalyzer extends Analyzer {
/**
* The Lucene Version used.
*/
private Version version;
private final Version version;
/**
* Creates a new FieldAnalyzer.

View File

@@ -39,7 +39,7 @@ public class SearchFieldAnalyzer extends Analyzer {
/**
* The Lucene Version used.
*/
private Version version;
private final Version version;
/**
* A local reference to the TokenPairConcatenatingFilter so that we
* can clear any left over state if this analyzer is re-used.

View File

@@ -42,7 +42,7 @@ public class SearchVersionAnalyzer extends Analyzer {
/**
* The Lucene Version used.
*/
private Version version;
private final Version version;
/**
* Creates a new SearchVersionAnalyzer.

View File

@@ -50,7 +50,7 @@ public final class TokenPairConcatenatingFilter extends TokenFilter {
/**
* A list of words parsed.
*/
private LinkedList<String> words;
private final LinkedList<String> words;
/**
* Constructs a new TokenPairConcatenatingFilter.

View File

@@ -42,7 +42,7 @@ public class VersionAnalyzer extends Analyzer {
/**
* The Lucene Version used.
*/
private Version version;
private final Version version;
/**
* Creates a new VersionAnalyzer.

View File

@@ -41,7 +41,7 @@ public final class VersionTokenizingFilter extends TokenFilter {
/**
* A collection of tokens to add to the stream.
*/
private LinkedList<String> tokens;
private final LinkedList<String> tokens;
/**
* Constructs a new VersionTokenizingFilter.

View File

@@ -166,8 +166,8 @@ public class DatabaseUpdater implements CachedWebDataSource {
* @param file the file containing the NVD CVE XML
* @param oldVersion contains the file containing the NVD CVE XML 1.2
* @throws ParserConfigurationException is thrown if there is a parser configuration exception
* @throws SAXException is thrown if there is a saxexception
* @throws IOException is thrown if there is a ioexception
* @throws SAXException is thrown if there is a SAXException
* @throws IOException is thrown if there is a IOException
* @throws SQLException is thrown if there is a sql exception
* @throws DatabaseException is thrown if there is a database exception
*/

View File

@@ -69,7 +69,7 @@ public class NvdCve12Handler extends DefaultHandler {
/**
* The current element.
*/
private Element current = new Element();
private final Element current = new Element();
/**
* a map of vulnerabilities.
*/

View File

@@ -49,7 +49,7 @@ public class NvdCve20Handler extends DefaultHandler {
/**
* the current element.
*/
private Element current = new Element();
private final Element current = new Element();
/**
* the text of the node.
*/

View File

@@ -72,15 +72,15 @@ public class Dependency implements Comparable<Dependency> {
/**
* A collection of vendor evidence.
*/
private EvidenceCollection vendorEvidence;
private final EvidenceCollection vendorEvidence;
/**
* A collection of product evidence.
*/
private EvidenceCollection productEvidence;
private final EvidenceCollection productEvidence;
/**
* A collection of version evidence.
*/
private EvidenceCollection versionEvidence;
private final EvidenceCollection versionEvidence;
/**
* Constructs a new Dependency object.
@@ -379,8 +379,8 @@ public class Dependency implements Comparable<Dependency> {
if (str == null) {
return false;
}
if (vendorEvidence.containsUsedString(str)) {
return versionEvidence.containsUsedString(str) || productEvidence.containsUsedString(str) || vendorEvidence.containsUsedString(str);
/*if (vendorEvidence.containsUsedString(str)) {
return true;
}
if (productEvidence.containsUsedString(str)) {
@@ -390,6 +390,7 @@ public class Dependency implements Comparable<Dependency> {
return true;
}
return false;
*/
}
/**
* A list of vulnerabilities for this dependency.

View File

@@ -94,11 +94,11 @@ public class EvidenceCollection implements Iterable<Evidence> {
/**
* A collection of evidence.
*/
private Set<Evidence> list;
private final Set<Evidence> list;
/**
* A collection of strings used to adjust Lucene's term weighting.
*/
private Set<String> weightedStrings;
private final Set<String> weightedStrings;
/**
* Creates a new EvidenceCollection.

View File

@@ -69,11 +69,11 @@ public class ReportGenerator {
/**
* The Velocity Engine.
*/
private VelocityEngine engine;
private final VelocityEngine engine;
/**
* The Velocity Engine Context.
*/
private Context context;
private final Context context;
/**
* Constructs a new ReportGenerator.

View File

@@ -44,7 +44,7 @@ public final class CliParser {
/**
* The options for the command line parser.
*/
private Options options = createCommandLineOptions();
private final Options options = createCommandLineOptions();
/**
* Indicates whether the arguments are valid.
*/

View File

@@ -33,7 +33,7 @@ import org.apache.commons.lang.StringUtils;
* versionParts[2] = 3;
* </code></p>
* <p>Note, the parser contained in this class expects the version numbers to be
* separated by periods. If a different seperator is used the parser will likely
* separated by periods. If a different separator is used the parser will likely
* fail.</p>
* @author Jeremy Long (jeremy.long@owasp.org)
*/

View File

@@ -31,7 +31,7 @@ public abstract class Filter<T> {
private class FilterIterator implements Iterator<T> {
private Iterator<T> iterator;
private final Iterator<T> iterator;
private T next;
private FilterIterator(Iterator<T> iterator) {