Commit 26acea8e authored by Mygod's avatar Mygod

Fix code style issues

parent a7d77461
# https://github.com/arturbosch/detekt/blob/801994bd60cc759b181649356cea045b8125301b/detekt-cli/src/main/resources/default-detekt-config.yml
# https://github.com/arturbosch/detekt/blob/RC6-4/detekt-cli/src/main/resources/default-detekt-config.yml
comments:
active: false
......@@ -7,7 +7,7 @@ complexity:
active: true
ComplexCondition:
active: true
threshold: 3
threshold: 4
ComplexInterface:
active: true
threshold: 10
......@@ -15,6 +15,7 @@ complexity:
ComplexMethod:
active: true
threshold: 10
ignoreSingleWhenExpression: false
LabeledExpression:
active: true
LargeClass:
......@@ -25,31 +26,32 @@ complexity:
threshold: 20
LongParameterList:
active: true
threshold: 5
threshold: 6
ignoreDefaultParameters: true
MethodOverloading:
active: false
NestedBlockDepth:
active: true
threshold: 3
threshold: 4
StringLiteralDuplication:
active: true
threshold: 2
threshold: 3
ignoreAnnotation: true
excludeStringsWithLessThan5Characters: true
ignoreStringsRegex: '$^'
TooManyFunctions:
active: true
thresholdInFiles: 10
thresholdInClasses: 10
thresholdInInterfaces: 10
thresholdInObjects: 10
thresholdInEnums: 10
thresholdInFiles: 11
thresholdInClasses: 11
thresholdInInterfaces: 11
thresholdInObjects: 11
thresholdInEnums: 11
empty-blocks:
active: true
EmptyCatchBlock:
active: false
active: true
allowedExceptionNameRegex: "^(_|ignore|expected).*"
EmptyClassBlock:
active: true
EmptyDefaultConstructor:
......@@ -64,6 +66,7 @@ empty-blocks:
active: true
EmptyFunctionBlock:
active: true
ignoreOverriddenFunctions: false
EmptyIfBlock:
active: true
EmptyInitBlock:
......@@ -105,7 +108,7 @@ exceptions:
active: true
TooGenericExceptionCaught:
active: true
exceptions:
exceptionNames:
- ArrayIndexOutOfBoundsException
- Error
- Exception
......@@ -116,10 +119,9 @@ exceptions:
- Throwable
TooGenericExceptionThrown:
active: true
exceptions:
exceptionNames:
- Error
- Exception
- NullPointerException
- Throwable
- RuntimeException
......@@ -143,6 +145,7 @@ naming:
FunctionNaming:
active: true
functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
excludeClassPattern: '$^'
MatchingDeclarationName:
active: true
MemberNameEqualsClassName:
......@@ -167,6 +170,7 @@ naming:
active: true
variablePattern: '[a-z][A-Za-z0-9]*'
privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^'
performance:
active: true
......@@ -239,15 +243,17 @@ style:
maxLineLength: 120
excludePackageStatements: false
excludeImportStatements: false
MayBeConst:
active: true
ModifierOrder:
active: true
NestedClassesVisibility:
active: true
NewLineAtEndOfFile:
active: true
OptionalAbstractKeyword:
NoTabs:
active: true
OptionalReturnKeyword:
OptionalAbstractKeyword:
active: true
OptionalUnit:
active: true
......@@ -268,6 +274,8 @@ style:
ThrowsCount:
active: true
max: 2
TrailingWhitespace:
active: true
UnnecessaryAbstractClass:
active: true
UnnecessaryInheritance:
......@@ -278,6 +286,8 @@ style:
active: true
UnusedImports:
active: true
UnusedPrivateMember:
active: true
UseDataClass:
active: false
UtilityClassWithPublicConstructor:
......
......@@ -62,8 +62,7 @@ class AppManager : AppCompatActivity(), Toolbar.OnMenuItemClickListener {
private var receiver: BroadcastReceiver? = null
private var cachedApps: List<PackageInfo>? = null
private fun getApps(pm: PackageManager): List<ProxiedApp> {
return synchronized(AppManager) {
private fun getApps(pm: PackageManager) = synchronized(AppManager) {
if (receiver == null) receiver = app.listenForPackageChanges {
synchronized(AppManager) {
receiver = null
......@@ -79,7 +78,6 @@ class AppManager : AppCompatActivity(), Toolbar.OnMenuItemClickListener {
cachedApps
}.map { ProxiedApp(pm, it.applicationInfo, it.packageName) }
}
}
private class ProxiedApp(private val pm: PackageManager, private val appInfo: ApplicationInfo,
val packageName: String) {
......
......@@ -117,7 +117,10 @@ object BaseService {
val item = callbacks.getBroadcastItem(i)
if (bandwidthListeners.contains(item.asBinder()))
item.trafficUpdated(profile!!.id, txRate, rxRate, txTotal, rxTotal)
} catch (_: Exception) { } // ignore
} catch (e: Exception) {
e.printStackTrace()
app.track(e)
}
callbacks.finishBroadcast()
}
}
......@@ -159,7 +162,10 @@ object BaseService {
try {
val item = callbacks.getBroadcastItem(i)
if (bandwidthListeners.contains(item.asBinder())) item.trafficPersisted(profile.id)
} catch (_: Exception) { } // ignore
} catch (e: Exception) {
e.printStackTrace()
app.track(e)
}
}
callbacks.finishBroadcast()
}
......@@ -211,7 +217,10 @@ object BaseService {
val n = callbacks.beginBroadcast()
for (i in 0 until n) try {
callbacks.getBroadcastItem(i).stateChanged(s, binder.profileName, msg)
} catch (_: Exception) { } // ignore
} catch (e: Exception) {
e.printStackTrace()
app.track(e)
}
callbacks.finishBroadcast()
}
state = s
......
......@@ -87,8 +87,7 @@ object PluginManager {
private var receiver: BroadcastReceiver? = null
private var cachedPlugins: Map<String, Plugin>? = null
fun fetchPlugins(): Map<String, Plugin> {
return synchronized(this) {
fun fetchPlugins(): Map<String, Plugin> = synchronized(this) {
if (receiver == null) receiver = app.listenForPackageChanges {
synchronized(this) {
receiver = null
......@@ -102,7 +101,6 @@ object PluginManager {
}
cachedPlugins!!
}
}
private fun buildUri(id: String) = Uri.Builder()
.scheme(PluginContract.SCHEME)
......
......@@ -22,7 +22,6 @@ package com.github.shadowsocks.preference
import android.os.Binder
import com.github.shadowsocks.App.Companion.app
import com.github.shadowsocks.BootReceiver
import com.github.shadowsocks.database.PrivateDatabase
import com.github.shadowsocks.database.PublicDatabase
import com.github.shadowsocks.utils.DirectBoot
......
......@@ -29,8 +29,8 @@ import com.twofortyfouram.locale.api.Intent as ApiIntent
class Settings(bundle: Bundle?) {
companion object {
private val KEY_SWITCH_ON = "switch_on"
private val KEY_PROFILE_ID = "profile_id"
private const val KEY_SWITCH_ON = "switch_on"
private const val KEY_PROFILE_ID = "profile_id"
fun fromIntent(intent: Intent) = Settings(intent.getBundleExtra(ApiIntent.EXTRA_BUNDLE))
}
......
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