Skip to content

Commit e6400a0

Browse files
authored
style: make checkstyle happier (#7559)
1 parent 686e1cf commit e6400a0

File tree

7 files changed

+79
-64
lines changed

7 files changed

+79
-64
lines changed

NOTICE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dependency-check
22

3-
Copyright (c) 2012-2013 Jeremy Long. All Rights Reserved.
3+
Copyright (c) 2012-2025 OWASP Dependency-Check Contributors. All Rights Reserved.
44

55
The licenses for the software listed below can be found in the META-INF/licenses/[dependency name].
66

cli/src/main/java/org/owasp/dependencycheck/CliParser.java

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private void validateArgs() throws FileNotFoundException, ParseException {
172172
if (!isValidFormat(validating)
173173
&& !isValidFilePath(validating, "format")) {
174174
final String msg = String.format("An invalid 'format' of '%s' was specified. "
175-
+ "Supported output formats are %s, and custom template files.",
175+
+ "Supported output formats are %s, and custom template files.",
176176
validating, SUPPORTED_FORMATS);
177177
throw new ParseException(msg);
178178
}
@@ -321,14 +321,14 @@ private void addStandardOptions(final Options options) {
321321
//This is an option group because it can be specified more then once.
322322

323323
options.addOptionGroup(newOptionGroup(newOptionWithArg(ARGUMENT.SCAN_SHORT, ARGUMENT.SCAN, "path",
324-
"The path to scan - this option can be specified multiple times. Ant style paths are supported (e.g. 'path/**/*.jar'); "
325-
+ "if using Ant style paths it is highly recommended to quote the argument value.")))
324+
"The path to scan - this option can be specified multiple times. Ant style paths are supported (e.g. 'path/**/*.jar'); "
325+
+ "if using Ant style paths it is highly recommended to quote the argument value.")))
326326
.addOptionGroup(newOptionGroup(newOptionWithArg(ARGUMENT.EXCLUDE, "pattern", "Specify an exclusion pattern. This option "
327327
+ "can be specified multiple times and it accepts Ant style exclusions.")))
328328
.addOption(newOptionWithArg(ARGUMENT.PROJECT, "name", "The name of the project being scanned."))
329329
.addOption(newOptionWithArg(ARGUMENT.OUT_SHORT, ARGUMENT.OUT, "path",
330330
"The folder to write reports to. This defaults to the current directory. It is possible to set this to a specific "
331-
+ "file name if the format argument is not set to ALL."))
331+
+ "file name if the format argument is not set to ALL."))
332332
.addOption(newOptionWithArg(ARGUMENT.OUTPUT_FORMAT_SHORT, ARGUMENT.OUTPUT_FORMAT, "format",
333333
"The report format (" + SUPPORTED_FORMATS + "). The default is HTML. Multiple format parameters can be specified."))
334334
.addOption(newOption(ARGUMENT.PRETTY_PRINT, "When specified the JSON and XML report formats will be pretty printed."))
@@ -346,7 +346,7 @@ private void addStandardOptions(final Options options) {
346346
.addOption(newOptionWithArg(ARGUMENT.NVD_API_KEY, "apiKey", "The API Key to access the NVD API."))
347347
.addOption(newOptionWithArg(ARGUMENT.FAIL_ON_CVSS, "score",
348348
"Specifies if the build should be failed if a CVSS score above a specified level is identified. The default is 11; "
349-
+ "since the CVSS scores are 0-10, by default the build will never fail."))
349+
+ "since the CVSS scores are 0-10, by default the build will never fail."))
350350
.addOption(newOptionWithArg(ARGUMENT.FAIL_JUNIT_ON_CVSS, "score",
351351
"Specifies the CVSS score that is considered a failure when generating the junit report. The default is 0."));
352352
}
@@ -397,7 +397,7 @@ private void addAdvancedOptions(final Options options) {
397397
"The proxy password to use when downloading resources."))
398398
.addOption(newOptionWithArg(ARGUMENT.NON_PROXY_HOSTS, "list",
399399
"The proxy exclusion list: hostnames (or patterns) for which proxy should not be used. "
400-
+ "Use pipe, comma or colon as list separator."))
400+
+ "Use pipe, comma or colon as list separator."))
401401
.addOption(newOptionWithArg(ARGUMENT.CONNECTION_TIMEOUT_SHORT, ARGUMENT.CONNECTION_TIMEOUT, "timeout",
402402
"The connection timeout (in milliseconds) to use when downloading resources."))
403403
.addOption(newOptionWithArg(ARGUMENT.CONNECTION_READ_TIMEOUT, "timeout",
@@ -414,14 +414,14 @@ private void addAdvancedOptions(final Options options) {
414414
"The database driver name."))
415415
.addOption(newOptionWithArg(ARGUMENT.DB_DRIVER_PATH, "path",
416416
"The path to the database driver; note, this does not need to be set unless the JAR is "
417-
+ "outside of the classpath."))
417+
+ "outside of the classpath."))
418418
.addOption(newOptionWithArg(ARGUMENT.SYM_LINK_DEPTH, "depth",
419419
"Sets how deep nested symbolic links will be followed; 0 indicates symbolic links will not be followed."))
420420
.addOption(newOptionWithArg(ARGUMENT.PATH_TO_BUNDLE_AUDIT, "path",
421421
"The path to bundle-audit for Gem bundle analysis."))
422422
.addOption(newOptionWithArg(ARGUMENT.PATH_TO_BUNDLE_AUDIT_WORKING_DIRECTORY, "path",
423423
"The path to working directory that the bundle-audit command should be executed from when "
424-
+ "doing Gem bundle analysis."))
424+
+ "doing Gem bundle analysis."))
425425
.addOption(newOptionWithArg(ARGUMENT.CENTRAL_URL, "url",
426426
"Alternative URL for Maven Central Search. If not set the public Sonatype Maven Central will be used."))
427427
.addOption(newOptionWithArg(ARGUMENT.CENTRAL_USERNAME, "username",
@@ -434,7 +434,7 @@ private void addAdvancedOptions(final Options options) {
434434
"Alternative URL for the OSS Index. If not set the public Sonatype OSS Index will be used."))
435435
.addOption(newOptionWithArg(ARGUMENT.OSSINDEX_USERNAME, "username",
436436
"The username to authenticate to Sonatype's OSS Index. If not set the Sonatype OSS Index "
437-
+ "Analyzer will use an unauthenticated connection."))
437+
+ "Analyzer will use an unauthenticated connection."))
438438
.addOption(newOptionWithArg(ARGUMENT.OSSINDEX_PASSWORD, "password", ""
439439
+ "The password to authenticate to Sonatype's OSS Index. If not set the Sonatype OSS "
440440
+ "Index Analyzer will use an unauthenticated connection."))
@@ -472,23 +472,23 @@ private void addAdvancedOptions(final Options options) {
472472
"The path to the `pnpm` executable."))
473473
.addOption(newOptionWithArg(ARGUMENT.RETIREJS_FILTERS, "pattern",
474474
"Specify Retire JS content filter used to exclude files from analysis based on their content; "
475-
+ "most commonly used to exclude based on your applications own copyright line. This "
476-
+ "option can be specified multiple times."))
475+
+ "most commonly used to exclude based on your applications own copyright line. This "
476+
+ "option can be specified multiple times."))
477477
.addOption(newOptionWithArg(ARGUMENT.NEXUS_URL, "url",
478478
"The url to the Nexus Server's REST API Endpoint (http://domain/nexus/service/local). If not "
479-
+ "set the Nexus Analyzer will be disabled."))
479+
+ "set the Nexus Analyzer will be disabled."))
480480
.addOption(newOptionWithArg(ARGUMENT.NEXUS_USERNAME, "username",
481481
"The username to authenticate to the Nexus Server's REST API Endpoint. If not set the Nexus "
482-
+ "Analyzer will use an unauthenticated connection."))
482+
+ "Analyzer will use an unauthenticated connection."))
483483
.addOption(newOptionWithArg(ARGUMENT.NEXUS_PASSWORD, "password",
484484
"The password to authenticate to the Nexus Server's REST API Endpoint. If not set the Nexus "
485-
+ "Analyzer will use an unauthenticated connection."))
485+
+ "Analyzer will use an unauthenticated connection."))
486486
//TODO remove as this should be covered by non-proxy hosts
487487
.addOption(newOptionWithArg(ARGUMENT.NEXUS_USES_PROXY, "true/false",
488488
"Whether or not the configured proxy should be used when connecting to Nexus."))
489489
.addOption(newOptionWithArg(ARGUMENT.ADDITIONAL_ZIP_EXTENSIONS, "extensions",
490490
"A comma separated list of additional extensions to be scanned as ZIP files (ZIP, EAR, WAR "
491-
+ "are already treated as zip files)"))
491+
+ "are already treated as zip files)"))
492492
.addOption(newOptionWithArg(ARGUMENT.PROP_SHORT, ARGUMENT.PROP, "file", "A property file to load."))
493493
.addOption(newOptionWithArg(ARGUMENT.PATH_TO_CORE, "path", "The path to dotnet core."))
494494
.addOption(newOptionWithArg(ARGUMENT.HINTS_FILE, "file", "The file path to the hints XML file."))
@@ -498,9 +498,12 @@ private void addAdvancedOptions(final Options options) {
498498
.addOption(newOption(ARGUMENT.DISABLE_ARCHIVE, "Disable the Archive Analyzer."))
499499
.addOption(newOption(ARGUMENT.DISABLE_KEV, "Disable the Known Exploited Vulnerability Analyzer."))
500500
.addOption(newOptionWithArg(ARGUMENT.KEV_URL, "url", "The url to the CISA Known Exploited Vulnerabilities JSON data feed"))
501-
.addOption(newOptionWithArg(ARGUMENT.KEV_USER, "user", "The user for basic authentication towards the CISA Known Exploited Vulnerabilities JSON data feed"))
502-
.addOption(newOptionWithArg(ARGUMENT.KEV_PASSWORD, "password", "The password for basic authentication towards the CISA Known Exploited Vulnerabilities JSON data feed"))
503-
.addOption(newOptionWithArg(ARGUMENT.KEV_BEARER_TOKEN, "token", "The token for bearer authentication towards the CISA Known Exploited Vulnerabilities JSON data feed"))
501+
.addOption(newOptionWithArg(ARGUMENT.KEV_USER, "user", "The user for basic authentication towards the CISA Known Exploited "
502+
+ "Vulnerabilities JSON data feed"))
503+
.addOption(newOptionWithArg(ARGUMENT.KEV_PASSWORD, "password", "The password for basic authentication towards the CISA Known "
504+
+ "Exploited Vulnerabilities JSON data feed"))
505+
.addOption(newOptionWithArg(ARGUMENT.KEV_BEARER_TOKEN, "token", "The token for bearer authentication towards the CISA Known "
506+
+ "Exploited Vulnerabilities JSON data feed"))
504507
.addOption(newOption(ARGUMENT.DISABLE_ASSEMBLY, "Disable the .NET Assembly Analyzer."))
505508
.addOption(newOption(ARGUMENT.DISABLE_PY_DIST, "Disable the Python Distribution Analyzer."))
506509
.addOption(newOption(ARGUMENT.DISABLE_CMAKE, "Disable the Cmake Analyzer."))
@@ -783,8 +786,8 @@ public void printHelp() {
783786
addAdvancedOptions(options);
784787
}
785788
final String helpMsg = String.format("%n%s"
786-
+ " can be used to identify if there are any known CVE vulnerabilities in libraries utilized by an application. "
787-
+ "%s will automatically update required data from the Internet, such as the CVE and CPE data files from nvd.nist.gov.%n%n",
789+
+ " can be used to identify if there are any known CVE vulnerabilities in libraries utilized by an application. "
790+
+ "%s will automatically update required data from the Internet, such as the CVE and CPE data files from nvd.nist.gov.%n%n",
788791
settings.getString(Settings.KEYS.APPLICATION_NAME, "DependencyCheck"),
789792
settings.getString(Settings.KEYS.APPLICATION_NAME, "DependencyCheck"));
790793

core/src/main/java/org/owasp/dependencycheck/analyzer/AbstractSuppressionAnalyzer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.nio.file.Path;
2727
import java.nio.file.StandardCopyOption;
2828
import java.util.ArrayList;
29-
import java.util.Iterator;
3029
import java.util.List;
3130
import java.util.Set;
3231
import java.util.regex.Pattern;
@@ -197,7 +196,7 @@ private void loadSuppressionBaseData(final Engine engine) throws SuppressionPars
197196
*/
198197
private void loadPackagedSuppressionBaseData(final SuppressionParser parser, final Engine engine) throws SuppressionParseException {
199198
List<SuppressionRule> ruleList = null;
200-
URL jarLocation = AbstractSuppressionAnalyzer.class.getProtectionDomain().getCodeSource().getLocation();
199+
final URL jarLocation = AbstractSuppressionAnalyzer.class.getProtectionDomain().getCodeSource().getLocation();
201200
String suppressionFileLocation = jarLocation.getFile();
202201
if (suppressionFileLocation.endsWith(".jar")) {
203202
suppressionFileLocation = "jar:file:" + suppressionFileLocation + "!/" + BASE_SUPPRESSION_FILE;

core/src/main/java/org/owasp/dependencycheck/analyzer/PoetryAnalyzer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ protected void analyzeDependency(Dependency dependency, Engine engine) throws An
147147
//do not report on the build file itself
148148
engine.removeDependency(dependency);
149149

150-
Optional<Toml> potentiallyParsedToml = parseDependencyFile(dependency);
150+
final Optional<Toml> potentiallyParsedToml = parseDependencyFile(dependency);
151151
if (potentiallyParsedToml.isEmpty()) {
152152
LOGGER.warn("toml file skipped: {} could not be parsed", dependency.getActualFilePath());
153153
return;
@@ -207,16 +207,16 @@ protected void analyzeDependency(Dependency dependency, Engine engine) throws An
207207

208208
private Optional<Toml> parseDependencyFile(Dependency dependency) {
209209
try {
210-
Toml toml = new Toml().read(dependency.getActualFile());
210+
final Toml toml = new Toml().read(dependency.getActualFile());
211211
return Optional.of(toml);
212212
} catch (RuntimeException e) {
213-
Optional<String> unparsableFileErrorMessage = Optional.ofNullable(e.getCause())
213+
final Optional<String> unparsableFileErrorMessage = Optional.ofNullable(e.getCause())
214214
.filter(c -> c instanceof IllegalStateException)
215215
.map(Throwable::getMessage)
216216
.filter(PoetryAnalyzer::isInvalidKeyErrorMessage);
217217

218218
if (unparsableFileErrorMessage.isPresent()) {
219-
String message = String.format("Invalid toml file, cannot parse '%s'", dependency.getActualFile());
219+
final String message = String.format("Invalid toml file, cannot parse '%s'", dependency.getActualFile());
220220
LOGGER.debug(message, e);
221221
return Optional.empty();
222222
}

0 commit comments

Comments
 (0)