John Moore
John Moore

Reputation: 71

How to exclude some directories from "Analyze -> Inspect Code" in Android Studio?

One code directory is from a long working library, but the code inspector complains about many issues in it. How do I exclude it from analysis?

I've tried looking at the settings, and also tried right clicking on various things through the analysis.

I'd like the code inspection to work for most of my project, but not from parts of it that work and analysis is unneeded. In this case, it is a complex open source C language library where I do not want to touch the code.

Upvotes: 2

Views: 839

Answers (1)

John Moore
John Moore

Reputation: 71

Okay - I feel a bit dumb, but so others don't have to go through this, here are details. Also, it is very easy to screw this up - the Android Studio GUI will let you do stuff that looks good in the dialog, but doesn't work. It took me several tries to find the magic that works.

Here is the procedure:

  1. From the main menu, select "Analyze" then "Inspect Code"
  2. Click the button next to "Custom Scope"
  3. Click the three dots button - to the right on the same line. A new dialog will pop up.
  4. Click the plus ( + ) - upper left, to start a new Custom scope
  5. Give it a name
  6. Select "Local" or "Remote"
  7. In the drop-down of the new dialog, select Project view
  8. Of the four icons, click them until only the one for file display is emphasized
  9. Find the top directory of what you want to analyze, and click "Include"
  10. Find each directory you want to exclude, and click "Exclude" for each
  11. Click OK - the custom scope dialog will close
  12. Click OK - the analysis will run

In the future, that scope is available by name, but remember that it does not honor the implied scope if you right-click a directory in the hierarchy.

Initial Code Inspection dialog

The Custom Scope dialog

Upvotes: 4

Related Questions