【发布时间】:2020-05-13 05:36:02
【问题描述】:
在 Python 中,我们可以通过应用 # NOSONAR 注释来抑制代码中特定行的所有 Sonarqube 警告。这并不理想。有没有办法抑制特定错误,而不是抑制所有错误?
例如,您可能有一个带有两个警告的函数:
Function "foo" has 8 parameters, which is greater than the 7 authorized.
Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed
你怎么能压制第一个,而不是第二个?
【问题讨论】:
-
如果我的问题没有错...您的意思是要使用“@SuppressWarnings("squid:S###")”而不是 NOSONAR?
-
@Ehsan
@SupressWarnings在 Python 中可用吗?我认为这仅在 Java 中是允许的。 -
这能回答你的问题吗? Ignore SonarQube warnings in python
-
@agabrys 不,这个答案说使用 #NOSONAR “是一个全球性的问题抑制:它会杀死在线上的所有问题,而不仅仅是来自特定规则的问题。”我正在寻找一种机制来抑制一个特定规则,而不是所有规则。