Configure default inspection scope

I have some custom inspections, and I need to exclude them from running on generated code and some other stuff. I know how to do this in the UI, but telling each user to set the scope manually before running them is not really acceptable for my customers. I need a way to configure this automatically.

What's the right way to go about it?

0

Hi Richard!

Why do you need explicit scopes?

Inspections should not started on generated scope, see com.intellij.openapi.roots.GeneratedSourcesFilter#isGeneratedSourceByAnyFilter used in com.intellij.analysis.AnalysisScope#accept(com.intellij.psi.PsiElementVisitor, boolean). If your inspection is not applicable for some files, you may return EMPTY_VISITOR in your buildVisitor implementation. I don't think that it need to be configurable, e.g. IDEA doesn't start java inspections on xml files and it's done implicitly and looks like everyone is happy with that.

Thanks,

Anna

0
Avatar
Permanently deleted user

Hi, Anna.

One of the things I am dealing with is parts of our product which are shipped as reference source code, but which we don't want to inspect unless the customer has copied and modified them.

Also, the full product is VERY large, and when I run "inspect" from the command line I don't want these files to be inspected.

Our internal developers DO want to see these inspections, though, so I can't just make the inspection "not applicable." Whether it is applicable or not depends, essentially, on the user role.

 

 

 

0

How would you detect user role in plugin?

0
Avatar
Permanently deleted user

We can detect whether the project file structure is the one we ship to customers, or the developer git repo.

But I do want this to be flexible (so that my CI build could run the inspections on the out-of-the-box sources). That's why changing the default scope seems like the right approach.

0

请先登录再写评论。