fix: remove constant variable causing SonarQube S5797 warning#501
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
fix: remove constant variable causing SonarQube S5797 warning#501sonarqube-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: 6697a24c-a9d0-46ec-bf23-33f308392970)
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 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. • 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 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.SonarQube Remediation Agent uses AI. Check for mistakes.