AnalysisScope passed to GlobalInspectionTool.runInspection() isn't correct

I've created global inspections to integrate the output of external static code analyzers. I noticed that no matter what scope I choose when I run these inspections (All, File, Custom, etc.), the AnalysisScope parameter that's passed to runInspection() is always for All. As a result, when I use that scope to determine which files should be processed by the external static code analyzers, it always ends up with full project's files. Interestingly, it still only displays the files from selected scope in the Inspection Results window.

I noticed that the provided GlobalInspectionContact, if cast to GlobalInspectionContextImpl, does include the correct scope. My workaround right now is to swap out the provided AnalysisScope for the one from the provided GlobalInspectionContact (only if I can safely cast to the implementation type). However, I feel dirty doing that, and I suspect that I'm the one doing something wrong given that I'm having to do so.

Any insights on how to get the correct selected scope from the provided arguments without peeking under the hood like this?

Thanks in advance!

PS: Is there any way to style text as code/monospaced inline? I tried using markdown but that didn't work, and when I tried to use the toolbar is styles the entire block, not just the desired word(s).

0
2 comments

Hi Scott,

I suspect it was my bug (this summer, so 2017.3 is affected), the next 2018.1 EAP should contain the fix (Corresponding issue: https://youtrack.jetbrains.com/issue/IDEA-185513)

Sorry for the inconvenience,

Anna

0

Thanks, Anna. As I mentioned, I have a workaround in place and am fine with that until your fix is available. Thanks for following up!

Regards,
Scott

0

Please sign in to leave a comment.