Intellij:忽略文件警告

Intellij: Ignore warnings by file

和其他许多人一样,我遇到的问题是 Intellij 会发出一些与我无关的警告。我当然可以检查每个人并让 Intellij 插入 suppresswarning-tag。但是我想知道是否有更优雅的方法来做到这一点。

使用 Pylint(Python 代码检查)时,有一个 pylint.rc 文件,可以在其中抑制警告。这样做的好处不仅是我在一个位置抑制了所有警告,而且我可以简单地将此文件复制到其他项目并重新使用它。

Intellij有类似的方法吗?

是的,您可以更改 Code Inspection

的设置

当您打开 Analyze/Inspect code... 时,您可以根据需要查看和更改 inspection profiles 并禁用警告。您也可以导入和导出 inspection profile.

Inspection profiles

When you inspect your code, you can tell IntelliJ IDEA which types of problems you would like to search for and get reports about. Such configurations can be preserved as inspection profiles.

An inspection profile defines the types of problems to be sought for, i.e. which code inspections are enabled/disabled and the severity of these inspections. Profiles are configurable in the Inspections settings page.

To set the current inspection profile (the one that is used for the on-the-fly code analysis in the editor), simply select it in the Inspections settings page and apply changes. When you perform code analysis or execute a single inspection, you can specify which profile to use for each run.