SonarLint could detect code smell or maintainability for some Python or Javascript codes in couple of my Git repositories. But in other Git repo where I had different Python files there they have code smell (below) and bugs, but SonarLint said “No problem has been detected in this workspace” in the “Problem” tab in the Terminal section. The “Output” tab is also empty. Would someone let me know why Sonarlint did not detect the code smell?
Env Info:
SonarLint 14.5.0, VSCode (1.96.2), MacOS (Apple M1 Max)
Python code that has code smell:
def calculate_discount(price, discount):
if discount == 0:
return price
elif discount == 10:
return price * 0.9
elif discount == 20:
return price * 0.8
elif discount == 30:
return price * 0.7
elif discount == 40:
return price * 0.6
elif discount == 50:
return price * 0.5
else:
return price
def if variable_a == 1:
if variable_b == 3:
do_something()
def main():
price = 100
discount = 20
final_price = calculate_discount(price, discount)
print("Final price:", final_price)
print("Final price:", final_price)
print("Final price:", final_price)
main()