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!

Hello @siddhant ,
Has this issue using JSX already been resolved?

It seems that even if it is written as follows, it will still be subject to analysis.
We use the Next.js.
How should it be written?

{/* #skipcq: JS-0422 */}
<a href={ PAGE_URL } target="_blank" className={ requestStyleClass }>click</a>

Hi @shun,

Currently, we support skipping JSX issues only when the skipcq pragma is added on the same line as the issue. For your example, the below should work.

<a href={ PAGE_URL } target="_blank" className={ requestStyleClass }>click</a> { /* skipcq: JS-0422 */ }

Hi @anto-christo ,
Thank you for your reply and advice.
However, even though I implemented it the same way as shown in the attached image, I couldn’t skip the analysis of this line.

Our environment is as follows, but could you let us know what kind of environment it is being developed in?

node: 20.17.0
npm: 10.8.2
next: ^15.0.1

Also, is there a mistake in the deepsource.toml file configuration?

version = 1

[[analyzers]]
name = "javascript"
enabled = true

  [analyzers.meta]
  environment = [
    "nodejs",
    "browser"
  ]

Hi @shun,

At the time of my reply, the support for this was only released on DeepSource Cloud.
We have now released it on DeepSource Enterprise Server as well, kindly update to v3.30.2 and recheck.
Let us know if you are still facing any issues.

Hi @anto-christo ,

Thanks for the information.
I have updated to the latest version and analyzed the code.
And we got it, thank you very much.

1 Like