fix: remove constant variable causing always-false condition in bench_isolation_forest#630
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
fix: remove constant variable causing always-false condition in bench_isolation_forest#630sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZ45C1YORXnEWm2Rf6TT for python:S5797 rule Generated by SonarQube Agent (task: 10490a9b-ac4f-402c-abd1-18afe5b05f2c)
SonarQube reviewer guide
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Removed the constant variable assignment
with_decision_function_histograms = Falsethat 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. • CRITICAL • View issue
Location:
benchmarks/bench_isolation_forest.py:135Why 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 = Falsewhich was the root cause of the code smell. This variable was always False and was later used as a condition in anifstatement, 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.SonarQube Remediation Agent uses AI. Check for mistakes.