Skip to content

fix: add missing os import for environment variable check#633

Open
sonarqube-agent[bot] wants to merge 1 commit into
mainfrom
remediate-main-20260520-223149-a9651c84
Open

fix: add missing os import for environment variable check#633
sonarqube-agent[bot] wants to merge 1 commit into
mainfrom
remediate-main-20260520-223149-a9651c84

Conversation

@sonarqube-agent

Copy link
Copy Markdown

Fixes a SonarQube CRITICAL issue where a hardcoded False constant was used as a condition. The fix replaces the constant with a dynamic value read from an environment variable using os.environ.get(), which requires the missing os import statement. This resolves the constant condition warning and allows the code to be configurable at runtime.

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

Adds the import os statement needed by Hunk 2, which replaces the hardcoded False constant assignment with a dynamic value read from an environment variable. This import is required for the os.environ.get() call that fixes the constant condition warning.

--- a/benchmarks/bench_isolation_forest.py
+++ b/benchmarks/bench_isolation_forest.py
@@ -18,0 +19,1 @@ case a warning is raised when computing the ROC curve.
+import os

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: 94bf68c6-ad2f-48c8-84bb-c03960f08406)
@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