diff --git a/README.md b/README.md index bbe962f..f63c2fe 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ This will enable all the tools with their default settings. For more advanced co [advanced usage](docs/advanced-usage.md) and to the [supported tools](docs/supported-tools.md) pages. ## Sample app -There's a sample Android project available [here](https://github.com/novoda/gradle-static-analysis-plugin/tree/master/sample). This sample showcases a simple setup featuring Checkstyle, FindBugs, PMD, Lint and Detekt. +There are two sample Android projects available, one consisting of a regular app - available [here](https://github.com/novoda/gradle-static-analysis-plugin/tree/master/sample) - and the other comprising a multi-module setup available [here](https://github.com/novoda/gradle-static-analysis-plugin/tree/master/sample-multi-module). Both sample projects showcase a setup featuring Checkstyle, FindBugs, PMD, Lint and Detekt. ## Roadmap The plugin is under active development and to be considered in **beta stage**. It is routinely used by many Novoda projects and diff --git a/sample-multi-module/app/build.gradle b/sample-multi-module/app/build.gradle new file mode 100644 index 0000000..263b25d --- /dev/null +++ b/sample-multi-module/app/build.gradle @@ -0,0 +1,34 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 27 + buildToolsVersion '27.0.3' + + defaultConfig { + applicationId 'com.novoda.staticanalysis.sample' + minSdkVersion 16 + targetSdkVersion 27 + versionCode 1 + versionName '1.0' + } + + buildTypes { + debug { + } + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt') + } + } +} + +dependencies { + implementation project(path: ':core') + implementation 'com.android.support:appcompat-v7:27.1.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + testImplementation 'junit:junit:4.12' +} + +apply from: rootProject.file('team-props/static-analysis.gradle') diff --git a/sample-multi-module/app/src/main/AndroidManifest.xml b/sample-multi-module/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..1f6fb82 --- /dev/null +++ b/sample-multi-module/app/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + diff --git a/sample-multi-module/app/src/main/java/com/novoda/staticanalysisplugin/sample/MyActivity.kt b/sample-multi-module/app/src/main/java/com/novoda/staticanalysisplugin/sample/MyActivity.kt new file mode 100644 index 0000000..ba0e566 --- /dev/null +++ b/sample-multi-module/app/src/main/java/com/novoda/staticanalysisplugin/sample/MyActivity.kt @@ -0,0 +1,26 @@ +package com.novoda.staticanalysisplugin.sample + +import android.content.Intent +import android.os.Bundle +import android.support.v7.app.AppCompatActivity +import android.widget.Toast +import com.novoda.buildpropertiesplugin.sample.R +import kotlinx.android.synthetic.main.activity_my.* + +class MyActivity : AppCompatActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_my) + + val another: AnotherCoreClass + + button.setOnClickListener({ + LOOK_ANOTHER_CRAZY_LONG_LONG_LONG_METHOD_NAME_FOR_NO_APPARENT_REASON_WHY_IS_THIS_METHOD_NAMED_LIKE_THIS_WHY_IT_LITERALLY_MAKES_NO_SENSE_WHATSOEVER(1) + startActivity(Intent(this, SomeOtherActivity::class.java)) + }) + } + + private fun LOOK_ANOTHER_CRAZY_LONG_LONG_LONG_METHOD_NAME_FOR_NO_APPARENT_REASON_WHY_IS_THIS_METHOD_NAMED_LIKE_THIS_WHY_IT_LITERALLY_MAKES_NO_SENSE_WHATSOEVER(duration: Int) = Toast.makeText(this, "some useless message", duration).show() + +} diff --git a/sample-multi-module/app/src/main/java/com/novoda/staticanalysisplugin/sample/MyClass.java b/sample-multi-module/app/src/main/java/com/novoda/staticanalysisplugin/sample/MyClass.java new file mode 100644 index 0000000..991bc58 --- /dev/null +++ b/sample-multi-module/app/src/main/java/com/novoda/staticanalysisplugin/sample/MyClass.java @@ -0,0 +1,4 @@ +package com.novoda.staticanalysisplugin.sample; + +public class MyClass { +} diff --git a/sample-multi-module/app/src/main/java/com/novoda/staticanalysisplugin/sample/SomeOtherActivity.java b/sample-multi-module/app/src/main/java/com/novoda/staticanalysisplugin/sample/SomeOtherActivity.java new file mode 100644 index 0000000..6bdc84c --- /dev/null +++ b/sample-multi-module/app/src/main/java/com/novoda/staticanalysisplugin/sample/SomeOtherActivity.java @@ -0,0 +1,30 @@ +package com.novoda.staticanalysisplugin.sample; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; +import android.util.Log; +import android.widget.Toast; + +import com.novoda.buildpropertiesplugin.sample.R; + +public class SomeOtherActivity extends AppCompatActivity { + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_some_other); + + THIS_IS_A_VERY_VERY_VERY_LONG_NAME_FOR_A_METHOD_IT_IS_IN_FACT_VERY_LONG_INDEED_NO_NEED_TO_COUNT_THE_NUMBER_OF_CHARACTERS_YOU_CAN_CLEARLY_SEE_THIS_IS_WAY_LONGER_THAN_IT_SHOULD(0); + + String extra = getIntent().getStringExtra("nope"); + if (extra != null) { + Log.d(SomeOtherActivity.class.getSimpleName(), extra); + } + int boom = extra.length(); + } + + private void THIS_IS_A_VERY_VERY_VERY_LONG_NAME_FOR_A_METHOD_IT_IS_IN_FACT_VERY_LONG_INDEED_NO_NEED_TO_COUNT_THE_NUMBER_OF_CHARACTERS_YOU_CAN_CLEARLY_SEE_THIS_IS_WAY_LONGER_THAN_IT_SHOULD(int duration) { + Toast.makeText(this, "i have no idea what to write here", duration).show(); + } +} diff --git a/sample-multi-module/app/src/main/res/layout/activity_my.xml b/sample-multi-module/app/src/main/res/layout/activity_my.xml new file mode 100644 index 0000000..a37e25b --- /dev/null +++ b/sample-multi-module/app/src/main/res/layout/activity_my.xml @@ -0,0 +1,13 @@ + + + +