12

Is there any way, how to exclude android generated files (or manually specify excluded folders), from Analyze -> Inspect Code ?

Marek Sebera
  • 39,650
  • 37
  • 158
  • 244
  • 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
  • 1
    See 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 Answers4

4

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.)

Edward Brey
  • 40,302
  • 20
  • 199
  • 253
3

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

Excluding folders

Marek Sebera
  • 39,650
  • 37
  • 158
  • 244
2

You can do it using the Gradle IDEA plugin:

apply plugin: 'idea'
idea {
    module {
        excludeDirs = [file("unwanted-directory-name")]
    }
}
pomo
  • 2,251
  • 1
  • 21
  • 34
1

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.

Community
  • 1
  • 1
Henrique de Sousa
  • 5,727
  • 49
  • 55