In IntelliJ IDEA, I can disable some inspections for a class, method, or other units. I have a module in a project that's a library that I am not the only consumer of. I do not use all the methods in the library and consequently a large number are marked 'unused'. These are all false positives. I would like to disable these inspections for this module alone (ideally, I'd like to disable unused warnings for public/protected methods).
Is this possible? If so, how would one go about doing this?
You need to define a custom scope and configure the inspections' scope.
Go to
Settings -> Appearance & Behavior -> Scopeand create a new scope. Include recursively all files, then exclude the given project library.Then go to
Settings -> Editor -> Inspectionsand choose the inspections you want to disable for that project library, e.g.Declaration redundancy -> Unused symbol. In the scope settings, choose your newly defined scope.
来源:https://stackoverflow.com/questions/28692654/how-do-i-disable-some-inspections-for-modules-in-intellij-idea