Skip to content

fix: remove constant variable causing always-false condition in bench_isolation_forest#630

Open
sonarqube-agent[bot] wants to merge 1 commit into
mainfrom
remediate-main-20260520-222640-48ecfa59
Open

fix: remove constant variable causing always-false condition in bench_isolation_forest#630
sonarqube-agent[bot] wants to merge 1 commit into
mainfrom
remediate-main-20260520-222640-48ecfa59

Conversation

@sonarqube-agent
Copy link
Copy Markdown

Removed the constant variable assignment with_decision_function_histograms = False that was causing an always-constant condition in an if statement. This eliminates dead code and resolves the SonarQube critical issue where the variable was never used as intended.

View Project in SonarCloud


Fixed Issues

python:S5797 - Replace this expression; used as a condition it will always be constant. • CRITICALView issue

Location: benchmarks/bench_isolation_forest.py:135

Why is this an issue?

When a constant is used as a condition, either it has no effect on the execution flow and it can be removed, or some code will never be executed and it is a bug.

What changed

Removes the constant variable assignment with_decision_function_histograms = False which was the root cause of the code smell. This variable was always False and was later used as a condition in an if statement, meaning the condition would always be constant. By removing this assignment, the source of the constant expression used as a condition is eliminated, and the associated dead code is no longer reachable.

--- a/benchmarks/bench_isolation_forest.py
+++ b/benchmarks/bench_isolation_forest.py
@@ -51,3 +50,0 @@ fig_roc, ax_roc = plt.subplots(1, 1, figsize=(8, 5))
-# Set this to true for plotting score histograms for each dataset:
-with_decision_function_histograms = False
-

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZ45C1YORXnEWm2Rf6TT for python:S5797 rule

Generated by SonarQube Agent (task: 10490a9b-ac4f-402c-abd1-18afe5b05f2c)
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant