Skip to content

Commit

Permalink
User properties / systemProp.* support
Browse files Browse the repository at this point in the history
  • Loading branch information
Krystian Panek committed Feb 28, 2020
1 parent 4e47297 commit b7e9ac3
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 49 deletions.
121 changes: 87 additions & 34 deletions detekt.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
build:
maxIssues: 0
excludeCorrectable: false
weights:
# complexity: 2
# LongParameterList: 1
# style: 1
# comments: 1

config:
validation: true
# when writing own rules with new properties, exclude the property path e.g.: "my_rule_set,.*>.*>[my_property]"
excludes: ""

processors:
active: true
exclude:
# - 'DetektProgressListener'
- 'DetektProgressListener'
# - 'FunctionCountProcessor'
# - 'PropertyCountProcessor'
# - 'ClassCountProcessor'
Expand All @@ -19,11 +25,11 @@ processors:
console-reports:
active: true
exclude:
# - 'ProjectStatisticsReport'
# - 'ComplexityReport'
# - 'NotificationReport'
# - 'FindingsReport'
# - 'BuildFailureReport'
- 'ProjectStatisticsReport'
- 'ComplexityReport'
- 'NotificationReport'
# - 'FindingsReport'
- 'FileBasedFindingsReport'

comments:
active: true
Expand All @@ -43,6 +49,8 @@ comments:
searchInInnerInterface: true
UndocumentedPublicFunction:
active: false
UndocumentedPublicProperty:
active: false

complexity:
active: true
Expand All @@ -55,9 +63,11 @@ complexity:
includeStaticDeclarations: false
ComplexMethod:
active: true
threshold: 10
threshold: 15
ignoreSingleWhenExpression: false
ignoreSimpleWhenEntries: false
ignoreNestingFunctions: false
nestingFunctions: run,let,apply,with,also,use,forEach,isNotNull,ifNull
LabeledExpression:
active: false
ignoredLabels: ""
Expand Down Expand Up @@ -96,6 +106,13 @@ complexity:
ignorePrivate: false
ignoreOverridden: false

coroutines:
active: true
GlobalCoroutineUsage:
active: false
RedundantSuspendModifier:
active: false

empty-blocks:
active: true
EmptyCatchBlock:
Expand All @@ -115,7 +132,7 @@ empty-blocks:
active: true
EmptyFunctionBlock:
active: true
ignoreOverriddenFunctions: false
ignoreOverridden: false
EmptyIfBlock:
active: true
EmptyInitBlock:
Expand All @@ -124,6 +141,8 @@ empty-blocks:
active: true
EmptySecondaryConstructor:
active: true
EmptyTryBlock:
active: true
EmptyWhenBlock:
active: true
EmptyWhileBlock:
Expand All @@ -145,6 +164,7 @@ exceptions:
active: false
ReturnFromFinally:
active: false
ignoreLabeled: false
SwallowedException:
active: false
ignoredExceptionTypes: 'InterruptedException,NumberFormatException,ParseException,MalformedURLException'
Expand Down Expand Up @@ -192,11 +212,15 @@ formatting:
CommentSpacing:
active: true
autoCorrect: true
EnumEntryNameCase:
active: false
autoCorrect: true
Filename:
active: true
FinalNewline:
active: true
autoCorrect: true
insertFinalNewLine: true
ImportOrdering:
active: false
autoCorrect: true
Expand All @@ -223,6 +247,9 @@ formatting:
NoEmptyClassBody:
active: true
autoCorrect: true
NoEmptyFirstLineInMethodBlock:
active: false
autoCorrect: true
NoLineBreakAfterElse:
active: true
autoCorrect: true
Expand Down Expand Up @@ -293,6 +320,7 @@ naming:
parameterPattern: '[a-z][A-Za-z0-9]*'
privateParameterPattern: '[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^'
ignoreOverridden: true
EnumNaming:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
Expand Down Expand Up @@ -320,15 +348,16 @@ naming:
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
parameterPattern: '[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^'
ignoreOverriddenFunctions: true
ignoreOverridden: true
InvalidPackageDeclaration:
active: false
rootPackage: ''
MatchingDeclarationName:
active: true
mustBeFirst: true
MemberNameEqualsClassName:
active: false
ignoreOverriddenFunction: true
active: true
ignoreOverridden: true
ObjectPropertyNaming:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
Expand Down Expand Up @@ -364,7 +393,7 @@ naming:
performance:
active: true
ArrayPrimitive:
active: false
active: true
ForEachOnRange:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
Expand All @@ -376,41 +405,49 @@ performance:

potential-bugs:
active: true
Deprecation:
active: false
DuplicateCaseInWhenExpression:
active: true
EqualsAlwaysReturnsTrueOrFalse:
active: false
active: true
EqualsWithHashCodeExist:
active: true
ExplicitGarbageCollectionCall:
active: true
InvalidRange:
HasPlatformType:
active: false
IteratorHasNextCallsNextMethod:
ImplicitDefaultLocale:
active: false
InvalidRange:
active: true
IteratorHasNextCallsNextMethod:
active: true
IteratorNotThrowingNoSuchElementException:
active: false
active: true
LateinitUsage:
active: false
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludeAnnotatedProperties: ""
ignoreOnClassesPattern: ""
MissingWhenCase:
MapGetWithNotNullAssertionOperator:
active: false
MissingWhenCase:
active: true
RedundantElseInWhen:
active: false
active: true
UnconditionalJumpStatementInLoop:
active: false
UnreachableCode:
active: true
UnsafeCallOnNullableType:
active: false
active: true
UnsafeCast:
active: false
UselessPostfixExpression:
active: false
WrongEqualsTypeParameter:
active: false
active: true

style:
active: true
Expand All @@ -422,9 +459,11 @@ style:
DataClassShouldBeImmutable:
active: false
EqualsNullCall:
active: false
active: true
EqualsOnSignatureLine:
active: false
ExplicitCollectionElementAccessMethod:
active: false
ExplicitItLambdaParameter:
active: false
ExpressionBodySyntax:
Expand All @@ -437,25 +476,34 @@ style:
ForbiddenImport:
active: false
imports: ''
forbiddenPatterns: ""
ForbiddenMethodCall:
active: false
methods: ''
ForbiddenPublicDataClass:
active: false
ignorePackages: '*.internal,*.internal.*'
ForbiddenVoid:
active: false
ignoreOverridden: false
ignoreUsageInGenerics: false
FunctionOnlyReturningConstant:
active: false
active: true
ignoreOverridableFunction: true
excludedFunctions: 'describeContents'
excludeAnnotatedFunction: "dagger.Provides"
LibraryCodeMustSpecifyReturnType:
active: false
active: true
LoopWithTooManyJumpStatements:
active: false
active: true
maxJumpCount: 1
MagicNumber:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
ignoreNumbers: '-1,0,1,2'
ignoreHashCodeFunction: true
ignorePropertyDeclaration: true
ignorePropertyDeclaration: false
ignoreLocalVariableDeclaration: false
ignoreConstantDeclaration: true
ignoreCompanionObjectPropertyDeclaration: true
ignoreAnnotation: false
Expand All @@ -471,7 +519,7 @@ style:
excludeImportStatements: true
excludeCommentStatements: false
MayBeConst:
active: false
active: true
ModifierOrder:
active: true
NestedClassesVisibility:
Expand All @@ -489,13 +537,13 @@ style:
PreferToOverPairSyntax:
active: false
ProtectedMemberInFinalClass:
active: false
active: true
RedundantExplicitType:
active: false
RedundantVisibilityModifierRule:
active: false
ReturnCount:
active: false
active: true
max: 2
excludedFunctions: "equals"
excludeLabeled: false
Expand All @@ -508,20 +556,22 @@ style:
SpacingBetweenPackageAndImports:
active: false
ThrowsCount:
active: false
active: true
max: 2
TrailingWhitespace:
active: false
UnderscoresInNumericLiterals:
active: false
acceptableDecimalLength: 5
UnnecessaryAbstractClass:
active: false
active: true
excludeAnnotatedClasses: "dagger.Module"
UnnecessaryAnnotationUseSiteTarget:
active: false
UnnecessaryApply:
active: false
UnnecessaryInheritance:
active: false
active: true
UnnecessaryLet:
active: false
UnnecessaryParentheses:
Expand All @@ -531,23 +581,26 @@ style:
UnusedImports:
active: false
UnusedPrivateClass:
active: false
active: true
UnusedPrivateMember:
active: false
allowedNames: "(_|ignored|expected|serialVersionUID)"
UseArrayLiteralsInAnnotations:
active: false
UseCheckOrError:
active: false
UseDataClass:
active: false
excludeAnnotatedClasses: ""
allowVars: false
UseIfInsteadOfWhen:
active: false
UseRequire:
active: false
UselessCallOnNotNull:
active: false
active: true
UtilityClassWithPublicConstructor:
active: false
active: true
VarCouldBeVal:
active: false
WildcardImport:
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ release.useAutomaticVersion=true

kotlin.version=1.3.61
dokka.version=0.9.18
detekt.version=1.0.1
detekt.version=1.6.0
10 changes: 8 additions & 2 deletions src/main/kotlin/com/neva/gradle/fork/ForkExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,14 @@ open class ForkExtension(val project: Project, val props: PropsExtension) {

Properties().apply {
load(file.bufferedReader())
}.forEach { name, value ->
project.extensions.extraProperties.set(name.toString(), props.encryptor.decrypt(value as String?))
}.forEach { n, v ->
val name = n.toString()
val value = props.encryptor.decrypt(v as String)!!

when {
name.startsWith("systemProp.") -> System.setProperty(name, value)
else -> project.extensions.extraProperties.set(name, value)
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/main/kotlin/com/neva/gradle/fork/config/AbstractRule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ abstract class AbstractRule(val config: Config) : Rule {
// nothing to do
}

fun visitTree(tree: FileTree, condition: (FileVisitDetails) -> Boolean, callback: (FileHandler, FileVisitDetails) -> Unit) {
fun visitTree(
tree: FileTree,
condition: (FileVisitDetails) -> Boolean,
callback: (FileHandler, FileVisitDetails) -> Unit
) {
val actions = mutableListOf<() -> Unit>()
tree.visitAll { fileDetail ->
if (condition(fileDetail)) {
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/com/neva/gradle/fork/config/FileHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class FileHandler(val config: Config, val file: File) {
return move(File(targetPath))
}

@Suppress("ReturnCount")
fun move(target: File): FileHandler {
actions += action@{
if (!file.exists()) {
Expand Down
Loading

0 comments on commit b7e9ac3

Please sign in to comment.