diff --git a/CHANGELOG.md b/CHANGELOG.md index eee455b4761..93fd2e0842f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ Currently the versioning policy of this project follows [Semantic Versioning v2. - Use method references instead of lambdas where possible ([#3179](https://github.com/spotbugs/spotbugs/pull/3179)) - Move default clauses to the end of switches ([#3222](https://github.com/spotbugs/spotbugs/pull/3222)) - Remove unnecessary throws declarations ([#3220](https://github.com/spotbugs/spotbugs/pull/3220)) +- Use `Boolean.parseBoolean()` for string-to-boolean conversion. ([#3217](https://github.com/spotbugs/spotbugs/pull/3217)) ### Changed - Bump up Java version to 11 diff --git a/eclipsePlugin/src/de/tobject/findbugs/FindbugsPlugin.java b/eclipsePlugin/src/de/tobject/findbugs/FindbugsPlugin.java index 59dc99dfffa..8a636557bde 100644 --- a/eclipsePlugin/src/de/tobject/findbugs/FindbugsPlugin.java +++ b/eclipsePlugin/src/de/tobject/findbugs/FindbugsPlugin.java @@ -473,27 +473,27 @@ public void configurePluginDebugOptions() { if (isDebugging()) { // debugging for the plugin itself String option = Platform.getDebugOption(PLUGIN_DEBUG); - FindbugsPlugin.DEBUG = Boolean.valueOf(option).booleanValue(); + FindbugsPlugin.DEBUG = Boolean.parseBoolean(option); // debugging for the builder and friends option = Platform.getDebugOption(BUILDER_DEBUG); - FindBugsBuilder.DEBUG = Boolean.valueOf(option).booleanValue(); + FindBugsBuilder.DEBUG = Boolean.parseBoolean(option); FindBugsWorker.DEBUG = FindBugsBuilder.DEBUG; // debugging for the nature option = Platform.getDebugOption(NATURE_DEBUG); - FindBugsNature.DEBUG = Boolean.valueOf(option).booleanValue(); + FindBugsNature.DEBUG = Boolean.parseBoolean(option); // debugging for the reporter option = Platform.getDebugOption(REPORTER_DEBUG); - Reporter.DEBUG = Boolean.valueOf(option).booleanValue(); + Reporter.DEBUG = Boolean.parseBoolean(option); // debugging for the content provider option = Platform.getDebugOption(CONTENT_DEBUG); - BugContentProvider.DEBUG = Boolean.valueOf(option).booleanValue(); + BugContentProvider.DEBUG = Boolean.parseBoolean(option); option = Platform.getDebugOption(PROFILER_DEBUG); - if (Boolean.valueOf(option).booleanValue()) { + if (Boolean.parseBoolean(option)) { System.setProperty("profiler.report", "true"); } } diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/BugProperty.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/BugProperty.java index 36cf49ac37e..c74a70f45ba 100644 --- a/spotbugs/src/main/java/edu/umd/cs/findbugs/BugProperty.java +++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/BugProperty.java @@ -102,7 +102,7 @@ public String getValue() { * @return value of property as a boolean */ public boolean getValueAsBoolean() { - return Boolean.valueOf(getValue()).booleanValue(); + return Boolean.parseBoolean(getValue()); } /** diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/PluginLoader.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/PluginLoader.java index f7ca634c6f1..6f69c3609af 100644 --- a/spotbugs/src/main/java/edu/umd/cs/findbugs/PluginLoader.java +++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/PluginLoader.java @@ -773,7 +773,7 @@ private void loadPluginComponents() try { String propertiesLocation = componentNode.valueOf("@properties"); - boolean disabled = Boolean.valueOf(componentNode.valueOf("@disabled")); + boolean disabled = Boolean.parseBoolean(componentNode.valueOf("@disabled")); Node filterMessageNode = findMessageNode(messageCollectionList, "/MessageCollection/PluginComponent[@id='" + componentId + "']", @@ -822,7 +822,7 @@ private void loadPluginComponents() + " loaded from " + loadedFrom); } String kind = main.valueOf("@kind"); - boolean analysis = Boolean.valueOf(main.valueOf("@analysis")); + boolean analysis = Boolean.parseBoolean(main.valueOf("@analysis")); Element mainMessageNode = (Element) findMessageNode(messageCollectionList, "/MessageCollection/FindBugsMain[@cmd='" + cmd // + " and @class='" + className @@ -867,7 +867,7 @@ private void loadPluginComponents() } DetectorFactory factory = new DetectorFactory(plugin, className, detectorClass, !"true".equals(disabled), speed, reports, requireJRE); - if (Boolean.valueOf(hidden).booleanValue()) { + if (Boolean.parseBoolean(hidden)) { factory.setHidden(true); } factory.setPositionSpecifiedInPluginDescriptor(detectorCount++); @@ -927,7 +927,7 @@ private void loadPluginComponents() } BugCategory bc = plugin.addOrCreateBugCategory(key); - boolean hidden = Boolean.valueOf(categoryNode.valueOf("@hidden")); + boolean hidden = Boolean.parseBoolean(categoryNode.valueOf("@hidden")); if (hidden) { bc.setHidden(hidden); } @@ -1006,7 +1006,7 @@ private void loadPluginComponents() try { String deprecatedStr = bugPatternNode.valueOf("@deprecated"); - boolean deprecated = !deprecatedStr.isEmpty() && Boolean.valueOf(deprecatedStr).booleanValue(); + boolean deprecated = !deprecatedStr.isEmpty() && Boolean.parseBoolean(deprecatedStr); if (deprecated) { bugPattern.setDeprecated(deprecated); } @@ -1288,7 +1288,7 @@ private DetectorFactorySelector getConstraintSelector(Element constraintElement, node = constraintElement.selectSingleNode("./" + singleDetectorElementName + "Category"); if (node != null) { - boolean spanPlugins = Boolean.valueOf(node.valueOf("@spanplugins")).booleanValue(); + boolean spanPlugins = Boolean.parseBoolean(node.valueOf("@spanplugins")); String categoryName = node.valueOf("@name"); if (!"".equals(categoryName)) { @@ -1307,7 +1307,7 @@ private DetectorFactorySelector getConstraintSelector(Element constraintElement, node = constraintElement.selectSingleNode("./" + singleDetectorElementName + "Subtypes"); if (node != null) { - boolean spanPlugins = Boolean.valueOf(node.valueOf("@spanplugins")).booleanValue(); + boolean spanPlugins = Boolean.parseBoolean(node.valueOf("@spanplugins")); String superName = node.valueOf("@super"); if (!"".equals(superName)) { diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/TextUICommandLine.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/TextUICommandLine.java index a834bb0004e..07d3af74059 100644 --- a/spotbugs/src/main/java/edu/umd/cs/findbugs/TextUICommandLine.java +++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/TextUICommandLine.java @@ -401,7 +401,7 @@ protected void handleOption(String option, String optionExtraPart) { } else if ("-quiet".equals(option)) { quiet = true; } else if ("-nested".equals(option)) { - scanNestedArchives = "".equals(optionExtraPart) || Boolean.valueOf(optionExtraPart).booleanValue(); + scanNestedArchives = "".equals(optionExtraPart) || Boolean.parseBoolean(optionExtraPart); } else if ("-exitcode".equals(option)) { setExitCode = true; } else if ("-auxclasspathFromInput".equals(option)) { diff --git a/spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java b/spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java index f6c2e5ef5b8..106548877f3 100644 --- a/spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java +++ b/spotbugs/src/main/java/edu/umd/cs/findbugs/config/ProjectFilterSettings.java @@ -197,7 +197,7 @@ public static ProjectFilterSettings fromEncodedString(String s) { displayFalseWarnings = s; s = ""; } - result.setDisplayFalseWarnings(Boolean.valueOf(displayFalseWarnings).booleanValue()); + result.setDisplayFalseWarnings(Boolean.parseBoolean(displayFalseWarnings)); } if (!s.isEmpty()) { @@ -282,7 +282,7 @@ public boolean displayWarning(BugInstance bugInstance) { } if (!displayFalseWarnings) { - boolean isFalseWarning = !Boolean.valueOf(bugInstance.getProperty(BugProperty.IS_BUG, "true")).booleanValue(); + boolean isFalseWarning = !Boolean.parseBoolean(bugInstance.getProperty(BugProperty.IS_BUG, "true")); if (isFalseWarning) { return false; }