Disable “not used” warning for public methods of a

2019-02-01 15:59发布

The new intellij upgrade (10.5) now shows a warning that some of the methods defined for a class are not being used. These methods are public and I plan on not using all of them as I have created them to support the API expected. I would like to disable this warning (not used for public methods in a class). Is there a way to do it?.

8条回答
Summer. ? 凉城
2楼-- · 2019-02-01 16:29

IDEA 2016.3

In the upcoming version IDEA 2016.3 (preview version already available) it is now possible to adjust the inspection scope:

enter image description here

< IDEA 14.0

If you want to highlight unused public methods, please enable the "Settings|Inspections|Declaration redundancy|Unused declaration" global inspection.

If you want to highlight unused private methods, please enable the "Settings|Inspections|Declaration redundancy|Unused symbol" local inspection.

So, if you want to highlight unused private members, but do not highlight unused public members, turn off "Unused declaration" and turn on "Unused symbol".

Source

I've just tested it using IDEA 13.1.4, and it worked exactly as described.

IDEA 14.x

In IntelliJ IDEA 14.0.x the settings are under:

Settings | Editor | Inspections | Declaration redundancy | Unused symbol/declaration

In IntelliJ IDEA 14.1 the option appears to be gone..

查看更多
放荡不羁爱自由
3楼-- · 2019-02-01 16:29

Disable Settings | Inspections | Declaration redundancy | Unused Declaration code inspection. As an option you can create a custom scope for your API classes and disable this inspection only per API scope so that it still works in the rest parts of your project.

查看更多
登录 后发表回答