I’m facing false positives in Python, concerning the 20% comment/code ratio rule.
I’m using Sonarqube Community Edition (Version 8.9.6 build 50800).
According to PEP258, docstring can have the following formats
"""Module docstring -> comment"""
g = 'module attribute (module-global variable)'
"""This is g's docstring. -> Not a comment"""
class AClass:
c = 'class attribute'
"""This is AClass.c's docstring. -> Not a comment"""
def __init__(self):
"""Method __init__'s docstring.-> comment"""
self.i = 'instance attribute'
"""This is self.i's docstring. -> not a comment"""
def f(x):
"""Function f's docstring. -> comment"""
return x**2
f.a = 1
"""Function attribute f.a's docstring. -> Not a comment"""
Yet, some of them only are considered as comments in Sonarqube. When it’s not, this is considered as code and my ratio becomes high!
Is it normal ? Desired ?
Thanks for your help!