How to silence issues on DeepSource?

There are some occurrences in my code where I do not want DeepSource to raise issues. What should I do?

There are a couple of ways to do that.

Using skipcq in source code

Add 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.

More details here - https://deepsource.io/docs/how-to/silence-issues.html#silencing-a-specific-issue

Using dashboard

Ignore issue for a specific file pattern or across the repository from the dashboard.

Adding onto @jai’s answer, if you believe that DeepSource is raising an error when it shouldn’t raise one – you can use the “Ignore…” button on the issue and select “This is a false positive.”. This will let the team know of your feedback. In most cases, we are able to resolve issues within a week. In any case, an engineer from DeepSource would get in touch and let you know about it.

I have such code:

message = item_meta.message.format(
    obj_name=getattr(obj, item_meta.title_field)
)

This raises PTC-W0034 (unnecessary use of getattr). I tried putting skipcq pragma both before that lines and on logical end of line - ater closing bracket - this does not work, the issue is still reported. Am I doing something wrong?

@zgoda skipcq should be on the same line where the issue is raised.

This would work for you:

message = item_meta.message.format(
    obj_name=getattr(obj, item_meta.title_field)  #skipcq: PTC-W0034
)
2 Likes

Thanks, I thought most code analyzers for Python are ast-based nowadays.

What would be a good way to do it with JSX, where I can’t quite get the comment on the same or previous line?

I have the following, where the React fragment is necessary to return the children. Using a code formatter on this project, I can’t simply make it a one-liner. Are there any function or block scoped skip options?

  // skipcq: JS-0424 Fragment required to return children
  <DesignProvider>
    <>{children}</>
  </DesignProvider>
1 Like

Hey @errkk :wave:,

Unfortunately, currently it’s not possible to ignore issues for a block using skipcq. We have added it to our roadmap and will start work on supporting it in the coming days.

For now, the only way would be to add //skipcq: <issue-code> to each line flagged by the issue.

I will surely let you know by posting on this thread once the support for ignoring issues in multiple lines/block is out.

Thanks!