Unverified Commit 11c09efa authored by Mygod's avatar Mygod Committed by GitHub

Update dependencies and refine style (#2308)

* Update dependencies

* Fix styling issues

* Some more fixes

Fixes #2306.
parent 41730631
...@@ -9,7 +9,7 @@ buildscript { ...@@ -9,7 +9,7 @@ buildscript {
minSdkVersion = 21 minSdkVersion = 21
sdkVersion = 29 sdkVersion = 29
compileSdkVersion = 29 compileSdkVersion = 29
lifecycleVersion = '2.2.0-alpha03' lifecycleVersion = '2.2.0-alpha05'
junitVersion = '4.12' junitVersion = '4.12'
androidTestVersion = '1.2.0' androidTestVersion = '1.2.0'
androidEspressoVersion = '3.2.0' androidEspressoVersion = '3.2.0'
...@@ -28,8 +28,8 @@ buildscript { ...@@ -28,8 +28,8 @@ buildscript {
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.22.0' classpath 'com.github.ben-manes:gradle-versions-plugin:0.25.0'
classpath 'com.google.gms:google-services:4.3.1' classpath 'com.google.gms:google-services:4.3.2'
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.8.0' classpath 'com.vanniktech:gradle-maven-publish-plugin:0.8.0'
classpath 'io.fabric.tools:gradle:1.31.0' classpath 'io.fabric.tools:gradle:1.31.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
......
...@@ -49,7 +49,7 @@ androidExtensions { ...@@ -49,7 +49,7 @@ androidExtensions {
experimental = true experimental = true
} }
def coroutinesVersion = '1.3.0' def coroutinesVersion = '1.3.1'
def roomVersion = '2.1.0' def roomVersion = '2.1.0'
def workVersion = '2.2.0' def workVersion = '2.2.0'
dependencies { dependencies {
...@@ -58,14 +58,14 @@ dependencies { ...@@ -58,14 +58,14 @@ dependencies {
api "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion" api "androidx.lifecycle:lifecycle-extensions:$lifecycleVersion"
api "androidx.lifecycle:lifecycle-livedata-core-ktx:$lifecycleVersion" api "androidx.lifecycle:lifecycle-livedata-core-ktx:$lifecycleVersion"
api "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion" api "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
api 'androidx.preference:preference:1.1.0-rc01' api 'androidx.preference:preference:1.1.0'
api "androidx.room:room-runtime:$roomVersion" api "androidx.room:room-runtime:$roomVersion"
api "androidx.work:work-runtime-ktx:$workVersion" api "androidx.work:work-runtime-ktx:$workVersion"
api "androidx.work:work-gcm:$workVersion" api "androidx.work:work-gcm:$workVersion"
api 'com.crashlytics.sdk.android:crashlytics:2.10.1' api 'com.crashlytics.sdk.android:crashlytics:2.10.1'
api 'com.google.code.gson:gson:2.8.5' api 'com.google.code.gson:gson:2.8.5'
api 'com.google.firebase:firebase-analytics:17.1.0' api 'com.google.firebase:firebase-analytics:17.2.0'
api 'com.google.firebase:firebase-config:19.0.0' api 'com.google.firebase:firebase-config:19.0.1'
api 'dnsjava:dnsjava:2.1.9' api 'dnsjava:dnsjava:2.1.9'
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion" api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
api "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion" api "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion"
......
...@@ -31,7 +31,6 @@ import com.github.shadowsocks.Core ...@@ -31,7 +31,6 @@ import com.github.shadowsocks.Core
import com.github.shadowsocks.Core.app import com.github.shadowsocks.Core.app
import kotlinx.coroutines.* import kotlinx.coroutines.*
import java.io.IOException import java.io.IOException
import java.lang.Runnable
import java.net.InetAddress import java.net.InetAddress
import java.util.concurrent.Executor import java.util.concurrent.Executor
import java.util.concurrent.Executors import java.util.concurrent.Executors
......
...@@ -112,8 +112,9 @@ data class Profile( ...@@ -112,8 +112,9 @@ data class Profile(
try { try {
val javaURI = URI(it.value) val javaURI = URI(it.value)
profile.host = javaURI.host ?: "" profile.host = javaURI.host ?: ""
if (profile.host.firstOrNull() == '[' && profile.host.lastOrNull() == ']') if (profile.host.firstOrNull() == '[' && profile.host.lastOrNull() == ']') {
profile.host = profile.host.substring(1, profile.host.length - 1) profile.host = profile.host.substring(1, profile.host.length - 1)
}
profile.remotePort = javaURI.port profile.remotePort = javaURI.port
profile.plugin = uri.getQueryParameter(Key.plugin) profile.plugin = uri.getQueryParameter(Key.plugin)
profile.name = uri.fragment ?: "" profile.name = uri.fragment ?: ""
...@@ -208,12 +209,14 @@ data class Profile( ...@@ -208,12 +209,14 @@ data class Profile(
} }
} }
} }
fun parseJson(json: JsonElement, feature: Profile? = null, create: (Profile) -> Unit) = JsonParser(feature).run { fun parseJson(json: JsonElement, feature: Profile? = null, create: (Profile) -> Unit) {
JsonParser(feature).run {
process(json) process(json)
for (profile in this) create(profile) for (profile in this) create(profile)
finalize(create) finalize(create)
} }
} }
}
@androidx.room.Dao @androidx.room.Dao
interface Dao { interface Dao {
...@@ -263,8 +266,9 @@ data class Profile( ...@@ -263,8 +266,9 @@ data class Profile(
.scheme("ss") .scheme("ss")
.encodedAuthority("$auth@$wrappedHost:$remotePort") .encodedAuthority("$auth@$wrappedHost:$remotePort")
val configuration = PluginConfiguration(plugin ?: "") val configuration = PluginConfiguration(plugin ?: "")
if (configuration.selected.isNotEmpty()) if (configuration.selected.isNotEmpty()) {
builder.appendQueryParameter(Key.plugin, configuration.selectedOptions.toString(false)) builder.appendQueryParameter(Key.plugin, configuration.selectedOptions.toString(false))
}
if (!name.isNullOrEmpty()) builder.fragment(name) if (!name.isNullOrEmpty()) builder.fragment(name)
return builder.build() return builder.build()
} }
......
...@@ -79,7 +79,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd ...@@ -79,7 +79,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
for (address in results) addRecord(when (address) { for (address in results) addRecord(when (address) {
is Inet4Address -> ARecord(question.name, DClass.IN, TTL, address) is Inet4Address -> ARecord(question.name, DClass.IN, TTL, address)
is Inet6Address -> AAAARecord(question.name, DClass.IN, TTL, address) is Inet6Address -> AAAARecord(question.name, DClass.IN, TTL, address)
else -> throw IllegalStateException("Unsupported address $address") else -> error("Unsupported address $address")
}, Section.ANSWER) }, Section.ANSWER)
}.toWire()) }.toWire())
} }
......
...@@ -37,7 +37,7 @@ class Socks5Endpoint(host: String, port: Int) { ...@@ -37,7 +37,7 @@ class Socks5Endpoint(host: String, port: Int) {
null -> Socks5Message.SOCKS_ATYP_DOMAINNAME null -> Socks5Message.SOCKS_ATYP_DOMAINNAME
is Inet4Address -> Socks5Message.SOCKS_ATYP_IPV4 is Inet4Address -> Socks5Message.SOCKS_ATYP_IPV4
is Inet6Address -> Socks5Message.SOCKS_ATYP_IPV6 is Inet6Address -> Socks5Message.SOCKS_ATYP_IPV6
else -> throw IllegalStateException("Unsupported address type $numeric") else -> error("Unsupported address type $numeric")
} }
ByteBuffer.allocate(bytes.size + (if (numeric == null) 1 else 0) + 3).apply { ByteBuffer.allocate(bytes.size + (if (numeric == null) 1 else 0) + 3).apply {
put(type.toByte()) put(type.toByte())
......
...@@ -42,7 +42,7 @@ class Subnet(val address: InetAddress, val prefixSize: Int) : Comparable<Subnet> ...@@ -42,7 +42,7 @@ class Subnet(val address: InetAddress, val prefixSize: Int) : Comparable<Subnet>
private val addressLength get() = address.address.size shl 3 private val addressLength get() = address.address.size shl 3
init { init {
if (prefixSize < 0 || prefixSize > addressLength) throw IllegalArgumentException("prefixSize: $prefixSize") require(prefixSize in 0..addressLength) { "prefixSize $prefixSize not in 0..$addressLength" }
} }
fun matches(other: InetAddress): Boolean { fun matches(other: InetAddress): Boolean {
......
...@@ -64,7 +64,7 @@ object DataStore : OnPreferenceDataStoreChangeListener { ...@@ -64,7 +64,7 @@ object DataStore : OnPreferenceDataStoreChangeListener {
?: BootReceiver.enabled.also { publicStore.putBoolean(Key.persistAcrossReboot, it) } ?: BootReceiver.enabled.also { publicStore.putBoolean(Key.persistAcrossReboot, it) }
val canToggleLocked: Boolean get() = publicStore.getBoolean(Key.directBootAware) == true val canToggleLocked: Boolean get() = publicStore.getBoolean(Key.directBootAware) == true
val directBootAware: Boolean get() = Core.directBootSupported && canToggleLocked val directBootAware: Boolean get() = Core.directBootSupported && canToggleLocked
val tcpFastOpen: Boolean get() = TcpFastOpen.sendEnabled && DataStore.publicStore.getBoolean(Key.tfo, true) val tcpFastOpen: Boolean get() = TcpFastOpen.sendEnabled && publicStore.getBoolean(Key.tfo, true)
val serviceMode get() = publicStore.getString(Key.serviceMode) ?: Key.modeVpn val serviceMode get() = publicStore.getString(Key.serviceMode) ?: Key.modeVpn
val listenAddress get() = if (publicStore.getBoolean(Key.shareOverLan, false)) "0.0.0.0" else "127.0.0.1" val listenAddress get() = if (publicStore.getBoolean(Key.shareOverLan, false)) "0.0.0.0" else "127.0.0.1"
var portProxy: Int var portProxy: Int
......
...@@ -55,16 +55,12 @@ object Commandline { ...@@ -55,16 +55,12 @@ object Commandline {
*/ */
fun toString(args: Iterable<String>?): String { fun toString(args: Iterable<String>?): String {
// empty path return empty string // empty path return empty string
if (args == null) { args ?: return ""
return ""
}
// path containing one or more elements // path containing one or more elements
val result = StringBuilder() val result = StringBuilder()
for (arg in args) { for (arg in args) {
if (result.isNotEmpty()) result.append(' ') if (result.isNotEmpty()) result.append(' ')
(0 until arg.length) arg.indices.map { arg[it] }.forEach {
.map { arg[it] }
.forEach {
when (it) { when (it) {
' ', '\\', '"', '\'' -> { ' ', '\\', '"', '\'' -> {
result.append('\\') // intentionally no break result.append('\\') // intentionally no break
...@@ -115,59 +111,49 @@ object Commandline { ...@@ -115,59 +111,49 @@ object Commandline {
inQuote -> if ("\'" == nextTok) { inQuote -> if ("\'" == nextTok) {
lastTokenHasBeenQuoted = true lastTokenHasBeenQuoted = true
state = normal state = normal
} else { } else current.append(nextTok)
current.append(nextTok) inDoubleQuote -> when (nextTok) {
} "\"" -> if (lastTokenIsSlash) {
inDoubleQuote -> if ("\"" == nextTok) {
if (lastTokenIsSlash) {
current.append(nextTok) current.append(nextTok)
lastTokenIsSlash = false lastTokenIsSlash = false
} else { } else {
lastTokenHasBeenQuoted = true lastTokenHasBeenQuoted = true
state = normal state = normal
} }
} else if ("\\" == nextTok) { "\\" -> lastTokenIsSlash = if (lastTokenIsSlash) {
lastTokenIsSlash = if (lastTokenIsSlash) {
current.append(nextTok) current.append(nextTok)
false false
} else } else true
true else -> {
} else {
if (lastTokenIsSlash) { if (lastTokenIsSlash) {
current.append("\\") // unescaped current.append("\\") // unescaped
lastTokenIsSlash = false lastTokenIsSlash = false
} }
current.append(nextTok) current.append(nextTok)
} }
}
else -> { else -> {
if (lastTokenIsSlash) { when {
lastTokenIsSlash -> {
current.append(nextTok) current.append(nextTok)
lastTokenIsSlash = false lastTokenIsSlash = false
} else if ("\\" == nextTok) }
lastTokenIsSlash = true "\\" == nextTok -> lastTokenIsSlash = true
else if ("\'" == nextTok) { "\'" == nextTok -> state = inQuote
state = inQuote "\"" == nextTok -> state = inDoubleQuote
} else if ("\"" == nextTok) { " " == nextTok -> if (lastTokenHasBeenQuoted || current.isNotEmpty()) {
state = inDoubleQuote
} else if (" " == nextTok) {
if (lastTokenHasBeenQuoted || current.isNotEmpty()) {
result.add(current.toString()) result.add(current.toString())
current.setLength(0) current.setLength(0)
} }
} else { else -> current.append(nextTok)
current.append(nextTok)
} }
lastTokenHasBeenQuoted = false lastTokenHasBeenQuoted = false
} }
} }
} }
if (lastTokenHasBeenQuoted || current.isNotEmpty()) { if (lastTokenHasBeenQuoted || current.isNotEmpty()) result.add(current.toString())
result.add(current.toString()) require(state != inQuote && state != inDoubleQuote) { "unbalanced quotes in $toProcess" }
} require(!lastTokenIsSlash) { "escape character following nothing in $toProcess" }
if (state == inQuote || state == inDoubleQuote) {
throw IllegalArgumentException("unbalanced quotes in $toProcess")
}
if (lastTokenIsSlash) throw IllegalArgumentException("escape character following nothing in $toProcess")
return result.toTypedArray() return result.toTypedArray()
} }
} }
# https://github.com/arturbosch/detekt/blob/RC9.2/detekt-cli/src/main/resources/default-detekt-config.yml # https://github.com/arturbosch/detekt/blob/1.0.1/detekt-cli/src/main/resources/default-detekt-config.yml
autoCorrect: true
comments: comments:
active: false active: false
...@@ -17,14 +16,16 @@ complexity: ...@@ -17,14 +16,16 @@ complexity:
active: true active: true
threshold: 10 threshold: 10
ignoreSingleWhenExpression: false ignoreSingleWhenExpression: false
ignoreSimpleWhenEntries: false
LabeledExpression: LabeledExpression:
active: false active: false
ignoredLabels: ""
LargeClass: LargeClass:
active: true active: true
threshold: 150 threshold: 600
LongMethod: LongMethod:
active: true active: true
threshold: 20 threshold: 60
LongParameterList: LongParameterList:
active: true active: true
threshold: 6 threshold: 6
...@@ -36,12 +37,14 @@ complexity: ...@@ -36,12 +37,14 @@ complexity:
threshold: 4 threshold: 4
StringLiteralDuplication: StringLiteralDuplication:
active: true active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
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"
thresholdInFiles: 11 thresholdInFiles: 11
thresholdInClasses: 11 thresholdInClasses: 11
thresholdInInterfaces: 11 thresholdInInterfaces: 11
...@@ -49,6 +52,7 @@ complexity: ...@@ -49,6 +52,7 @@ complexity:
thresholdInEnums: 11 thresholdInEnums: 11
ignoreDeprecated: true ignoreDeprecated: true
ignorePrivate: false ignorePrivate: false
ignoreOverridden: true
empty-blocks: empty-blocks:
active: true active: true
...@@ -69,7 +73,7 @@ empty-blocks: ...@@ -69,7 +73,7 @@ empty-blocks:
active: true active: true
EmptyFunctionBlock: EmptyFunctionBlock:
active: true active: true
ignoreOverriddenFunctions: false ignoreOverriddenFunctions: true
EmptyIfBlock: EmptyIfBlock:
active: true active: true
EmptyInitBlock: EmptyInitBlock:
...@@ -90,6 +94,7 @@ exceptions: ...@@ -90,6 +94,7 @@ exceptions:
methodNames: 'toString,hashCode,equals,finalize' methodNames: 'toString,hashCode,equals,finalize'
InstanceOfCheckForException: InstanceOfCheckForException:
active: true active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
NotImplementedDeclaration: NotImplementedDeclaration:
active: true active: true
PrintStackTrace: PrintStackTrace:
...@@ -100,6 +105,8 @@ exceptions: ...@@ -100,6 +105,8 @@ exceptions:
active: true active: true
SwallowedException: SwallowedException:
active: true active: true
ignoredExceptionTypes: 'InterruptedException,NumberFormatException,ParseException,MalformedURLException'
allowedExceptionNameRegex: "^(_|(ignore|expected).*)"
ThrowingExceptionFromFinally: ThrowingExceptionFromFinally:
active: false active: false
ThrowingExceptionInMain: ThrowingExceptionInMain:
...@@ -111,6 +118,7 @@ exceptions: ...@@ -111,6 +118,7 @@ exceptions:
active: true active: true
TooGenericExceptionCaught: TooGenericExceptionCaught:
active: true active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
exceptionNames: exceptionNames:
- ArrayIndexOutOfBoundsException - ArrayIndexOutOfBoundsException
- Error - Error
...@@ -133,6 +141,9 @@ formatting: ...@@ -133,6 +141,9 @@ formatting:
active: true active: true
android: true android: true
autoCorrect: true autoCorrect: true
AnnotationOnSeparateLine:
active: true
autoCorrect: true
ChainWrapping: ChainWrapping:
active: true active: true
autoCorrect: true autoCorrect: true
...@@ -155,6 +166,9 @@ formatting: ...@@ -155,6 +166,9 @@ formatting:
ModifierOrdering: ModifierOrdering:
active: true active: true
autoCorrect: true autoCorrect: true
MultiLineIfElse:
active: true
autoCorrect: true
NoBlankLineBeforeRbrace: NoBlankLineBeforeRbrace:
active: true active: true
autoCorrect: true autoCorrect: true
...@@ -164,8 +178,6 @@ formatting: ...@@ -164,8 +178,6 @@ formatting:
NoEmptyClassBody: NoEmptyClassBody:
active: true active: true
autoCorrect: true autoCorrect: true
NoItParamInMultilineLambda:
active: false
NoLineBreakAfterElse: NoLineBreakAfterElse:
active: true active: true
autoCorrect: true autoCorrect: true
...@@ -188,6 +200,9 @@ formatting: ...@@ -188,6 +200,9 @@ formatting:
autoCorrect: true autoCorrect: true
NoWildcardImports: NoWildcardImports:
active: false active: false
PackageName:
active: true
autoCorrect: true
ParameterListWrapping: ParameterListWrapping:
active: false active: false
SpacingAroundColon: SpacingAroundColon:
...@@ -199,12 +214,18 @@ formatting: ...@@ -199,12 +214,18 @@ formatting:
SpacingAroundCurly: SpacingAroundCurly:
active: true active: true
autoCorrect: true autoCorrect: true
SpacingAroundDot:
active: true
autoCorrect: true
SpacingAroundKeyword: SpacingAroundKeyword:
active: true active: true
autoCorrect: true autoCorrect: true
SpacingAroundOperators: SpacingAroundOperators:
active: true active: true
autoCorrect: true autoCorrect: true
SpacingAroundParens:
active: true
autoCorrect: true
SpacingAroundRangeOperator: SpacingAroundRangeOperator:
active: true active: true
autoCorrect: true autoCorrect: true
...@@ -217,56 +238,73 @@ naming: ...@@ -217,56 +238,73 @@ naming:
ClassNaming: ClassNaming:
active: true active: true
classPattern: '[A-Z$][a-zA-Z0-9$]*' classPattern: '[A-Z$][a-zA-Z0-9$]*'
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
ConstructorParameterNaming: ConstructorParameterNaming:
active: true active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
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: '$^'
EnumNaming: EnumNaming:
active: true active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
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"
forbiddenName: '' forbiddenName: ''
FunctionMaxLength: FunctionMaxLength:
active: true active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
maximumFunctionNameLength: 30 maximumFunctionNameLength: 30
FunctionMinLength: FunctionMinLength:
active: true active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
minimumFunctionNameLength: 3 minimumFunctionNameLength: 3
FunctionNaming: FunctionNaming:
active: true active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$' functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
excludeClassPattern: '$^' excludeClassPattern: '$^'
ignoreOverridden: true ignoreOverridden: true
FunctionParameterNaming: FunctionParameterNaming:
active: true active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
parameterPattern: '[a-z][A-Za-z0-9]*' parameterPattern: '[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^' excludeClassPattern: '$^'
ignoreOverriddenFunctions: true
InvalidPackageDeclaration:
active: true
rootPackage: ''
MatchingDeclarationName: MatchingDeclarationName:
active: true active: true
MemberNameEqualsClassName: MemberNameEqualsClassName:
active: false active: false
ObjectPropertyNaming: ObjectPropertyNaming:
active: true active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
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
packagePattern: '^[a-z]+(\.[a-z][a-z0-9]*)*$' excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
packagePattern: '^[a-z]+(\.[a-z][A-Za-z0-9]*)*$'
TopLevelPropertyNaming: TopLevelPropertyNaming:
active: true active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
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"
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"
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: '$^'
...@@ -274,10 +312,14 @@ naming: ...@@ -274,10 +312,14 @@ naming:
performance: performance:
active: true active: true
ArrayPrimitive:
active: true
ForEachOnRange: ForEachOnRange:
active: true active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
SpreadOperator: SpreadOperator:
active: true active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
UnnecessaryTemporaryInstantiation: UnnecessaryTemporaryInstantiation:
active: true active: true
...@@ -299,6 +341,10 @@ potential-bugs: ...@@ -299,6 +341,10 @@ potential-bugs:
active: true active: true
LateinitUsage: LateinitUsage:
active: false active: false
MissingWhenCase:
active: false
RedundantElseInWhen:
active: true
UnconditionalJumpStatementInLoop: UnconditionalJumpStatementInLoop:
active: true active: true
UnreachableCode: UnreachableCode:
...@@ -318,8 +364,14 @@ style: ...@@ -318,8 +364,14 @@ style:
active: true active: true
DataClassContainsFunctions: DataClassContainsFunctions:
active: false active: false
DataClassShouldBeImmutable:
active: false
EqualsNullCall: EqualsNullCall:
active: true active: true
EqualsOnSignatureLine:
active: true
ExplicitItLambdaParameter:
active: true
ExpressionBodySyntax: ExpressionBodySyntax:
active: true active: true
includeLineWrapping: false includeLineWrapping: false
...@@ -331,10 +383,14 @@ style: ...@@ -331,10 +383,14 @@ style:
imports: '' imports: ''
ForbiddenVoid: ForbiddenVoid:
active: true active: true
ignoreOverridden: true
ignoreUsageInGenerics: false
FunctionOnlyReturningConstant: FunctionOnlyReturningConstant:
active: true active: true
ignoreOverridableFunction: true ignoreOverridableFunction: true
excludedFunctions: 'describeContents' excludedFunctions: 'describeContents'
LibraryCodeMustSpecifyReturnType:
active: true
LoopWithTooManyJumpStatements: LoopWithTooManyJumpStatements:
active: true active: true
maxJumpCount: 1 maxJumpCount: 1
...@@ -383,9 +439,13 @@ style: ...@@ -383,9 +439,13 @@ style:
max: 2 max: 2
TrailingWhitespace: TrailingWhitespace:
active: true active: true
UnderscoresInNumericLiterals:
active: false
UnnecessaryAbstractClass: UnnecessaryAbstractClass:
active: true active: true
excludeAnnotatedClasses: "dagger.Module" excludeAnnotatedClasses: "dagger.Module"
UnnecessaryApply:
active: true
UnnecessaryInheritance: UnnecessaryInheritance:
active: true active: true
UnnecessaryLet: UnnecessaryLet:
...@@ -396,14 +456,22 @@ style: ...@@ -396,14 +456,22 @@ style:
active: true active: true
UnusedImports: UnusedImports:
active: true active: true
UnusedPrivateClass:
active: true
UnusedPrivateMember: UnusedPrivateMember:
active: true active: true
allowedNames: "(_|ignored|expected|serialVersionUID)" allowedNames: "(_|ignored|expected|serialVersionUID)"
UseCheckOrError:
active: true
UseDataClass: UseDataClass:
active: false active: false
UseRequire:
active: true
UselessCallOnNotNull:
active: true
UtilityClassWithPublicConstructor: UtilityClassWithPublicConstructor:
active: true active: true
VarCouldBeVal: VarCouldBeVal:
active: false active: true
WildcardImport: WildcardImport:
active: false active: false
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
...@@ -125,8 +125,8 @@ if $darwin; then ...@@ -125,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi fi
# For Cygwin, switch paths to Windows format before running java # For Cygwin or MSYS, switch paths to Windows format before running java
if $cygwin ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`
......
...@@ -60,11 +60,11 @@ androidExtensions { ...@@ -60,11 +60,11 @@ androidExtensions {
dependencies { dependencies {
implementation project(':core') implementation project(':core')
implementation 'androidx.browser:browser:1.2.0-alpha07' implementation 'androidx.browser:browser:1.2.0-alpha08'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2' implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion"
implementation 'com.google.android.gms:play-services-vision:18.0.0' implementation 'com.google.android.gms:play-services-vision:18.0.0'
implementation 'com.google.firebase:firebase-ads:18.1.1' implementation 'com.google.firebase:firebase-ads:18.2.0'
implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.0.0' implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.0.0'
implementation 'com.twofortyfouram:android-plugin-api-for-locale:1.0.4' implementation 'com.twofortyfouram:android-plugin-api-for-locale:1.0.4'
implementation 'net.glxn.qrgen:android:2.0' implementation 'net.glxn.qrgen:android:2.0'
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
package com.github.shadowsocks.acl package com.github.shadowsocks.acl
import android.annotation.SuppressLint
import android.content.ClipData import android.content.ClipData
import android.content.ClipboardManager import android.content.ClipboardManager
import android.content.DialogInterface import android.content.DialogInterface
...@@ -102,6 +103,7 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener, ...@@ -102,6 +103,7 @@ class CustomRulesFragment : ToolbarFragment(), Toolbar.OnMenuItemClickListener,
override fun AlertDialog.Builder.prepare(listener: DialogInterface.OnClickListener) { override fun AlertDialog.Builder.prepare(listener: DialogInterface.OnClickListener) {
val activity = requireActivity() val activity = requireActivity()
@SuppressLint("InflateParams")
val view = activity.layoutInflater.inflate(R.layout.dialog_acl_rule, null) val view = activity.layoutInflater.inflate(R.layout.dialog_acl_rule, null)
templateSelector = view.findViewById(R.id.template_selector) templateSelector = view.findViewById(R.id.template_selector)
editText = view.findViewById(R.id.content) editText = view.findViewById(R.id.content)
......
...@@ -68,7 +68,7 @@ class TileService : BaseTileService(), ShadowsocksConnection.Callback { ...@@ -68,7 +68,7 @@ class TileService : BaseTileService(), ShadowsocksConnection.Callback {
qsTile?.apply { qsTile?.apply {
label = null label = null
when (serviceState) { when (serviceState) {
BaseService.State.Idle -> throw IllegalStateException("serviceState") BaseService.State.Idle -> error("serviceState")
BaseService.State.Connecting -> { BaseService.State.Connecting -> {
icon = iconBusy icon = iconBusy
state = Tile.STATE_ACTIVE state = Tile.STATE_ACTIVE
......
...@@ -55,9 +55,9 @@ mavenPublish { ...@@ -55,9 +55,9 @@ mavenPublish {
} }
dependencies { dependencies {
api 'androidx.core:core-ktx:1.1.0-rc03' api 'androidx.core:core-ktx:1.1.0'
api 'androidx.drawerlayout:drawerlayout:1.1.0-alpha03' // https://android-developers.googleblog.com/2019/07/android-q-beta-5-update.html api 'androidx.drawerlayout:drawerlayout:1.1.0-alpha03' // https://android-developers.googleblog.com/2019/07/android-q-beta-5-update.html
api 'com.google.android.material:material:1.1.0-alpha09' api 'com.google.android.material:material:1.1.0-alpha10'
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion"
testImplementation "junit:junit:$junitVersion" testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test:runner:$androidTestVersion" androidTestImplementation "androidx.test:runner:$androidTestVersion"
......
...@@ -74,9 +74,7 @@ class PluginOptions : HashMap<String, String?> { ...@@ -74,9 +74,7 @@ class PluginOptions : HashMap<String, String?> {
fun putWithDefault(key: String, value: String?, default: String? = null) = fun putWithDefault(key: String, value: String?, default: String? = null) =
if (value == null || value == default) remove(key) else put(key, value) if (value == null || value == default) remove(key) else put(key, value)
private fun append(result: StringBuilder, str: String) = (0 until str.length) private fun append(result: StringBuilder, str: String) = str.indices.map { str[it] }.forEach {
.map { str[it] }
.forEach {
when (it) { when (it) {
'\\', '=', ';' -> { '\\', '=', ';' -> {
result.append('\\') // intentionally no break result.append('\\') // intentionally no break
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment