Skip to content

Commit 7c5a41f

Browse files
committed
Konsist: no field should have 'm' prefix, and fix new detected issues.
1 parent 4338d82 commit 7c5a41f

File tree

4 files changed

+33
-19
lines changed

4 files changed

+33
-19
lines changed

app/src/test/kotlin/io/element/android/app/KonsistTest.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ import com.lemonappdev.konsist.api.ext.list.constructors
2323
import com.lemonappdev.konsist.api.ext.list.modifierprovider.withoutModifier
2424
import com.lemonappdev.konsist.api.ext.list.modifierprovider.withoutOverrideModifier
2525
import com.lemonappdev.konsist.api.ext.list.parameters
26+
import com.lemonappdev.konsist.api.ext.list.properties
2627
import com.lemonappdev.konsist.api.ext.list.withAllAnnotationsOf
2728
import com.lemonappdev.konsist.api.ext.list.withAllParentsOf
2829
import com.lemonappdev.konsist.api.ext.list.withNameEndingWith
2930
import com.lemonappdev.konsist.api.ext.list.withReturnType
3031
import com.lemonappdev.konsist.api.ext.list.withTopLevel
3132
import com.lemonappdev.konsist.api.ext.list.withoutName
3233
import com.lemonappdev.konsist.api.ext.list.withoutNameEndingWith
34+
import com.lemonappdev.konsist.api.verify.assertFalse
3335
import com.lemonappdev.konsist.api.verify.assertTrue
3436
import io.element.android.libraries.architecture.Presenter
3537
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
@@ -122,4 +124,16 @@ class KonsistTest {
122124
functionDeclaration.name == "create${functionDeclaration.returnType?.name}"
123125
}
124126
}
127+
128+
@Test
129+
fun `no field should have 'm' prefix`() {
130+
Konsist
131+
.scopeFromProject()
132+
.classes()
133+
.properties()
134+
.assertFalse {
135+
val secondCharacterIsUppercase = it.name.getOrNull(1)?.isUpperCase() ?: false
136+
it.name.startsWith('m') && secondCharacterIsUppercase
137+
}
138+
}
125139
}

features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/logs/LogFormatter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ import java.util.logging.LogRecord
2828
internal class LogFormatter : Formatter() {
2929

3030
override fun format(r: LogRecord): String {
31-
if (!mIsTimeZoneSet) {
31+
if (!isTimeZoneSet) {
3232
DATE_FORMAT.timeZone = TimeZone.getTimeZone("UTC")
33-
mIsTimeZoneSet = true
33+
isTimeZoneSet = true
3434
}
3535

3636
val thrown = r.thrown
@@ -59,6 +59,6 @@ internal class LogFormatter : Formatter() {
5959
// private val DATE_FORMAT = SimpleDateFormat("MM-dd HH:mm:ss.SSS", Locale.US)
6060
private val DATE_FORMAT = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss*SSSZZZZ", Locale.US)
6161

62-
private var mIsTimeZoneSet = false
62+
private var isTimeZoneSet = false
6363
}
6464
}

features/rageshake/impl/src/main/kotlin/io/element/android/features/rageshake/impl/reporter/DefaultBugReporter.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ class DefaultBugReporter @Inject constructor(
101101
}
102102

103103
// the pending bug report call
104-
private var mBugReportCall: Call? = null
104+
private var bugReportCall: Call? = null
105105

106106
// boolean to cancel the bug report
107-
private val mIsCancelled = false
107+
private val isCancelled = false
108108

109109
/*
110110
val adapter = MatrixJsonParser.getMoshi()
@@ -151,7 +151,7 @@ class DefaultBugReporter @Inject constructor(
151151
listener: BugReporterListener?
152152
) {
153153
// enumerate files to delete
154-
val mBugReportFiles: MutableList<File> = ArrayList()
154+
val bugReportFiles: MutableList<File> = ArrayList()
155155

156156
try {
157157

@@ -172,15 +172,15 @@ class DefaultBugReporter @Inject constructor(
172172
val files = getLogFiles()
173173
files.mapNotNullTo(gzippedFiles) { f ->
174174
when {
175-
mIsCancelled -> null
175+
isCancelled -> null
176176
f.extension == "gz" -> f
177177
else -> compressFile(f)
178178
}
179179
}
180180
files.deleteAllExceptMostRecent()
181181
}
182182

183-
if (!mIsCancelled && (withCrashLogs || withDevicesLogs)) {
183+
if (!isCancelled && (withCrashLogs || withDevicesLogs)) {
184184
val gzippedLogcat = saveLogCat(false)
185185

186186
if (null != gzippedLogcat) {
@@ -215,7 +215,7 @@ class DefaultBugReporter @Inject constructor(
215215
val userId = sessionData?.userId ?: "undefined"
216216
var olmVersion = "undefined"
217217

218-
if (!mIsCancelled) {
218+
if (!isCancelled) {
219219
val text = when (reportType) {
220220
ReportType.BUG_REPORT -> bugDescription
221221
ReportType.SUGGESTION -> "[Suggestion] $bugDescription"
@@ -268,7 +268,7 @@ class DefaultBugReporter @Inject constructor(
268268
}
269269
}
270270

271-
mBugReportFiles.addAll(gzippedFiles)
271+
bugReportFiles.addAll(gzippedFiles)
272272

273273
if (gzippedFiles.isNotEmpty() && !uploadedSomeLogs) {
274274
serverError = "Couldn't upload any logs, please retry."
@@ -336,8 +336,8 @@ class DefaultBugReporter @Inject constructor(
336336
0
337337
}
338338

339-
if (mIsCancelled && null != mBugReportCall) {
340-
mBugReportCall!!.cancel()
339+
if (isCancelled && null != bugReportCall) {
340+
bugReportCall!!.cancel()
341341
}
342342

343343
Timber.v("## onWrite() : $percentage%")
@@ -360,8 +360,8 @@ class DefaultBugReporter @Inject constructor(
360360

361361
// trigger the request
362362
try {
363-
mBugReportCall = okHttpClient.get().newCall(request)
364-
response = mBugReportCall!!.execute()
363+
bugReportCall = okHttpClient.get().newCall(request)
364+
response = bugReportCall!!.execute()
365365
responseCode = response.code
366366
} catch (e: CancellationException) {
367367
throw e
@@ -423,11 +423,11 @@ class DefaultBugReporter @Inject constructor(
423423
}
424424

425425
withContext(coroutineDispatchers.main) {
426-
mBugReportCall = null
426+
bugReportCall = null
427427

428428
if (null != listener) {
429429
try {
430-
if (mIsCancelled) {
430+
if (isCancelled) {
431431
listener.onUploadCancelled()
432432
} else if (null == serverError) {
433433
listener.onUploadSucceed(reportURL)
@@ -443,7 +443,7 @@ class DefaultBugReporter @Inject constructor(
443443
}
444444
} finally {
445445
// delete the generated files when the bug report process has finished
446-
for (file in mBugReportFiles) {
446+
for (file in bugReportFiles) {
447447
file.safeDelete()
448448
}
449449
}

libraries/push/impl/src/main/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class DefaultPushHandler @Inject constructor(
5656
private val coroutineScope = CoroutineScope(SupervisorJob())
5757

5858
// UI handler
59-
private val mUIHandler by lazy {
59+
private val uiHandler by lazy {
6060
Handler(Looper.getMainLooper())
6161
}
6262

@@ -81,7 +81,7 @@ class DefaultPushHandler @Inject constructor(
8181
return
8282
}
8383

84-
mUIHandler.post {
84+
uiHandler.post {
8585
coroutineScope.launch(Dispatchers.IO) { handleInternal(pushData) }
8686
}
8787
}

0 commit comments

Comments
 (0)