This file contains 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
import { fail, warn } from "danger"; | |
const fs = require("fs"); | |
const xml2js = require("xml2js"); | |
const detektReportFile = fs.readFileSync( | |
"../build/reports/detekt/detekt-checkstyle.xml" | |
); | |
const parser = new xml2js.Parser({ async: false, attrkey: "attrs" }); | |
parser.parseString(detektReportFile, (err, report) => { | |
if (err != null) { |
This file contains 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
allprojects { | |
gradle.projectsEvaluated { | |
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { | |
kotlinOptions { | |
allWarningsAsErrors = true | |
} | |
} | |
} | |
} |
This file contains 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
#!/bin/bash -e | |
# Run Detekt on pre-push on changed files | |
cd Android | |
while read -r local_ref local_sha remote_ref remote_sha; do | |
if [[ "$local_sha" =~ ^0+$ ]]; then | |
# Handle delete | |
: |
This file contains 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
#!/bin/bash | |
java -jar libs/detekt-cli-1.10.0-all.jar --build-upon-default-config --includes "**/src/main/**/*.kt" -c detekt.yml -p libs/detekt-formatting-1.10.0-RC1.jar --parallel -r xml:build/reports/detekt/detekt-checkstyle.xml "$@" |
This file contains 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
build: | |
maxIssues: 0 | |
processors: | |
active: true | |
console-reports: | |
active: true | |
formatting: |
This file contains 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 MyClass { | |
// This will automatically have the TAG "MyClass" | |
private val log by timber() | |
fun logSomething() { | |
log.i("Hello") | |
log.w(Exception(), "World") | |
} | |
} |
This file contains 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
import timber.log.Timber | |
import kotlin.properties.ReadOnlyProperty | |
import kotlin.reflect.KProperty | |
class MyClass { | |
// This will automatically have the TAG "MyClass" | |
private val log by timber() | |
fun logSomething() { | |
log.i("Hello") |
This file contains 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 MyClass(private val scope: CoroutineScope) { | |
private val job = ConflatedJob() | |
fun retry() { | |
retryJob += scope.launch { | |
delay(Long.MAX_VALUE) | |
} | |
} | |
} |
This file contains 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 MyClass(private val scope: CoroutineScope) { | |
private val job = ConflatedJob() | |
fun retry() { | |
retryJob += scope.launch { | |
delay(Long.MAX_VALUE) | |
} | |
} | |
} |
This file contains 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
context.registerReceiverInScope(scope, WifiManager.WIFI_STATE_CHANGED_ACTION) { intent -> | |
val state = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE, WifiManager.WIFI_STATE_DISABLED) | |
// Use wifi state here | |
} | |
/** | |
* Register a broadcast receiver in the given coroutine scope for any of the specified actions | |
* and call the callback when it is invoked. | |
*/ | |
fun Context.registerReceiverInScope( |