Javascript equivalent of @SuppressWarnings?(@SuppressWarnings 的 Javascript 等价物?)
问题描述
我目前正在运行 Sonar 以对我的代码进行静态分析.当我分析 java 文件并想抑制某个警告时,我使用了 @SuppressWarnings(nameOfTheWarningOnSonar) 注释.我想知道 Javascript 中是否有一个简单的等价物来抑制 Sonar 上的特定警告.
I am currently running Sonar for the static analysis of my code. When I was analyzing java files and wanted to suppress a certain warning, I used the @SuppressWarnings(nameOfTheWarningOnSonar) annotation. I wanted to know if there was a simple equivalent in Javascript to suppress specific warnings on Sonar.
推荐答案
嗯,最简单的方法是肯定的:
Well, the easiest way is for sure :
纠正 Sonar 所说的内容 :)
但让我们假设它是误报.
but let's assume that it's false positive.
以下是解决此问题的可能方法列表:
Here are the list of possible method to fix this issue :
自 2014 年 11 月起: 标签支持
// NOSONAR
the code who display Sonar error
现在完全支持 JavaScript 检查(感谢@RPallas)
is now fully supported by the JavaScript check (thanks @RPallas)
当你不控制声纳时: 相当丑陋的方法
try {
the code who display Sonar error
} catch(err) { }
如果您发现任何可能的问题,Sonar 将无法检测到某些东西(感谢 @JavaScript).
If you catch any possible problem, Sonar can't detect something (thanks @JavaScript).
但最好的办法是一定要修改声纳的配置:
But the best way is for sure to modify the configuration of Sonar :
当您控制 Sonar 时: 添加插件
在 Sonar 上使用 CheckStyle 插件:(http://checkstyle.sourceforge.net/)
To use the CheckStyle plugin on Sonar : (http://checkstyle.sourceforge.net/)
解决方案是向违规类添加 Checkstyle 结构化注释以禁止特定检查.
The solution will be to add a Checkstyle structured comment to the offending class to suppress a particular check.
需要的抑制评论(SuppressionCommentFilter)格式是这样的:
The suppression comment (SuppressionCommentFilter) format required is like this:
//CHECKSTYLE:OFF
the code who display Sonar error
//CHECKSTYLE:ON
但是我把你送到这个插件的文档(http://checkstyle.sourceforge.net/config.html)
But I send you to the documentation of this plugin (http://checkstyle.sourceforge.net/config.html)
我希望这个答案会有所帮助.
I hope this answer helps.
这篇关于@SuppressWarnings 的 Javascript 等价物?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:@SuppressWarnings 的 Javascript 等价物?


- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 400或500级别的HTTP响应 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01