Refine code style

This commit is contained in:
Mygod
2020-08-04 03:07:04 +08:00
parent 1d0422a8ec
commit ba80e922b8
3 changed files with 50 additions and 28 deletions

View File

@@ -1,4 +1,4 @@
# https://github.com/arturbosch/detekt/blob/1.7.1/detekt-cli/src/main/resources/default-detekt-config.yml # https://github.com/arturbosch/detekt/blob/v1.10.0/detekt-core/src/main/resources/default-detekt-config.yml
comments: comments:
active: false active: false
@@ -41,14 +41,14 @@ complexity:
threshold: 4 threshold: 4
StringLiteralDuplication: StringLiteralDuplication:
active: true active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
threshold: 3 threshold: 3
ignoreAnnotation: true ignoreAnnotation: true
excludeStringsWithLessThan5Characters: true excludeStringsWithLessThan5Characters: true
ignoreStringsRegex: '$^' ignoreStringsRegex: '$^'
TooManyFunctions: TooManyFunctions:
active: true active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
thresholdInFiles: 11 thresholdInFiles: 11
thresholdInClasses: 11 thresholdInClasses: 11
thresholdInInterfaces: 11 thresholdInInterfaces: 11
@@ -69,7 +69,7 @@ empty-blocks:
active: true active: true
EmptyCatchBlock: EmptyCatchBlock:
active: true active: true
allowedExceptionNameRegex: '^(_|(ignore|expected).*)' allowedExceptionNameRegex: '_|(ignore|expected).*'
EmptyClassBlock: EmptyClassBlock:
active: true active: true
EmptyDefaultConstructor: EmptyDefaultConstructor:
@@ -123,7 +123,7 @@ exceptions:
- NumberFormatException - NumberFormatException
- ParseException - ParseException
- MalformedURLException - MalformedURLException
allowedExceptionNameRegex: '^(_|(ignore|expected).*)' allowedExceptionNameRegex: '_|(ignore|expected).*'
ThrowingExceptionFromFinally: ThrowingExceptionFromFinally:
active: false active: false
ThrowingExceptionInMain: ThrowingExceptionInMain:
@@ -168,7 +168,9 @@ formatting:
autoCorrect: true autoCorrect: true
insertFinalNewLine: true insertFinalNewLine: true
ImportOrdering: ImportOrdering:
active: false active: true
autoCorrect: true
layout: 'idea'
Indentation: Indentation:
active: true active: true
autoCorrect: true autoCorrect: true
@@ -233,6 +235,9 @@ formatting:
SpacingAroundDot: SpacingAroundDot:
active: true active: true
autoCorrect: true autoCorrect: true
SpacingAroundDoubleColon:
active: true
autoCorrect: true
SpacingAroundKeyword: SpacingAroundKeyword:
active: true active: true
autoCorrect: true autoCorrect: true
@@ -245,6 +250,12 @@ formatting:
SpacingAroundRangeOperator: SpacingAroundRangeOperator:
active: true active: true
autoCorrect: true autoCorrect: true
SpacingBetweenDeclarationsWithAnnotations:
active: false
autoCorrect: true
SpacingBetweenDeclarationsWithComments:
active: false
autoCorrect: true
StringTemplate: StringTemplate:
active: true active: true
autoCorrect: true autoCorrect: true
@@ -253,38 +264,39 @@ naming:
active: true active: true
ClassNaming: ClassNaming:
active: true active: true
classPattern: '[A-Z$][a-zA-Z0-9$]*' excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] classPattern: '[A-Z][a-zA-Z0-9]*'
ConstructorParameterNaming: ConstructorParameterNaming:
active: true active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
parameterPattern: '[a-z][A-Za-z0-9]*' parameterPattern: '[a-z][A-Za-z0-9]*'
privateParameterPattern: '[a-z][A-Za-z0-9]*' privateParameterPattern: '[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^' excludeClassPattern: '$^'
ignoreOverridden: true ignoreOverridden: true
EnumNaming: EnumNaming:
active: true active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*' enumEntryPattern: '[A-Z][_a-zA-Z0-9]*'
ForbiddenClassName: ForbiddenClassName:
active: true active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
forbiddenName: [] forbiddenName: []
FunctionMaxLength: FunctionMaxLength:
active: true active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
maximumFunctionNameLength: 30 maximumFunctionNameLength: 30
FunctionMinLength: FunctionMinLength:
active: false active: false
FunctionNaming: FunctionNaming:
active: true active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$' functionPattern: '([a-z][a-zA-Z0-9]*)|(`.*`)'
excludeClassPattern: '$^' excludeClassPattern: '$^'
ignoreOverridden: true ignoreOverridden: true
ignoreAnnotated: ['Composable']
FunctionParameterNaming: FunctionParameterNaming:
active: true active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
parameterPattern: '[a-z][A-Za-z0-9]*' parameterPattern: '[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^' excludeClassPattern: '$^'
ignoreOverridden: true ignoreOverridden: true
@@ -298,29 +310,29 @@ naming:
active: false active: false
ObjectPropertyNaming: ObjectPropertyNaming:
active: true active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
constantPattern: '[A-Za-z][_A-Za-z0-9]*' constantPattern: '[A-Za-z][_A-Za-z0-9]*'
propertyPattern: '[A-Za-z][_A-Za-z0-9]*' propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*' privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*'
PackageNaming: PackageNaming:
active: true active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
packagePattern: '^[a-z]+(\.[a-z][A-Za-z0-9]*)*$' packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*'
TopLevelPropertyNaming: TopLevelPropertyNaming:
active: true active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
constantPattern: '[A-Z][_A-Z0-9]*' constantPattern: '[A-Z][_A-Z0-9]*'
propertyPattern: '[A-Za-z][_A-Za-z0-9]*' propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*' privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*'
VariableMaxLength: VariableMaxLength:
active: true active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
maximumVariableNameLength: 64 maximumVariableNameLength: 64
VariableMinLength: VariableMinLength:
active: false active: false
VariableNaming: VariableNaming:
active: true active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
variablePattern: '[a-z][A-Za-z0-9]*' variablePattern: '[a-z][A-Za-z0-9]*'
privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^' excludeClassPattern: '$^'
@@ -332,7 +344,7 @@ performance:
active: true active: true
ForEachOnRange: ForEachOnRange:
active: true active: true
excludes: ['**/test/**', '**/androidTest/**', '**/*.Test.kt', '**/*.Spec.kt', '**/*.Spek.kt'] excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
SpreadOperator: SpreadOperator:
active: false active: false
UnnecessaryTemporaryInstantiation: UnnecessaryTemporaryInstantiation:
@@ -352,8 +364,14 @@ potential-bugs:
active: true active: true
HasPlatformType: HasPlatformType:
active: true active: true
IgnoredReturnValue:
active: true
restrictToAnnotatedMethods: true
returnValueAnnotations: ['*.CheckReturnValue', '*.CheckResult']
ImplicitDefaultLocale: ImplicitDefaultLocale:
active: true active: true
ImplicitUnitReturnType:
active: false
InvalidRange: InvalidRange:
active: true active: true
IteratorHasNextCallsNextMethod: IteratorHasNextCallsNextMethod:
@@ -414,7 +432,7 @@ style:
forbiddenPatterns: '' forbiddenPatterns: ''
ForbiddenMethodCall: ForbiddenMethodCall:
active: true active: true
methods: [] methods: ['kotlin.io.println', 'kotlin.io.print']
ForbiddenPublicDataClass: ForbiddenPublicDataClass:
active: true active: true
ignorePackages: ['*.internal', '*.internal.*'] ignorePackages: ['*.internal', '*.internal.*']
@@ -436,6 +454,8 @@ style:
active: false active: false
MandatoryBracesIfStatements: MandatoryBracesIfStatements:
active: false active: false
MandatoryBracesLoops:
active: false
MaxLineLength: MaxLineLength:
active: true active: true
maxLineLength: 120 maxLineLength: 120

View File

@@ -372,13 +372,16 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene
p2pManager.createGroup(channel, WifiP2pConfig.Builder().apply { p2pManager.createGroup(channel, WifiP2pConfig.Builder().apply {
setNetworkName(PLACEHOLDER_NETWORK_NAME) setNetworkName(PLACEHOLDER_NETWORK_NAME)
setPassphrase(passphrase) setPassphrase(passphrase)
operatingChannel.let { oc -> when (val oc = operatingChannel) {
if (oc == 0) setGroupOperatingBand(when (val band = operatingBand) { 0 -> setGroupOperatingBand(when (val band = operatingBand) {
SoftApConfigurationCompat.BAND_ANY -> WifiP2pConfig.GROUP_OWNER_BAND_AUTO SoftApConfigurationCompat.BAND_ANY -> WifiP2pConfig.GROUP_OWNER_BAND_AUTO
SoftApConfigurationCompat.BAND_2GHZ -> WifiP2pConfig.GROUP_OWNER_BAND_2GHZ SoftApConfigurationCompat.BAND_2GHZ -> WifiP2pConfig.GROUP_OWNER_BAND_2GHZ
SoftApConfigurationCompat.BAND_5GHZ -> WifiP2pConfig.GROUP_OWNER_BAND_5GHZ SoftApConfigurationCompat.BAND_5GHZ -> WifiP2pConfig.GROUP_OWNER_BAND_5GHZ
else -> throw IllegalArgumentException("Unknown band $band") else -> throw IllegalArgumentException("Unknown band $band")
}) else setGroupOperatingFrequency(SoftApConfigurationCompat.channelToFrequency(operatingBand, oc)) })
else -> {
setGroupOperatingFrequency(SoftApConfigurationCompat.channelToFrequency(operatingBand, oc))
}
} }
setDeviceAddress(deviceAddress?.toPlatform()) setDeviceAddress(deviceAddress?.toPlatform())
}.build().run { }.build().run {

View File

@@ -25,7 +25,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import timber.log.Timber import timber.log.Timber
import java.lang.reflect.InvocationTargetException
@RequiresApi(24) @RequiresApi(24)
sealed class TetheringTileService : IpNeighbourMonitoringTileService(), TetheringManager.StartTetheringCallback { sealed class TetheringTileService : IpNeighbourMonitoringTileService(), TetheringManager.StartTetheringCallback {