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 {danger, fail, message, warn, schedule} from 'danger' | |
const reporter = require("danger-plugin-lint-report") | |
// Scan ktlint reports | |
schedule(reporter.scan({ | |
fileMask: "**/reports/ktlint/*.xml", | |
reportSeverity: true, | |
requireLineModification: 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
name: DangerJS | |
on: [pull_request] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: |
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
@NoCopy | |
data class Password private constructor(val value: String) { | |
companion object { | |
fun of(value: String): Either<List<Violation>, Password> { | |
val violations = buildList { | |
if (value.isTooShort()) { add(Violation.PasswordTooShort(MIN_LENGTH)) } | |
if (value.containsNoNumbers()) { add(Violation.PasswordContainsNoNumbers) } | |
} | |
return if (violations.isEmpty()) Password(value).right() else violations.left() | |
} |
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
internal class PasswordValidatorTest { | |
private val validator = PasswordValidator() | |
@TestFactory | |
fun `given input password, when validating it, then is should return if it is valid`() = | |
listOf( | |
"Test123!" to true, | |
"#tesT12!" to true, | |
"12Es@t123" to 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
internal class PasswordValidatorTest { | |
private val validator = PasswordValidator() | |
@ParameterizedTest(name = "given \"{0}\", when validating the password, then it should return {1}") | |
@MethodSource("passwordArguments") | |
fun `given input password, when validating it, then is should return if it is valid`( | |
password: String, | |
expected: Boolean | |
) { |
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
KeyPairGenerator.getInstance(KeyProperties.KEY_ALGORITHM_RSA, "AndroidKeyStore").apply { | |
val certBuilder = KeyGenParameterSpec.Builder(alias, KeyProperties.PURPOSE_ENCRYPT) | |
.setKeyValidityStart(keyValidityStart) | |
.setKeyValidityEnd(keyValidityEnd) | |
.setCertificateSerialNumber(BigInteger.valueOf(1L)) | |
.setCertificateSubject(X500Principal("CN=MyCompany")) | |
.setUserAuthenticationRequired(true) | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { | |
initialize( | |
certBuilder |
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 LogInModelTest : LogInListener { | |
private lateinit var successTask: Task<AuthResult> | |
private lateinit var failureTask: Task<AuthResult> | |
@Mock | |
private lateinit val mAuth: FirebaseAuth | |
private lateinit var logInModel: LogInModel | |
private var logInResult = UNDEF | |
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 OverlappingPanelsLayout : FrameLayout { | |
private var scrollingSlopPx: Float = 0f | |
private var velocityTracker: VelocityTracker? = null | |
private var isScrollingHorizontally = false | |
private var xFromInterceptActionDown: Float = 0f | |
private var yFromInterceptActionDown: Float = 0f | |
... // initialize scrollingSlopPx and VelocityTracker |
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 OurViewModel(observeGithubReposUseCase: ObserveGithubReposUseCase): ViewModel { | |
val githubRepos: LiveData<List<GithubRepoItem>> | |
get() = observeGithubReposUseCase | |
.observe() | |
.map { reposList -> | |
reposList | |
.sortedByDescending { it.stars } | |
.map { |
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
@Suppress("UNCHECKED_CAST") | |
class ViewModelFactory @Inject constructor( | |
private val creators: Map<Class<out ViewModel>, Provider<ViewModel>> | |
) : ViewModelProvider.Factory { | |
override fun <T : ViewModel> create(modelClass: Class<T>): T { | |
val creator = creators[modelClass] | |
?: creators.asIterable().find { (key, _) -> modelClass.isAssignableFrom(key) }?.value | |
?: throw IllegalArgumentException("Unknown ViewModel class $modelClass") |