Skip to content

fix: remove constant variable causing SonarQube S5797 warning#501

Open
sonarqube-agent[bot] wants to merge 1 commit into
mainfrom
remediate-main-20260520-101148-4ca6bccc
Open

fix: remove constant variable causing SonarQube S5797 warning#501
sonarqube-agent[bot] wants to merge 1 commit into
mainfrom
remediate-main-20260520-101148-4ca6bccc

Conversation

@sonarqube-agent
Copy link
Copy Markdown

Removed a constant variable assignment that was always False and used as a condition, which triggered a SonarQube critical issue (S5797) for constant expressions in conditionals. This eliminates the static analysis warning and improves code clarity by removing unnecessary constant assignments.

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 static analysis warning. 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.

--- 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: 6697a24c-a9d0-46ec-bf23-33f308392970)
@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