Unused local variables should be removed and min()/max()


Python scanner ( detects unused local variables accumulated with operators like +=, but failed on variables accumulated with min()/max() (or may be other functions without side effects):

max_value = 0.0
avg_value = 0.0
for value_tag in value_tags:
     value = get_value(value_tag) # arbitrary source of data
     max_value = max(max_value, value)
     avg_value += voltage

Hey there.

Are you using SonarCloud or SonarQube (if the latter, what version?)

Hi, Colin!

We use SonarQube Developer Edition Version 9.4 (build 54424).


Sorry for the very late answer.

You’re right, we could improve the rule to catch such cases.
I created SONARPY-1062 to track this improvement.

Thanks a lot for your suggestion!

Hi, Pierre-Yves!

Thank you for help!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.