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
enum class Destination { | |
HOME, | |
NOTIFICATIONS, | |
ACCOUNTS | |
} |
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
/* | |
* Copyright (C) 2019 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
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 Solution { | |
private var count = 0 | |
private var candidate: Int? = null | |
fun majorityElement(nums: IntArray): Int { | |
for (num in nums) { | |
candidate = updateCandidateForZeroCount(num) | |
count = updateCountForCandidate(num) | |
} |
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
override fun visit(root: KtFile) { | |
super.visit(root) | |
val classVisitor = UnusedClassVisitor() | |
root.accept(classVisitor) | |
classVisitor.privateClasses | |
.filterNot<KtNamedDeclaration> { it.isUsed() } | |
.forEach { | |
report(CodeSmell(issue, Entity.from(it), "Private class ${it.nameAsSafeName.identifier} is unused.")) |
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
private fun KtNamedDeclaration.isUsed(): Boolean { | |
if (nameAsSafeName.identifier in namedClasses) return true | |
val pathSegments = fqName?.pathSegments().orEmpty() | |
return pathSegments.isNotEmpty() && importedFqNames.any { importedFqName -> | |
importedFqName.pathSegments().zip(pathSegments).all { it.first == it.second } | |
} | |
} |
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
if (count == 0) { | |
candidate = num | |
} | |
if (num == candidate) { | |
count++ | |
} else { | |
count-- | |
} |
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 Solution { | |
fun majorityElement(nums: IntArray): Int { | |
var count = 0 | |
var candidate: Int? = null | |
for (num in nums) { | |
if (count == 0) { | |
candidate = num | |
count++ | |
} else { |
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
private void includeSetupAndTeardownPages() throws Exception { | |
includeSetupPages(); | |
includePageContent(); | |
includeTeardownPages(); | |
updatePageContent(); | |
} | |
private void includeSetupPages() throws Exception { | |
if (isSuite) | |
includeSuiteSetupPage(); |
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
public static String testableHtml(PageData pageData, boolean includeSuiteSetup) throws Exception { | |
WikiPage wikiPage = pageData.getWikiPage(); | |
StringBuffer buffer = new StringBuffer(); | |
if (pageData.hasAttribute("Test")) { | |
if (includeSuiteSetup) { | |
WikiPage suiteSetup = PageCrawlerImpl.getInheritedPage(SuiteResponder.SUITE_SETUP_NAME, wikiPage); | |
if (suiteSetup != null) { | |
WikiPagePath pagePath = suiteSetup.getPageCrawler().getFullPath(suiteSetup); | |
String pagePathName = PathParser.render(pagePath); | |
buffer.append("!include -setup .").append(pagePathName).append("\n"); |
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 io.gitlab.arturbosch.detekt.api.Config | |
import io.gitlab.arturbosch.detekt.test.assertThat | |
import io.gitlab.arturbosch.detekt.test.compileAndLintWithContext | |
import io.gitlab.arturbosch.detekt.test.setupKotlinEnvironment | |
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment | |
import org.junit.jupiter.api.BeforeAll | |
import org.junit.jupiter.api.Test | |
class DoubleNegativeTakeUnlessTest { |
NewerOlder