Skip to content

Commit 7eb4845

Browse files
rvandermeulenmergify[bot]
authored andcommitted
Enable ktlint class and function signature rules
1 parent 53affac commit 7eb4845

File tree

67 files changed

+538
-209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+538
-209
lines changed

.editorconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ insert_final_newline = true
77
max_line_length = 120 # same as detekt.yml
88

99
# rules we should look into enabling
10-
ktlint_standard_class-signature = disabled
1110
ktlint_standard_function-expression-body = disabled
1211
ktlint_standard_function-naming = disabled
13-
ktlint_standard_function-signature = disabled
1412
ktlint_standard_indent = disabled
1513
ktlint_standard_multiline-expression-wrapping = disabled
1614
ktlint_standard_no-empty-first-line-in-class-body = disabled

app/src/androidTest/java/org/mozilla/reference/browser/FirefoxTestRunner.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ import androidx.test.runner.AndroidJUnitRunner
1010

1111
class FirefoxTestRunner : AndroidJUnitRunner() {
1212

13-
override fun newApplication(cl: ClassLoader?, className: String?, context: Context?): Application {
13+
override fun newApplication(
14+
cl: ClassLoader?,
15+
className: String?,
16+
context: Context?,
17+
): Application {
1418
return super.newApplication(cl, FirefoxTestApplication::class.java.name, context)
1519
}
1620
}

app/src/androidTest/java/org/mozilla/reference/browser/ext/UiDevice.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import org.mozilla.reference.browser.helpers.TestAssetHelper.waitingTime
1515
*
1616
* @throws AssertionError if no [UiObject2] matches the condition
1717
*/
18-
fun UiDevice.waitAndInteract(condition: SearchCondition<UiObject2>, interaction: UiObject2.() -> Unit) {
18+
fun UiDevice.waitAndInteract(
19+
condition: SearchCondition<UiObject2>,
20+
interaction: UiObject2.() -> Unit,
21+
) {
1922
val obj = this.wait(condition, waitingTime)
2023
assertNotNull(obj)
2124
interaction.invoke(obj)

app/src/androidTest/java/org/mozilla/reference/browser/helpers/Assert.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import org.junit.Assert.assertEquals
1313
* pixel data are the same (within the provided delta): this is the same metrics that
1414
* [Bitmap.sameAs] uses.
1515
*/
16-
fun assertEqualsWithDelta(expectedB: Bitmap, actualB: Bitmap, delta: Float) {
16+
fun assertEqualsWithDelta(
17+
expectedB: Bitmap,
18+
actualB: Bitmap,
19+
delta: Float,
20+
) {
1721
assertEquals("widths should be equal", expectedB.width, actualB.width)
1822
assertEquals("heights should be equal", expectedB.height, actualB.height)
1923
assertEquals("config should be equal", expectedB.config, actualB.config)

app/src/androidTest/java/org/mozilla/reference/browser/helpers/Matchers.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ fun isSelected(isSelected: Boolean): Matcher<View> = maybeInvertMatcher(espresso
3636
*
3737
* @param matcher The matcher that our view cousins will be checked against to
3838
*/
39-
fun hasCousin(matcher: Matcher<View>): Matcher<View> = object : BaseMatcher<View>() {
39+
fun hasCousin(matcher: Matcher<View>): Matcher<View> =
40+
object : BaseMatcher<View>() {
4041
override fun describeTo(description: Description?) {
4142
description?.apply {
4243
appendText("has cousin that matches: ")
@@ -54,15 +55,20 @@ fun hasCousin(matcher: Matcher<View>): Matcher<View> = object : BaseMatcher<View
5455
?.count() == 1
5556
}
5657

57-
private fun matchChildren(matcher: Matcher<View>): (View?) -> Boolean = {
58+
private fun matchChildren(matcher: Matcher<View>): (View?) -> Boolean =
59+
{
5860
(it as? ViewGroup)
5961
?.children
6062
?.filter { v -> matcher.matches(v) }
6163
?.count() == 1
6264
}
6365
}
6466

65-
private fun maybeInvertMatcher(matcher: Matcher<View>, useUnmodifiedMatcher: Boolean): Matcher<View> = when {
67+
private fun maybeInvertMatcher(
68+
matcher: Matcher<View>,
69+
useUnmodifiedMatcher: Boolean,
70+
): Matcher<View> =
71+
when {
6672
useUnmodifiedMatcher -> matcher
6773
else -> not(matcher)
6874
}

app/src/androidTest/java/org/mozilla/reference/browser/helpers/MockWebServer.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ class AndroidAssetDispatcher : Dispatcher() {
6666
}
6767

6868
@Throws(IOException::class)
69-
private fun fileToResponse(path: String, file: InputStream): MockResponse {
69+
private fun fileToResponse(
70+
path: String,
71+
file: InputStream,
72+
): MockResponse {
7073
return MockResponse()
7174
.setResponseCode(HTTP_OK)
7275
.setBody(fileToBytes(file)!!)

app/src/androidTest/java/org/mozilla/reference/browser/helpers/RetryTestRule.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ import org.junit.runner.Description
1111
import org.junit.runners.model.Statement
1212
import java.lang.AssertionError
1313

14-
class RetryTestRule(private val retryCount: Int = 5) : TestRule {
14+
class RetryTestRule(
15+
private val retryCount: Int = 5,
16+
) : TestRule {
1517

16-
override fun apply(base: Statement, description: Description): Statement {
18+
override fun apply(
19+
base: Statement,
20+
description: Description,
21+
): Statement {
1722
return statement {
1823
for (i in 1..retryCount) {
1924
try {

app/src/androidTest/java/org/mozilla/reference/browser/helpers/TestAssetHelper.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ object TestAssetHelper {
1616
val waitingTime: Long = TimeUnit.SECONDS.toMillis(15)
1717
val waitingTimeShort: Long = TimeUnit.SECONDS.toMillis(1)
1818

19-
data class TestAsset(val url: Uri, val content: String, val title: String)
19+
data class TestAsset(
20+
val url: Uri,
21+
val content: String,
22+
val title: String,
23+
)
2024

2125
/**
2226
* Hosts 3 simple websites, found at androidTest/assets/pages/generic[1|2|3].html
@@ -36,7 +40,10 @@ object TestAssetHelper {
3640
}
3741
}
3842

39-
fun getGenericAsset(server: MockWebServer, pageNum: Int): TestAsset {
43+
fun getGenericAsset(
44+
server: MockWebServer,
45+
pageNum: Int,
46+
): TestAsset {
4047
val url = server.url("pages/generic$pageNum.html").toString().toUri()!!
4148
val content = "Page content: $pageNum"
4249
val title = "Test_Page_$pageNum"

app/src/androidTest/java/org/mozilla/reference/browser/helpers/TestHelper.kt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,27 @@ object TestHelper {
7474
return bitmap
7575
}
7676

77-
fun UiDevice.waitForObjects(obj: UiObject, waitingTime: Long = TestAssetHelper.waitingTime) {
77+
fun UiDevice.waitForObjects(
78+
obj: UiObject,
79+
waitingTime: Long = TestAssetHelper.waitingTime,
80+
) {
7881
this.waitForIdle()
7982
Assert.assertNotNull(obj.waitForExists(waitingTime))
8083
}
8184

82-
fun itemWithResId(resourceId: String) =
83-
mDevice.findObject(UiSelector().resourceId(resourceId))
85+
fun itemWithResId(resourceId: String) = mDevice.findObject(UiSelector().resourceId(resourceId))
8486

85-
fun itemWithText(itemText: String) =
86-
mDevice.findObject(UiSelector().text(itemText))
87+
fun itemWithText(itemText: String) = mDevice.findObject(UiSelector().text(itemText))
8788

88-
fun itemWithResIdContainingText(resourceId: String, text: String) =
89-
mDevice.findObject(UiSelector().resourceId(resourceId).textContains(text))
89+
fun itemWithResIdContainingText(
90+
resourceId: String,
91+
text: String,
92+
) = mDevice.findObject(UiSelector().resourceId(resourceId).textContains(text))
9093

91-
fun assertUIObjectExists(vararg appItems: UiObject, exists: Boolean = true) {
94+
fun assertUIObjectExists(
95+
vararg appItems: UiObject,
96+
exists: Boolean = true,
97+
) {
9298
if (exists) {
9399
for (appItem in appItems) {
94100
assertTrue(appItem.waitForExists(waitingTime))

app/src/androidTest/java/org/mozilla/reference/browser/helpers/ext/String.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import android.net.Uri
88

99
// Extension functions for the String class
1010

11-
fun String?.toUri(): Uri? = if (this == null) {
11+
fun String?.toUri(): Uri? =
12+
if (this == null) {
1213
null
1314
} else {
1415
Uri.parse(this)

0 commit comments

Comments
 (0)