简体   繁体   English

Intellij,仅对文件禁用检查/建议

[英]Intellij, disable inspection/suggestion only for file

It's annoying and attention grabbing when Intellij will highlight all kinds of stuff like simplify something or a suggestion, or a warning of some kind. 当Intellij突出显示各种内容时(例如简化某些内容或提出建议或发出某种警告),这很烦人并且引起了注意。

Many times, I like the thank you mam, but stop bothering me. 很多时候,我喜欢谢谢妈妈,但不要再打扰我了。 This is not relevant. 这无关紧要。

However, Intellij will only allow you to ignore the type of warning globally, which is kind of dangerous to do. 但是,Intellij仅允许您全局忽略警告的类型,这样做是很危险的。

I am aware that you can add an annotation, but I don't want to pollute my classes with annotations and comments everywhere. 我知道您可以添加注释,但是我不想在任何地方都用注释和注释来污染我的班级。 Also, @SuppressWarnings("ALL") is applied even suggestions, not even on warnings. 同样,@ SuppressWarnings(“ ALL”)甚至被应用于建议,甚至不应用于警告。

Can't Intellij manage this using a project file ? Intellij不能使用项目文件来管理它吗? Also, Intellij should add a line to the right to show where such a supression has been done. 另外,Intellij应该在右侧添加一行以显示在哪里进行了这种压缩。

Problem right now, is that once you supress globally it's almost impossible to undo, or revise. 现在的问题是,一旦您在全球范围内压制,几乎不可能撤消或修改。

I mean @SuppressWarnings({"PointlessBooleanExpression", "ConstantConditions"}) is hardly Java related, and should not be added to the code. 我的意思是@SuppressWarnings({"PointlessBooleanExpression", "ConstantConditions"})与Java几乎没有关系,因此不应将其添加到代码中。

It should be managed by the editor. 它应该由编辑器管理。 It must also be made so that it's easily editable and an overview can be seen for the entire project files. 还必须对其进行制作,以便易于编辑,并可以查看整个项目文件的概述。

Is this possible already? 这有可能吗?

If enabled in the settings somewhere, you can use //@formatter:off to turn off formatter and //@formatter:on to turn on formatter. 如果在某处的设置中启用了此功能,则可以使用//@formatter:off关闭格式器,并使用//@formatter:on打开格式器。 Afaik it requires that you turn on the formatter before the end of the file. Afaik要求您在文件结尾之前打开格式化程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM