Skip to content

Commit

Permalink
Merge branch 'master' into s
Browse files Browse the repository at this point in the history
  • Loading branch information
Mygod committed Jul 11, 2021
2 parents f7a2507 + ae2a9e8 commit 17aa319
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 19 deletions.
65 changes: 57 additions & 8 deletions detekt.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# https://github.com/detekt/detekt/blob/v1.14.2/detekt-core/src/main/resources/default-detekt-config.yml
# https://github.com/detekt/detekt/blob/v1.17.1/detekt-core/src/main/resources/default-detekt-config.yml

comments:
active: false
Expand Down Expand Up @@ -36,6 +36,8 @@ complexity:
ignoreAnnotated: []
MethodOverloading:
active: false
NamedArguments:
active: false
NestedBlockDepth:
active: true
threshold: 4
Expand Down Expand Up @@ -66,6 +68,8 @@ coroutines:
active: false
RedundantSuspendModifier:
active: true
SleepInsteadOfDelay:
active: true
SuspendFunWithFlowReturnType:
active: true

Expand Down Expand Up @@ -113,8 +117,10 @@ exceptions:
active: false
NotImplementedDeclaration:
active: true
ObjectExtendsThrowable:
active: true
PrintStackTrace:
active: false
active: true
RethrowCaughtException:
active: false
ReturnFromFinally:
Expand Down Expand Up @@ -179,11 +185,13 @@ formatting:
ImportOrdering:
active: true
autoCorrect: true
layout: 'idea'
layout: '*,java.**,javax.**,kotlin.**,^'
Indentation:
active: false
MaximumLineLength:
active: false
active: true
maxLineLength: 120
ignoreBackTickedIdentifier: false
ModifierOrdering:
active: true
autoCorrect: true
Expand Down Expand Up @@ -229,6 +237,9 @@ formatting:
autoCorrect: true
ParameterListWrapping:
active: false
SpacingAroundAngleBrackets:
active: true
autoCorrect: true
SpacingAroundColon:
active: true
autoCorrect: true
Expand Down Expand Up @@ -256,6 +267,9 @@ formatting:
SpacingAroundRangeOperator:
active: true
autoCorrect: true
SpacingAroundUnaryOperator:
active: true
autoCorrect: true
SpacingBetweenDeclarationsWithAnnotations:
active: false
SpacingBetweenDeclarationsWithComments:
Expand Down Expand Up @@ -306,12 +320,15 @@ naming:
ignoreOverridden: true
InvalidPackageDeclaration:
active: true
excludes: ['buildSrc/**', '**/*.kts']
rootPackage: ''
MatchingDeclarationName:
active: true
mustBeFirst: true
MemberNameEqualsClassName:
active: false
NoNameShadowing:
active: true
NonBooleanPropertyPrefixedWithIs:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
Expand All @@ -327,7 +344,7 @@ naming:
packagePattern: '[a-z]+(\.[a-z][A-Za-z0-9]*)*'
TopLevelPropertyNaming:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
excludes: ['buildSrc/**', '**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
constantPattern: '[A-Z][_A-Z0-9]*'
propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*'
Expand Down Expand Up @@ -359,14 +376,22 @@ performance:

potential-bugs:
active: true
CastToNullableType:
active: false
Deprecation:
active: true
DontDowncastCollectionTypes:
active: true
DoubleMutabilityForCollection:
active: true
DuplicateCaseInWhenExpression:
active: true
EqualsAlwaysReturnsTrueOrFalse:
active: true
EqualsWithHashCodeExist:
active: true
ExitOutsideMain:
active: true
ExplicitGarbageCollectionCall:
active: true
HasPlatformType:
Expand Down Expand Up @@ -398,15 +423,19 @@ potential-bugs:
UnconditionalJumpStatementInLoop:
active: true
UnnecessaryNotNullOperator:
active: false
active: true
UnnecessarySafeCall:
active: false
active: true
UnreachableCatchBlock:
active: true
UnreachableCode:
active: true
UnsafeCallOnNullableType:
active: true
UnsafeCast:
active: false
active: true
UnusedUnaryOperator:
active: true
UselessPostfixExpression:
active: true
WrongEqualsTypeParameter:
Expand All @@ -422,6 +451,8 @@ style:
active: false
DataClassShouldBeImmutable:
active: false
DestructuringDeclarationWithTooManyEntries:
active: false
EqualsNullCall:
active: true
EqualsOnSignatureLine:
Expand All @@ -446,6 +477,7 @@ style:
methods: ['kotlin.io.println', 'kotlin.io.print']
ForbiddenPublicDataClass:
active: true
excludes: ['**']
ignorePackages: ['*.internal', '*.internal.*']
ForbiddenVoid:
active: true
Expand All @@ -454,12 +486,15 @@ style:
FunctionOnlyReturningConstant:
active: true
ignoreOverridableFunction: true
ignoreActualFunction: true
excludedFunctions: 'describeContents'
excludeAnnotatedFunction: ['dagger.Provides']
LibraryCodeMustSpecifyReturnType:
active: true
excludes: ['**']
LibraryEntitiesShouldNotBePublic:
active: true
excludes: ['**']
LoopWithTooManyJumpStatements:
active: true
maxJumpCount: 1
Expand All @@ -479,12 +514,16 @@ style:
active: true
ModifierOrder:
active: true
MultilineLambdaItParameter:
active: false
NestedClassesVisibility:
active: true
NewLineAtEndOfFile:
active: true
NoTabs:
active: true
ObjectLiteralToLambda:
active: true
OptionalAbstractKeyword:
active: true
OptionalUnit:
Expand All @@ -497,6 +536,8 @@ style:
active: true
RedundantExplicitType:
active: true
RedundantHigherOrderMapUsage:
active: true
RedundantVisibilityModifierRule:
active: true
ReturnCount:
Expand All @@ -520,6 +561,8 @@ style:
active: true
UnnecessaryApply:
active: true
UnnecessaryFilter:
active: true
UnnecessaryInheritance:
active: true
UnnecessaryLet:
Expand All @@ -545,8 +588,14 @@ style:
active: false
UseEmptyCounterpart:
active: true
UseIfEmptyOrIfBlank:
active: true
UseIfInsteadOfWhen:
active: false
UseIsNullOrEmpty:
active: true
UseOrEmpty:
active: true
UseRequire:
active: true
UseRequireNotNull:
Expand Down
18 changes: 8 additions & 10 deletions mobile/src/main/java/be/mygod/vpnhotspot/net/MacAddressCompat.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,19 @@ value class MacAddressCompat(val addr: Long) {
* @return the MacAddress corresponding to the given byte array representation.
* @throws IllegalArgumentException if the given byte array is not a valid representation.
*/
fun fromBytes(addr: ByteArray) = ByteBuffer.allocate(Long.SIZE_BYTES).run {
order(ByteOrder.LITTLE_ENDIAN)
put(when (addr.size) {
ETHER_ADDR_LEN -> addr
fun fromBytes(addr: ByteArray): MacAddressCompat {
val buffer = when (addr.size) {
ETHER_ADDR_LEN -> ByteBuffer.allocate(Long.SIZE_BYTES).order(ByteOrder.LITTLE_ENDIAN).put(addr)
8 -> {
require(addr.take(2).all { it == 0.toByte() }) {
"Unrecognized padding " + addr.joinToString(":") { "%02x".format(it) }
}
addr.drop(2).toByteArray()
ByteBuffer.allocate(Long.SIZE_BYTES).order(ByteOrder.LITTLE_ENDIAN).put(addr, 2, ETHER_ADDR_LEN)
}
else -> throw IllegalArgumentException(addr.joinToString(":") { "%02x".format(it) } +
" was not a valid MAC address")
})
rewind()
MacAddressCompat(long)
else -> return fromString(String(addr))
}
buffer.rewind()
return MacAddressCompat(buffer.long)
}
/**
* Creates a MacAddress from the given String representation. A valid String representation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ object DefaultNetworkMonitor : UpstreamMonitor() {
}
else -> try {
Services.connectivity.requestNetwork(networkRequest, networkCallback)
} catch (e: SecurityException) {
} catch (e: RuntimeException) {
// SecurityException would be thrown in requestNetwork on Android 6.0 thanks to Google's stupid bug
if (Build.VERSION.SDK_INT != 23) throw e
GlobalScope.launch { callback.onFallback() }
Expand Down

0 comments on commit 17aa319

Please sign in to comment.