Is there any way, how to exclude android generated files (or manually specify excluded folders), from Analyze -> Inspect Code ?
-
Can you please tell how do you inspect code in android studio(gradle android studio project). Are there any plugins available. Can it be done using command line. – Nevin Raj Victor Apr 20 '15 at 06:49
-
You can inspect code from Android Studio menu (Analyze > Inspect Code), from CLI you can go with Gradle Android Lint (`gradle lint`), but you cannot do the same Code Inspection from CLI as Android Studio (IntelliJ IDEA) can from GUI. – Marek Sebera Apr 20 '15 at 09:13
-
Is there any other tool available which can be operated from command line? – Nevin Raj Victor Apr 20 '15 at 09:16
-
1See http://www.sonarqube.org/ that is widely used and is able to give you reports from Continuous-Integration/Code-Quality analysis on CLI – Marek Sebera Apr 20 '15 at 09:17
4 Answers
Use a custom scope. After clicking Analyze > Inspect Code, from the Specify Inspection Scope dialog, click "..." after "Custom scope". Define a new scope. Recursively include Android
, app
, and whatever else is important. Then recursively exclude folders you don't want.
I like to put my generated code in the build
folder and exclude it. (To get code in the build
folder to be included in the build, include it in app.gradle
in android/sourceSets/main/java.srcDirs
.)

- 40,302
- 20
- 199
- 253
-
Just wanted to say that this works, whereas the accepted answer is outdated. – zoltish Jun 10 '16 at 06:17
-
Just wanted to say currently this is recommended by android developers blog. – Developine Jan 26 '17 at 06:32
I've found answer
Excluded folders won't be taken in account for Code Analysis
- Right-click on top-level element and go to Open Module Settings
- There you have listed single modules, select correct module
- In right column select folders to be excluded and either right click -> exclude or button exclude above the file tree
- In left column remove all leftover references to excluded directories from other groups than Excluded Folders

- 39,650
- 37
- 158
- 244
-
1
-
7I don't have any of this for Android Studio. Is it because my project is wearable/mobile project? https://www.dropbox.com/s/zezxtycckls0mel/Screenshot%202014-10-30%2018.04.37.png?dl=0 – Kamilski81 Oct 30 '14 at 23:04
-
1
You can do it using the Gradle IDEA plugin:
apply plugin: 'idea'
idea {
module {
excludeDirs = [file("unwanted-directory-name")]
}
}

- 1,720
- 1
- 13
- 35

- 2,251
- 1
- 21
- 34
Take a look at this answer:
You basically just create a custom scope with the following pattern: !file:*intermediates*/&&!file:*generated*/&&!lib:*..*
Hope this helps.

- 1
- 1

- 5,727
- 49
- 55