コード整形

This commit is contained in:
tateisu 2023-07-20 11:40:12 +09:00
parent 55fb631952
commit 4fc6442c37
14 changed files with 87 additions and 101 deletions

View File

@ -171,7 +171,7 @@ dependencies {
implementation project(":anko")
implementation fileTree(include: ["*.aar"], dir: "src/main/libs")
fcmImplementation "com.google.firebase:firebase-messaging:23.1.2"
fcmImplementation "com.google.firebase:firebase-messaging:23.2.0"
fcmImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$kotlinxCoroutinesVersion"
// implementation "org.conscrypt:conscrypt-android:$conscryptVersion"

View File

@ -65,7 +65,7 @@ class TestTootInstance {
/*
TootInstance.get() はアカウントを指定する場合とホストを指定する場合がある
ホスト指定とアカウント指定 MastodonとMisskey で試す
*/
*/
@Test
fun instanceByHostname() = runTest {

View File

@ -692,7 +692,10 @@ class ActAppSetting : AppCompatActivity(), ColorPickerDialogListener, View.OnCli
etEditText.setText(text)
etEditText.setSelection(0, text.length)
item.showEditText.invoke(actAppSetting,views.etEditText)
item.showEditText.invoke(
actAppSetting,
views.etEditText
)
}
updateErrorView()
}

View File

@ -2,7 +2,6 @@ package jp.juggler.subwaytooter
import android.app.Activity
import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.graphics.Typeface
@ -627,30 +626,29 @@ class ActMain : AppCompatActivity(),
super.onResume()
/*
super.onResume() から呼ばれる isTopOfTask() android.os.RemoteException 例外をたまに出すが放置することにした
java.lang.RuntimeException:
at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4430)
at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4470)
Caused by: java.lang.IllegalArgumentException:
at android.os.Parcel.createException (Parcel.java:1957)
at android.os.Parcel.readException (Parcel.java:1921)
at android.os.Parcel.readException (Parcel.java:1871)
at android.app.IActivityManager$Stub$Proxy.isTopOfTask (IActivityManager.java:7912)
at android.app.Activity.isTopOfTask (Activity.java:6724)
at android.app.Activity.onResume (Activity.java:1425)
at androidx.fragment.app.FragmentActivity.onResume (FragmentActivity.java:456)
at jp.juggler.subwaytooter.ActMain.onResume (ActMain.kt:685)
at android.app.Instrumentation.callActivityOnResume (Instrumentation.java:1456)
at android.app.Activity.performResume (Activity.java:7614)
at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4412)
Caused by: android.os.RemoteException:
at com.android.server.am.ActivityManagerService.isTopOfTask (ActivityManagerService.java:16128)
at android.app.IActivityManager$Stub.onTransact (IActivityManager.java:2376)
at com.android.server.am.ActivityManagerService.onTransact (ActivityManagerService.java:3648)
at com.android.server.am.HwActivityManagerService.onTransact (HwActivityManagerService.java:609)
at android.os.Binder.execTransact (Binder.java:739)
*/
super.onResume() から呼ばれる isTopOfTask() android.os.RemoteException 例外をたまに出すが放置することにした
java.lang.RuntimeException:
at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4430)
at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4470)
Caused by: java.lang.IllegalArgumentException:
at android.os.Parcel.createException (Parcel.java:1957)
at android.os.Parcel.readException (Parcel.java:1921)
at android.os.Parcel.readException (Parcel.java:1871)
at android.app.IActivityManager$Stub$Proxy.isTopOfTask (IActivityManager.java:7912)
at android.app.Activity.isTopOfTask (Activity.java:6724)
at android.app.Activity.onResume (Activity.java:1425)
at androidx.fragment.app.FragmentActivity.onResume (FragmentActivity.java:456)
at jp.juggler.subwaytooter.ActMain.onResume (ActMain.kt:685)
at android.app.Instrumentation.callActivityOnResume (Instrumentation.java:1456)
at android.app.Activity.performResume (Activity.java:7614)
at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4412)
Caused by: android.os.RemoteException:
at com.android.server.am.ActivityManagerService.isTopOfTask (ActivityManagerService.java:16128)
at android.app.IActivityManager$Stub.onTransact (IActivityManager.java:2376)
at com.android.server.am.ActivityManagerService.onTransact (ActivityManagerService.java:3648)
at com.android.server.am.HwActivityManagerService.onTransact (HwActivityManagerService.java:609)
at android.os.Binder.execTransact (Binder.java:739)
*/
if (PrefB.bpDontScreenOff.value) {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)

View File

@ -214,7 +214,7 @@ suspend fun <T : Any?, A : Context> A.runApiTask2(
progressPrefix: String? = null,
progressSetup: (progress: ProgressDialogEx) -> Unit = ApiTask.defaultProgressSetupCallback,
backgroundBlock: suspend A.(client: TootApiClient) -> T,
) :T = TootTaskRunner2.runApiTask(
): T = TootTaskRunner2.runApiTask(
this,
accessInfo,
null,

View File

@ -1,10 +1,12 @@
package jp.juggler.subwaytooter.api
import java.lang.Exception
class TootApiResultException(val result: TootApiResult?) : Exception(result?.error ?: "cancelled.") {
class TootApiResultException(val result: TootApiResult?) :
Exception(result?.error ?: "cancelled.") {
constructor(error: String) : this(TootApiResult(error))
}
fun errorApiResult(result: TootApiResult?):Nothing = throw TootApiResultException(result)
fun errorApiResult(error:String):Nothing = throw TootApiResultException(error)
fun errorApiResult(result: TootApiResult?): Nothing =
throw TootApiResultException(result)
fun errorApiResult(error: String): Nothing =
throw TootApiResultException(error)

View File

@ -604,6 +604,7 @@ open class TootAccount(
apDomain = pair.second ?: error("can't get apDomain from acct or url")
acct = Acct.parse(username, apDomain)
}
else -> error("serverType missmatch: ${parser.serviceType}")
}
return TootAccount(
@ -713,12 +714,9 @@ open class TootAccount(
// Tootsearch用。URLやUriを使ってアカウントのインスタンス名を調べる
fun findHostFromUrl(
acctArg: String?,
linkHelper: LinkHelper
?,
url: String
?,
)
: Pair<Host?, Host?> {
linkHelper: LinkHelper?,
url: String?,
): Pair<Host?, Host?> {
val apDomain = findApDomain(acctArg, linkHelper)
val apiHost = findApiHost(url)
return Pair(apiHost ?: apDomain, apDomain ?: apiHost)

View File

@ -356,7 +356,7 @@ private fun ItemViewHolder.showAttachments(status: TootStatus) {
}
}
val reUrlGif by lazy{
val reUrlGif by lazy {
"""\.gif(?:\z|\?|#)"""
.toRegex(RegexOption.IGNORE_CASE)
}

View File

@ -38,8 +38,8 @@ abstract class PushBase {
subLog: SubscriptionLogger,
account: SavedAccount,
willRemoveSubscription: Boolean,
forceUpdate:Boolean,
):String?
forceUpdate: Boolean,
): String?
// プッシュメッセージのJSONデータを通知用に整形
abstract suspend fun formatPushMessage(

View File

@ -100,7 +100,7 @@ class AttachmentRequest(
if (mimeType == MIME_TYPE_GIF) {
// GIFはそのまま投げる
return contentUriOpener(context.contentResolver, uri, mimeType, isImage = true)
}else if (mimeType.startsWith("image")) {
} else if (mimeType.startsWith("image")) {
// 静止画
return createResizedImageOpener()
}
@ -372,10 +372,11 @@ class AttachmentRequest(
private suspend fun createResizedAudioOpener(srcBytes: Long): InputStreamOpener {
val instance = instance()
val mediaConfig = mediaConfig()
return when {
return when {
mimeType.mimeTypeIsSupported(instance) &&
goodAudioType.contains(mimeType) &&
srcBytes <= maxBytesVideo(instance,mediaConfig).toLong() -> contentUriOpener(
srcBytes <= maxBytesVideo(instance, mediaConfig).toLong()
-> contentUriOpener(
context.contentResolver,
uri,
mimeType,
@ -402,5 +403,4 @@ class AttachmentRequest(
}
}
}
}

View File

@ -328,7 +328,7 @@ class AttachmentUploader(
val maxBytesImage = ar.maxBytesImage(instance, mediaConfig)
val opener = ar.createOpener()
try{
try {
if (opener.contentLength > maxBytesImage.toLong()) {
return@runApiTask TootApiResult(
@ -339,7 +339,8 @@ class AttachmentUploader(
)
}
val fileName = fixDocumentName(getDocumentName(safeContext.contentResolver, src.uri))
val fileName =
fixDocumentName(getDocumentName(safeContext.contentResolver, src.uri))
if (account.isMisskey) {
TootApiResult("custom thumbnail is not supported on misskey account.")
@ -367,7 +368,7 @@ class AttachmentUploader(
}
result
}
}finally{
} finally {
opener.deleteTempFile()
}
}

View File

@ -28,4 +28,3 @@ fun Context.getUserAgent(): String {
else -> userAgentDefault()
}
}

View File

@ -76,10 +76,6 @@ comments:
complexity:
active: true
CyclomaticComplexMethod:
active: false
threshold: 20
ComplexCondition:
active: true
threshold: 8
@ -88,13 +84,15 @@ complexity:
threshold: 10
includeStaticDeclarations: false
includePrivateDeclarations: false
ComplexMethod:
active: true
CyclomaticComplexMethod:
active: false
threshold: 100
ignoreSingleWhenExpression: true
ignoreSimpleWhenEntries: true
ignoreNestingFunctions: true
nestingFunctions: ['run', 'let', 'apply', 'with', 'also', 'use', 'forEach', 'isNotNull', 'ifNull']
LabeledExpression:
active: false
ignoredLabels: []
@ -254,9 +252,6 @@ formatting:
android: false
autoCorrect: true
MultiLineIfElse:
active: false
Wrapping:
active: false
AnnotationOnSeparateLine:
@ -293,7 +288,6 @@ formatting:
active: false
autoCorrect: true
indentSize: 4
continuationIndentSize: 4
MaximumLineLength:
active: false
maxLineLength: 120
@ -390,6 +384,10 @@ formatting:
# 誤検出があるので無効化
active: false
autoCorrect: true
BlockCommentInitialStarAlignment:
active: false
CommentWrapping:
active: false
naming:
active: true
@ -402,7 +400,6 @@ naming:
parameterPattern: '[a-z][A-Za-z0-9]*'
privateParameterPattern: '[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^'
ignoreOverridden: true
excludes:
- '**/test/**'
- '**/androidTest/**'
@ -433,14 +430,12 @@ naming:
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
functionPattern: '([a-z][a-zA-Z0-9]*)|(`.*`)'
excludeClassPattern: '$^'
ignoreOverridden: true
ignoreAnnotated: ['Composable']
FunctionParameterNaming:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
parameterPattern: '[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^'
ignoreOverridden: true
InvalidPackageDeclaration:
active: false
excludes: ['*.kts']
@ -495,7 +490,6 @@ naming:
variablePattern: '[a-z][A-Za-z0-9]*'
privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^'
ignoreOverridden: true
performance:
active: true
@ -520,8 +514,6 @@ potential-bugs:
active: false
DoubleMutabilityForCollection:
active: false
DuplicateCaseInWhenExpression:
active: true
EqualsAlwaysReturnsTrueOrFalse:
active: true
EqualsWithHashCodeExist:
@ -534,7 +526,7 @@ potential-bugs:
active: false
IgnoredReturnValue:
active: false
restrictToAnnotatedMethods: true
restrictToConfig: true
returnValueAnnotations: ['*.CheckReturnValue', '*.CheckResult']
ImplicitDefaultLocale:
active: true
@ -554,13 +546,8 @@ potential-bugs:
ignoreOnClassesPattern: ''
MapGetWithNotNullAssertionOperator:
active: false
MissingWhenCase:
active: true
allowElseExpression: true
NullableToStringCall:
active: false
RedundantElseInWhen:
active: true
UnconditionalJumpStatementInLoop:
active: false
UnnecessaryNotNullOperator:
@ -590,7 +577,7 @@ style:
active: false
DataClassContainsFunctions:
active: false
conversionFunctionPrefix: 'to'
conversionFunctionPrefix: ['to']
DataClassShouldBeImmutable:
active: false
DestructuringDeclarationWithTooManyEntries:
@ -608,8 +595,8 @@ style:
active: false
includeLineWrapping: false
ForbiddenComment:
active: true
values: ['TODO:', 'FIXME:', 'STOPSHIP:']
active: false
# comments: ???
allowedPatterns: ''
ForbiddenImport:
active: false
@ -631,10 +618,6 @@ style:
- '**/jvmTest/**'
- '**/jsTest/**'
- '**/iosTest/**'
ForbiddenPublicDataClass:
active: true
excludes: ['**']
ignorePackages: ['*.internal', '*.internal.*']
ForbiddenVoid:
active: false
ignoreOverridden: false
@ -643,14 +626,8 @@ style:
active: true
ignoreOverridableFunction: true
ignoreActualFunction: true
excludedFunctions: 'describeContents'
excludedFunctions: ['describeContents']
ignoreAnnotated: ['dagger.Provides']
LibraryCodeMustSpecifyReturnType:
active: true
excludes: ['**']
LibraryEntitiesShouldNotBePublic:
active: true
excludes: ['**']
LoopWithTooManyJumpStatements:
active: true
maxJumpCount: 10
@ -668,8 +645,6 @@ style:
ignoreEnums: false
ignoreRanges: false
ignoreExtensionFunctions: true
MandatoryBracesIfStatements:
active: false
MandatoryBracesLoops:
active: false
MaxLineLength:
@ -711,7 +686,7 @@ style:
ReturnCount:
active: false
max: 10
excludedFunctions: 'equals'
excludedFunctions: ['equals']
excludeLabeled: false
excludeReturnFromLambda: true
excludeGuardClauses: false
@ -790,3 +765,7 @@ style:
- java.util.*
- kotlinx.android.synthetic.*
- android.content.*
UnusedPrivateProperty:
active: false
UnusedParameter:
active: false

View File

@ -6,25 +6,31 @@ use warnings;
my $inFile = "app/build/reports/detekt/st-detektAll.txt";
my $rv = system qq(./gradlew :app:detektAll);
$rv == 256 and $rv =0;
$rv and die "gradle failed.";
my @lines;
say "#############################################";
say "# reading $inFile ...";
my @lines;
open(my $fh, "<:encoding(UTF-8)",$inFile) or die "$! $inFile";
while(<$fh>){
s/[\x0d\x0a]+//;
next if not length;
# TopLevelPropertyNaming - [wild] at Z:\mastodon-related\SubwayTooter\app\src\main\java\jp\juggler\subwaytooter\util\MimeTypeUtils.kt:118:19 - Signature=MimeTypeUtils.kt$private const val wild = '?'.code.toByte()
if(not /\A(.+) at (\S+?:\d+:\d+) - (.+)/){
say "?? $_";
s|\\|/|g;
# SpacingAroundCurly - [<anonymous>] at Z:\mastodon-related\SubwayTooter\app\src\main\java\jp\juggler\subwaytooter\itemviewholder\ItemViewHolderShowStatus.kt:359:21 - Signature=ItemViewHolderShowStatus.kt${
if( m|\A(\S+) - \[([^]]+)\] at (\S+)|){
my($name,$obj,$pos)=($1,$2,$3);
$pos =~ s|\A.*?/SubwayTooter/||;
push @lines,"$pos $name [$obj]";
next;
}
my($name,$pos,$other)=($1,$2,$3);
$pos =~ s|\A.+\\SubwayTooter\\||;
$pos =~ s|\\|/|g;
push @lines, "$pos $name $other";
die "parse error: ?? $_";
}
say $_ for sort @lines;
say "#############################################";
say "# result:";
@lines or say "no problems found.";
say $_ for sort @lines;