Konsist: no field should have 'm' prefix, and fix new detected issues.
This commit is contained in:
parent
108ce544d7
commit
69c46c993e
4 changed files with 33 additions and 19 deletions
|
|
@ -23,6 +23,7 @@ import com.lemonappdev.konsist.api.ext.list.constructors
|
||||||
import com.lemonappdev.konsist.api.ext.list.modifierprovider.withoutModifier
|
import com.lemonappdev.konsist.api.ext.list.modifierprovider.withoutModifier
|
||||||
import com.lemonappdev.konsist.api.ext.list.modifierprovider.withoutOverrideModifier
|
import com.lemonappdev.konsist.api.ext.list.modifierprovider.withoutOverrideModifier
|
||||||
import com.lemonappdev.konsist.api.ext.list.parameters
|
import com.lemonappdev.konsist.api.ext.list.parameters
|
||||||
|
import com.lemonappdev.konsist.api.ext.list.properties
|
||||||
import com.lemonappdev.konsist.api.ext.list.withAllAnnotationsOf
|
import com.lemonappdev.konsist.api.ext.list.withAllAnnotationsOf
|
||||||
import com.lemonappdev.konsist.api.ext.list.withAllParentsOf
|
import com.lemonappdev.konsist.api.ext.list.withAllParentsOf
|
||||||
import com.lemonappdev.konsist.api.ext.list.withNameEndingWith
|
import com.lemonappdev.konsist.api.ext.list.withNameEndingWith
|
||||||
|
|
@ -30,6 +31,7 @@ import com.lemonappdev.konsist.api.ext.list.withReturnType
|
||||||
import com.lemonappdev.konsist.api.ext.list.withTopLevel
|
import com.lemonappdev.konsist.api.ext.list.withTopLevel
|
||||||
import com.lemonappdev.konsist.api.ext.list.withoutName
|
import com.lemonappdev.konsist.api.ext.list.withoutName
|
||||||
import com.lemonappdev.konsist.api.ext.list.withoutNameEndingWith
|
import com.lemonappdev.konsist.api.ext.list.withoutNameEndingWith
|
||||||
|
import com.lemonappdev.konsist.api.verify.assertFalse
|
||||||
import com.lemonappdev.konsist.api.verify.assertTrue
|
import com.lemonappdev.konsist.api.verify.assertTrue
|
||||||
import io.element.android.libraries.architecture.Presenter
|
import io.element.android.libraries.architecture.Presenter
|
||||||
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
|
||||||
|
|
@ -122,4 +124,16 @@ class KonsistTest {
|
||||||
functionDeclaration.name == "create${functionDeclaration.returnType?.name}"
|
functionDeclaration.name == "create${functionDeclaration.returnType?.name}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `no field should have 'm' prefix`() {
|
||||||
|
Konsist
|
||||||
|
.scopeFromProject()
|
||||||
|
.classes()
|
||||||
|
.properties()
|
||||||
|
.assertFalse {
|
||||||
|
val secondCharacterIsUppercase = it.name.getOrNull(1)?.isUpperCase() ?: false
|
||||||
|
it.name.startsWith('m') && secondCharacterIsUppercase
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,9 @@ import java.util.logging.LogRecord
|
||||||
internal class LogFormatter : Formatter() {
|
internal class LogFormatter : Formatter() {
|
||||||
|
|
||||||
override fun format(r: LogRecord): String {
|
override fun format(r: LogRecord): String {
|
||||||
if (!mIsTimeZoneSet) {
|
if (!isTimeZoneSet) {
|
||||||
DATE_FORMAT.timeZone = TimeZone.getTimeZone("UTC")
|
DATE_FORMAT.timeZone = TimeZone.getTimeZone("UTC")
|
||||||
mIsTimeZoneSet = true
|
isTimeZoneSet = true
|
||||||
}
|
}
|
||||||
|
|
||||||
val thrown = r.thrown
|
val thrown = r.thrown
|
||||||
|
|
@ -59,6 +59,6 @@ internal class LogFormatter : Formatter() {
|
||||||
// private val DATE_FORMAT = SimpleDateFormat("MM-dd HH:mm:ss.SSS", Locale.US)
|
// private val DATE_FORMAT = SimpleDateFormat("MM-dd HH:mm:ss.SSS", Locale.US)
|
||||||
private val DATE_FORMAT = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss*SSSZZZZ", Locale.US)
|
private val DATE_FORMAT = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss*SSSZZZZ", Locale.US)
|
||||||
|
|
||||||
private var mIsTimeZoneSet = false
|
private var isTimeZoneSet = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -101,10 +101,10 @@ class DefaultBugReporter @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
// the pending bug report call
|
// the pending bug report call
|
||||||
private var mBugReportCall: Call? = null
|
private var bugReportCall: Call? = null
|
||||||
|
|
||||||
// boolean to cancel the bug report
|
// boolean to cancel the bug report
|
||||||
private val mIsCancelled = false
|
private val isCancelled = false
|
||||||
|
|
||||||
/*
|
/*
|
||||||
val adapter = MatrixJsonParser.getMoshi()
|
val adapter = MatrixJsonParser.getMoshi()
|
||||||
|
|
@ -151,7 +151,7 @@ class DefaultBugReporter @Inject constructor(
|
||||||
listener: BugReporterListener?
|
listener: BugReporterListener?
|
||||||
) {
|
) {
|
||||||
// enumerate files to delete
|
// enumerate files to delete
|
||||||
val mBugReportFiles: MutableList<File> = ArrayList()
|
val bugReportFiles: MutableList<File> = ArrayList()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
@ -172,7 +172,7 @@ class DefaultBugReporter @Inject constructor(
|
||||||
val files = getLogFiles()
|
val files = getLogFiles()
|
||||||
files.mapNotNullTo(gzippedFiles) { f ->
|
files.mapNotNullTo(gzippedFiles) { f ->
|
||||||
when {
|
when {
|
||||||
mIsCancelled -> null
|
isCancelled -> null
|
||||||
f.extension == "gz" -> f
|
f.extension == "gz" -> f
|
||||||
else -> compressFile(f)
|
else -> compressFile(f)
|
||||||
}
|
}
|
||||||
|
|
@ -180,7 +180,7 @@ class DefaultBugReporter @Inject constructor(
|
||||||
files.deleteAllExceptMostRecent()
|
files.deleteAllExceptMostRecent()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mIsCancelled && (withCrashLogs || withDevicesLogs)) {
|
if (!isCancelled && (withCrashLogs || withDevicesLogs)) {
|
||||||
val gzippedLogcat = saveLogCat(false)
|
val gzippedLogcat = saveLogCat(false)
|
||||||
|
|
||||||
if (null != gzippedLogcat) {
|
if (null != gzippedLogcat) {
|
||||||
|
|
@ -215,7 +215,7 @@ class DefaultBugReporter @Inject constructor(
|
||||||
val userId = sessionData?.userId ?: "undefined"
|
val userId = sessionData?.userId ?: "undefined"
|
||||||
var olmVersion = "undefined"
|
var olmVersion = "undefined"
|
||||||
|
|
||||||
if (!mIsCancelled) {
|
if (!isCancelled) {
|
||||||
val text = when (reportType) {
|
val text = when (reportType) {
|
||||||
ReportType.BUG_REPORT -> bugDescription
|
ReportType.BUG_REPORT -> bugDescription
|
||||||
ReportType.SUGGESTION -> "[Suggestion] $bugDescription"
|
ReportType.SUGGESTION -> "[Suggestion] $bugDescription"
|
||||||
|
|
@ -268,7 +268,7 @@ class DefaultBugReporter @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mBugReportFiles.addAll(gzippedFiles)
|
bugReportFiles.addAll(gzippedFiles)
|
||||||
|
|
||||||
if (gzippedFiles.isNotEmpty() && !uploadedSomeLogs) {
|
if (gzippedFiles.isNotEmpty() && !uploadedSomeLogs) {
|
||||||
serverError = "Couldn't upload any logs, please retry."
|
serverError = "Couldn't upload any logs, please retry."
|
||||||
|
|
@ -336,8 +336,8 @@ class DefaultBugReporter @Inject constructor(
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIsCancelled && null != mBugReportCall) {
|
if (isCancelled && null != bugReportCall) {
|
||||||
mBugReportCall!!.cancel()
|
bugReportCall!!.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
Timber.v("## onWrite() : $percentage%")
|
Timber.v("## onWrite() : $percentage%")
|
||||||
|
|
@ -360,8 +360,8 @@ class DefaultBugReporter @Inject constructor(
|
||||||
|
|
||||||
// trigger the request
|
// trigger the request
|
||||||
try {
|
try {
|
||||||
mBugReportCall = okHttpClient.get().newCall(request)
|
bugReportCall = okHttpClient.get().newCall(request)
|
||||||
response = mBugReportCall!!.execute()
|
response = bugReportCall!!.execute()
|
||||||
responseCode = response.code
|
responseCode = response.code
|
||||||
} catch (e: CancellationException) {
|
} catch (e: CancellationException) {
|
||||||
throw e
|
throw e
|
||||||
|
|
@ -423,11 +423,11 @@ class DefaultBugReporter @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
withContext(coroutineDispatchers.main) {
|
withContext(coroutineDispatchers.main) {
|
||||||
mBugReportCall = null
|
bugReportCall = null
|
||||||
|
|
||||||
if (null != listener) {
|
if (null != listener) {
|
||||||
try {
|
try {
|
||||||
if (mIsCancelled) {
|
if (isCancelled) {
|
||||||
listener.onUploadCancelled()
|
listener.onUploadCancelled()
|
||||||
} else if (null == serverError) {
|
} else if (null == serverError) {
|
||||||
listener.onUploadSucceed(reportURL)
|
listener.onUploadSucceed(reportURL)
|
||||||
|
|
@ -443,7 +443,7 @@ class DefaultBugReporter @Inject constructor(
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
// delete the generated files when the bug report process has finished
|
// delete the generated files when the bug report process has finished
|
||||||
for (file in mBugReportFiles) {
|
for (file in bugReportFiles) {
|
||||||
file.safeDelete()
|
file.safeDelete()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class DefaultPushHandler @Inject constructor(
|
||||||
private val coroutineScope = CoroutineScope(SupervisorJob())
|
private val coroutineScope = CoroutineScope(SupervisorJob())
|
||||||
|
|
||||||
// UI handler
|
// UI handler
|
||||||
private val mUIHandler by lazy {
|
private val uiHandler by lazy {
|
||||||
Handler(Looper.getMainLooper())
|
Handler(Looper.getMainLooper())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ class DefaultPushHandler @Inject constructor(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mUIHandler.post {
|
uiHandler.post {
|
||||||
coroutineScope.launch(Dispatchers.IO) { handleInternal(pushData) }
|
coroutineScope.launch(Dispatchers.IO) { handleInternal(pushData) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue