This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply plugin: 'findbugs' | |
| task findbugs(type: FindBugs) { | |
| excludeFilter = file("$project.rootDir/tools/rules-findbugs.xml") | |
| classes = fileTree("$project.buildDir/intermediates/classes/dev/debug/com/dd") | |
| source = fileTree("$project.rootDir/src/main/java/com/dd/") | |
| classpath = files() | |
| reports { | |
| xml.enabled = false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply plugin: 'com.android.application' | |
| apply from: "$project.rootDir/tools/script-findbugs.gradle" | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // MainActivity.java | |
| ... | |
| private void someMethod(int variable) { | |
| switch (variable) { | |
| case 1: | |
| System.out.println("1"); | |
| case 2: | |
| System.out.println("2"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <FindBugsFilter> | |
| <Bug pattern="SF_SWITCH_NO_DEFAULT" /> | |
| <Bug pattern="SF_SWITCH_FALLTHROUGH" /> | |
| </FindBugsFilter> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply plugin: 'pmd' | |
| task pmd(type: Pmd) { | |
| ruleSetFiles = files("$project.rootDir/tools/rules-pmd.xml") | |
| source = fileTree('src/main/java/') | |
| reports { | |
| xml.enabled = false | |
| html.enabled = true | |
| html.destination = "$project.buildDir/outputs/pmd/pmd.html" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| apply plugin: 'com.android.application' | |
| apply from: "$project.rootDir/tools/script-pmd.gradle" | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // MainActivity.java | |
| ... | |
| private void someMethod(int a, int b, int c, int d) { | |
| if (a > b) { | |
| if (b > c) { | |
| if (c > d) { | |
| if (d > a) { | |
| // some logic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class NewPresenter(private val todoDao: TodoDao) { | |
| private var description: CharSequence? = null | |
| fun bind(view: TodoView) { | |
| todoDao.all() | |
| .observeOn(AndroidSchedulers.mainThread()) | |
| .subscribe { view.updateTodos(it) } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // dispatches execution onto the Android main UI thread | |
| private val uiContext: CoroutineContext = UI | |
| // represents a common pool of shared threads as the coroutine dispatcher | |
| private val bgContext: CoroutineContext = CommonPool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private fun loadData() = launch(uiContext) { | |
| view.showLoading() // ui thread | |
| val task = async(bgContext) { dataProvider.loadData("Task") } | |
| val result = task.await() // non ui thread, suspend until finished | |
| view.showData(result) // ui thread | |
| } |