# Silence issues
While we strive to ensure minimum false positives in code analyses, there will always be cases where there is a need to ignore issues permanently.
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
# Silencing a specific issue
skipcq as a comment with the issue's short-code at the end of the line, or one the line above it to silence the issue.
input = 10 # skipcq: PYL-W0622
# skipcq: PYL-W0622 input = 10
Doing so will suppress
PYL-W0622 on this line, which is raised because the inbuilt function
input has been redefined.
# Silencing multiple issues
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
# Silencing all issues on a line
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
A word of caution, though — 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.
# In conjunction with existing comments
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
In case the
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,
skipcq keyword can be used for all analyzers. The general format is:
a line of code that raises an issue <comment identifier> skipcq: <issue code 1>, <issue code 2>
So, in order 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