Although we make every effort to minimize false positives in our code analyses, there may still be instances where it is necessary to permanently ignore certain issues.
For example, there may be a function that has arguments that are not used anywhere in the function.
def return_as_is(param, an_unused_param): return param
This will raise the issue Unused argument, with DeepSource issue code PYL-W0613. However, if the extra argument exists for the sole purpose of API consistency, it is better to ignore this issue. In order to silence this issue permanently in code, use the
def return_as_is(param, an_unused_param): # skipcq: PYL-W0613 return param
skipcq: as a comment with the issue's short-code at the end of the line, or on the line above it to silence the issue.
input = 10 # skipcq: PYL-W0622
# skipcq: PYL-W0622 input = 10
To silence multiple issues on a line, add a comma separated list of issue short-codes after the
def function(input, an_argument_not_used): # skipcq: PYL-W0622, PYL-W0613 pass
# skipcq: PYL-W0622, PYL-W0613 def function(input, an_argument_not_used): pass
To silence all issues that could be raised on a line, use the keyword
skipcq in the comment corresponding to the line.
except Exception: # skipcq pass
# skipcq except Exception: pass
This would prevent all issues from being raised on this line, which is probably not desired. We recommend using the keyword explicitly for the issues to be suppressed.
skipcq at the end of the comment for the line.
class Klass: def __init__(self): pass def func(self, x): # This function does not use `self`. Hence an issue will be raised. Lets ignore it. skipcq return x ** 2
skipcq comment is placed above the line, place as many comments or newlines between the skipcq keyword and the concerned line as needed.
class Klass: def __init__(self): pass # skipcq # This function does not use `self`. # Hence an issue will be raised. Lets ignore it. def func(self, x): return x ** 2
While all the examples above are for Python, the skipcq keyword can be used for all analyzers.
This is the general format:
a line of code that raises an issue <comment identifier> skipcq: <issue code 1>, <issue code 2>
For example, to silence an issue on a line of Go code:
x := true // The next line will raise an issue stating that negating a boolean twice is pointless. // But we want to keep it, and not have any issues raised by DeepSource. Hence, `skipcq` y := !!y // skipcq: SSC-SA4010
Updated 7 months ago