Search code examples
intellij-ideateamcitycode-analysislintstatic-code-analysis

Code analysis for android projects in Teamcity


I have a gradle based android studio project. I have installed IntelliJ IDEA 14 CE . Now I want to check code quality using a command. Is this possible? The real question is whether you can do code analysis to a completed project using IntelliJ IDEA 14 CE. Please give a solution.

EDIT

If it's not possible is there any other tool available for code analysis which can be operated using a shell command. I require command based code checking which will make my job easier when I integrate a project with the continuous integration server(TeamCity).


Solution

  • Lint is a very good option for code inspection. Just do the following

    cd PATH_TO_PROJECT
    chmod a+x gradlew
    ./gradlew lint
    

    To avoid warnings from failing the build edit build.gradle file as below

    android {
    lintOptions {      
    quiet false
    abortOnError true
    ignoreWarnings true
    checkReleaseBuilds false
    }
    ...
    }
    

    The errors will be obtained as an html and xml file in your output folder