Skip to content

Commit

Permalink
checkstyle cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylong committed Jul 15, 2019
1 parent faefb19 commit 6c1a561
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 16 deletions.
13 changes: 10 additions & 3 deletions core/src/main/java/org/owasp/dependencycheck/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,7 @@ private void throwFatalExceptionCollection(String message, @NotNull final Throwa
throw new ExceptionCollection(exceptions, true);
}

//CSOFF: LineLength
/**
* Writes the report to the given output directory.
*
Expand All @@ -1165,12 +1166,14 @@ private void throwFatalExceptionCollection(String message, @NotNull final Throwa
* file name if the format is not ALL)
* @param format the report format (ALL, HTML, CSV, JSON, etc.)
* @throws ReportException thrown if there is an error generating the report
* @deprecated use {@link #writeReports(java.lang.String, java.io.File, java.lang.String, org.owasp.dependencycheck.exception.ExceptionCollection)}
* @deprecated use
* {@link #writeReports(java.lang.String, java.io.File, java.lang.String, org.owasp.dependencycheck.exception.ExceptionCollection)}
*/
@Deprecated
public void writeReports(String applicationName, File outputDir, String format) throws ReportException {
writeReports(applicationName, null, null, null, outputDir, format, null);
}
//CSON: LineLength

/**
* Writes the report to the given output directory.
Expand All @@ -1187,6 +1190,7 @@ public void writeReports(String applicationName, File outputDir, String format,
writeReports(applicationName, null, null, null, outputDir, format, exceptions);
}

//CSOFF: LineLength
/**
* Writes the report to the given output directory.
*
Expand All @@ -1198,14 +1202,16 @@ public void writeReports(String applicationName, File outputDir, String format,
* file name if the format is not ALL)
* @param format the report format (ALL, HTML, CSV, JSON, etc.)
* @throws ReportException thrown if there is an error generating the report
* @deprecated use {@link #writeReports(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.io.File, java.lang.String, org.owasp.dependencycheck.exception.ExceptionCollection)}
* @deprecated use
* {@link #writeReports(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.io.File, java.lang.String, org.owasp.dependencycheck.exception.ExceptionCollection)}
*/
@Deprecated
public synchronized void writeReports(String applicationName, @Nullable final String groupId,
@Nullable final String artifactId, @Nullable final String version,
@NotNull final File outputDir, String format) throws ReportException {
writeReports(applicationName, groupId, artifactId, version, outputDir, format, null);
}
//CSON: LineLength

/**
* Writes the report to the given output directory.
Expand All @@ -1228,7 +1234,8 @@ public synchronized void writeReports(String applicationName, @Nullable final St
throw new UnsupportedOperationException("Cannot generate report in evidence collection mode.");
}
final DatabaseProperties prop = database.getDatabaseProperties();
final ReportGenerator r = new ReportGenerator(applicationName, groupId, artifactId, version, dependencies, getAnalyzers(), prop, settings, exceptions);
final ReportGenerator r = new ReportGenerator(applicationName, groupId, artifactId, version,
dependencies, getAnalyzers(), prop, settings, exceptions);
try {
r.write(outputDir.getAbsolutePath(), format);
} catch (ReportException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,18 @@ private List<SuppressionRule> loadSuppressionFile(final SuppressionParser parser
Thread.sleep(500);
downloader.fetchFile(url, file, true);
} catch (TooManyRequestsException ex1) {
throw new SuppressionParseException("Unable to download supression file `" + file + "`; received 429 - too many requests", ex1);
throw new SuppressionParseException("Unable to download supression file `" + file
+ "`; received 429 - too many requests", ex1);
} catch (ResourceNotFoundException ex1) {
throw new SuppressionParseException("Unable to download supression file `" + file + "`; received 404 - resource not found", ex1);
throw new SuppressionParseException("Unable to download supression file `" + file
+ "`; received 404 - resource not found", ex1);
} catch (InterruptedException ex1) {
Thread.currentThread().interrupt();
throw new SuppressionParseException("Unable to download supression file `" + file + "`", ex1);
}
} catch (TooManyRequestsException ex) {
throw new SuppressionParseException("Unable to download supression file `" + file + "`; received 429 - too many requests", ex);
throw new SuppressionParseException("Unable to download supression file `" + file
+ "`; received 429 - too many requests", ex);
} catch (ResourceNotFoundException ex) {
throw new SuppressionParseException("Unable to download supression file `" + file + "`; received 404 - resource not found", ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,15 @@ public class ArchiveAnalyzer extends AbstractFileTypeAnalyzer {
/**
* The set of things we can handle with Zip methods
*/
private static final Set<String> KNOWN_ZIP_EXT = Collections.unmodifiableSet(newHashSet("zip", "ear", "war", "jar", "sar", "apk", "nupkg", "aar"));
private static final Set<String> KNOWN_ZIP_EXT = Collections.unmodifiableSet(
newHashSet("zip", "ear", "war", "jar", "sar", "apk", "nupkg", "aar"));
/**
* The set of file extensions supported by this analyzer. Note for
* developers, any additions to this list will need to be explicitly handled
* in {@link #extractFiles(File, File, Engine)}.
*/
private static final Set<String> EXTENSIONS = Collections.unmodifiableSet(newHashSet("tar", "gz", "tgz", "bz2", "tbz2"));
private static final Set<String> EXTENSIONS = Collections.unmodifiableSet(
newHashSet("tar", "gz", "tgz", "bz2", "tbz2"));

/**
* Detects files with extensions to remove from the engine's collection of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ private boolean appendWeightedSearch(StringBuilder sb, String field, Map<String,
sb.append(field).append(":(");
boolean addSpace = false;
boolean addedTerm = false;

for (Map.Entry<String, MutableInt> entry : terms.entrySet()) {
final StringBuilder boostedTerms = new StringBuilder();
final int weighting = entry.getValue().intValue();
Expand All @@ -499,7 +499,7 @@ private boolean appendWeightedSearch(StringBuilder sb, String field, Map<String,
} else {
addSpace = true;
}
addedTerm=true;
addedTerm = true;
if (LuceneUtils.isKeyword(word)) {
sb.append("\"");
LuceneUtils.appendEscapedLuceneQuery(sb, word);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public synchronized TopDocs search(String searchString, int maxQueryResults) thr
* analyzers
*/
public synchronized Query parseQuery(String searchString) throws ParseException, IndexException {
if (searchString == null || searchString.trim().isEmpty()
if (searchString == null || searchString.trim().isEmpty()
|| "product:() AND vendor:()".equals(searchString)) {
throw new ParseException("Query is null or empty");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public enum Format {
private final Settings settings;

//CSOFF: ParameterNumber
//CSOFF: LineLength
/**
* Constructs a new ReportGenerator.
*
Expand Down Expand Up @@ -184,7 +185,8 @@ public ReportGenerator(String applicationName, List<Dependency> dependencies, Li
*/
@Deprecated
public ReportGenerator(String applicationName, String groupID, String artifactID, String version,
List<Dependency> dependencies, List<Analyzer> analyzers, DatabaseProperties properties, Settings settings) {
List<Dependency> dependencies, List<Analyzer> analyzers, DatabaseProperties properties,
Settings settings) {
this(applicationName, groupID, artifactID, version, dependencies, analyzers, properties, settings, null);
}

Expand Down Expand Up @@ -232,7 +234,8 @@ public ReportGenerator(String applicationName, String groupID, String artifactID
*/
@SuppressWarnings("JavaTimeDefaultTimeZone")
private VelocityContext createContext(String applicationName, List<Dependency> dependencies,
List<Analyzer> analyzers, DatabaseProperties properties, String groupID, String artifactID, String version, ExceptionCollection exceptions) {
List<Analyzer> analyzers, DatabaseProperties properties, String groupID,
String artifactID, String version, ExceptionCollection exceptions) {

final ZonedDateTime dt = ZonedDateTime.now();
final String scanDate = DateTimeFormatter.RFC_1123_DATE_TIME.format(dt);
Expand Down Expand Up @@ -270,6 +273,7 @@ private VelocityContext createContext(String applicationName, List<Dependency> d
return ctxt;
}
//CSON: ParameterNumber
//CSON: LineLength

/**
* Creates a new Velocity Engine.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,9 @@ private ExceptionCollection collectMavenDependencies(Engine engine, MavenProject
final Artifact dependencyArtifact = dependencyNode.getArtifact();
final Artifact result;
if (dependencyArtifact.isResolved()) {
//All transitive dependencies, excluding reactor and dependencyManagement artifacts should have been resolved by Maven prior to invoking the plugin
//Resolving the dependencies manually is unnecessary, and does not work in some cases (issue-1751)
//All transitive dependencies, excluding reactor and dependencyManagement artifacts should
//have been resolved by Maven prior to invoking the plugin - resolving the dependencies
//manually is unnecessary, and does not work in some cases (issue-1751)
getLog().debug(String.format("Skipping artifact %s, already resolved", dependencyArtifact.getArtifactId()));
result = dependencyArtifact;
} else {
Expand Down Expand Up @@ -1639,7 +1640,8 @@ protected void populateSettings() {
settings.setBooleanIfNotNull(Settings.KEYS.ANALYZER_ARTIFACTORY_PARALLEL_ANALYSIS, artifactoryAnalyzerParallelAnalysis);
if (Boolean.TRUE.equals(artifactoryAnalyzerEnabled)) {
if (artifactoryAnalyzerServerId != null) {
configureServerCredentials(artifactoryAnalyzerServerId, Settings.KEYS.ANALYZER_ARTIFACTORY_API_USERNAME, Settings.KEYS.ANALYZER_ARTIFACTORY_API_TOKEN);
configureServerCredentials(artifactoryAnalyzerServerId, Settings.KEYS.ANALYZER_ARTIFACTORY_API_USERNAME,
Settings.KEYS.ANALYZER_ARTIFACTORY_API_TOKEN);
} else {
settings.setStringIfNotNull(Settings.KEYS.ANALYZER_ARTIFACTORY_API_USERNAME, artifactoryAnalyzerUsername);
settings.setStringIfNotNull(Settings.KEYS.ANALYZER_ARTIFACTORY_API_TOKEN, artifactoryAnalyzerApiToken);
Expand Down

0 comments on commit 6c1a561

Please sign in to comment.