In a python project I have an async class method called “Modération”. If I understood well the python PEP8 rule, this should be report as a consistancy issue. However this one is not reported. After investigation the file is correctly scanned by sonar, and other issues are discovered, but this one not.
Is it a known bug or work as expected ?
this is on sonar scanner, Community Edition v10.5.1 (90531).
To reproduce, here is a piece of the code
@message_command(default_member_permissions=256)
async def Modérer(self, interaction: Interaction, message):
view = nextcord.ui.View()
view.add_item(SelectSanction(message))
with open("moderate.txt", "a") as file:
file.write("===\n" + message.content.replace("=", "\=") + "\n===\n")
await interaction.response.send_message("Quelle sanction appliquer à ce message ?", ephemeral=True, view=view)
In this case, the function name “Modérer” is not detected as problematic.
I dig a little bit and found that in this case, sonar may not detect this because it is a decorator-defined command, not a standard Python function.
I don’t know if it is a bug or a feature.
Hi @TristanL,
Thanks for reaching out, and thanks for reporting this false negative.
I was able to reproduce this issue with the following code snippet. I’m assuming that your the class of Modération inherits from another class.
from nextcord.ext import commands
class ModerationCog(commands.Cog):
async def Modérer(self, interaction, message):
pass
S100, the rule, which should raise in this case, does not when its class inherits from another class. The logic being that there is a good chance your overriding a method and therefore you cannot change the name. However, in cases like these this logic is a bit too aggressively suppressing issues leading to this false negative.
I’ve added this community thread to the internal ticket which is tracking this issue.