Skip to content

Commit

Permalink
Fix java.lang.ClassCastException is reading default yaml config (#3920)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicola Corti <corti.nico@gmail.com>
  • Loading branch information
chao2zhang and cortinico committed Jul 2, 2021
1 parent f6d75dd commit 5048b8b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 55 deletions.
90 changes: 45 additions & 45 deletions detekt-core/src/main/resources/default-detekt-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ complexity:
ignoreSimpleWhenEntries: false
ignoreNestingFunctions: false
nestingFunctions:
- run
- let
- apply
- with
- also
- use
- forEach
- isNotNull
- ifNull
- 'run'
- 'let'
- 'apply'
- 'with'
- 'also'
- 'use'
- 'forEach'
- 'isNotNull'
- 'ifNull'
LabeledExpression:
active: false
ignoredLabels: []
Expand Down Expand Up @@ -199,10 +199,10 @@ exceptions:
ExceptionRaisedInUnexpectedLocation:
active: true
methodNames:
- toString
- hashCode
- equals
- finalize
- 'toString'
- 'hashCode'
- 'equals'
- 'finalize'
InstanceOfCheckForException:
active: false
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
Expand All @@ -220,10 +220,10 @@ exceptions:
SwallowedException:
active: true
ignoredExceptionTypes:
- NumberFormatException
- InterruptedException
- ParseException
- MalformedURLException
- 'NumberFormatException'
- 'InterruptedException'
- 'ParseException'
- 'MalformedURLException'
allowedExceptionNameRegex: '_|(ignore|expected).*'
ThrowingExceptionFromFinally:
active: true
Expand All @@ -233,36 +233,36 @@ exceptions:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
exceptions:
- ArrayIndexOutOfBoundsException
- Error
- Exception
- IllegalMonitorStateException
- NullPointerException
- IndexOutOfBoundsException
- RuntimeException
- Throwable
- 'ArrayIndexOutOfBoundsException'
- 'Error'
- 'Exception'
- 'IllegalMonitorStateException'
- 'NullPointerException'
- 'IndexOutOfBoundsException'
- 'RuntimeException'
- 'Throwable'
ThrowingNewInstanceOfSameException:
active: true
TooGenericExceptionCaught:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
exceptionNames:
- ArrayIndexOutOfBoundsException
- Error
- Exception
- IllegalMonitorStateException
- NullPointerException
- IndexOutOfBoundsException
- RuntimeException
- Throwable
- 'ArrayIndexOutOfBoundsException'
- 'Error'
- 'Exception'
- 'IllegalMonitorStateException'
- 'NullPointerException'
- 'IndexOutOfBoundsException'
- 'RuntimeException'
- 'Throwable'
allowedExceptionNameRegex: '_|(ignore|expected).*'
TooGenericExceptionThrown:
active: true
exceptionNames:
- Error
- Exception
- Throwable
- RuntimeException
- 'Error'
- 'Exception'
- 'Throwable'
- 'RuntimeException'

formatting:
active: true
Expand Down Expand Up @@ -614,8 +614,8 @@ style:
ForbiddenMethodCall:
active: false
methods:
- kotlin.io.println
- kotlin.io.print
- 'kotlin.io.println'
- 'kotlin.io.print'
ForbiddenPublicDataClass:
active: true
excludes: ['**']
Expand All @@ -632,7 +632,7 @@ style:
ignoreActualFunction: true
excludedFunctions: ''
excludeAnnotatedFunction:
- dagger.Provides
- 'dagger.Provides'
LibraryCodeMustSpecifyReturnType:
active: true
excludes: ['**']
Expand All @@ -646,10 +646,10 @@ style:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
ignoreNumbers:
- -1
- 0
- 1
- 2
- '-1'
- '0'
- '1'
- '2'
ignoreHashCodeFunction: true
ignorePropertyDeclaration: false
ignoreLocalVariableDeclaration: false
Expand Down Expand Up @@ -725,7 +725,7 @@ style:
UnnecessaryAbstractClass:
active: true
excludeAnnotatedClasses:
- dagger.Module
- 'dagger.Module'
UnnecessaryAnnotationUseSiteTarget:
active: false
UnnecessaryApply:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ private fun String.quotedForList(): String {
isBlank() -> quoted()
startsWith(SINGLE_QUOTE) && endsWith(SINGLE_QUOTE)
|| startsWith(DOUBLE_QUOTE) && endsWith(DOUBLE_QUOTE) -> this
matches(NO_QUOTES_REQUIRED) -> this
else -> quoted()
}
}
Expand All @@ -78,4 +77,3 @@ private fun String.quoted() = "'$this'"
private const val SINGLE_INDENT = " "
private const val SINGLE_QUOTE = "'"
private const val DOUBLE_QUOTE = "\""
private val NO_QUOTES_REQUIRED = Regex("""[.\w\s-]+""")
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object YamlSpec : Spek({
val given = listOf("value")
val result = yaml { list("key", given) }
val expected = """key:
| - value
| - 'value'
""".trimMargin()
assertThat(result).isEqualTo(expected)
}
Expand All @@ -28,8 +28,8 @@ object YamlSpec : Spek({
val given = listOf("value 1", "value 2")
val result = yaml { list("key", given) }
val expected = """key:
| - value 1
| - value 2
| - 'value 1'
| - 'value 2'
""".trimMargin()
assertThat(result).isEqualTo(expected)
}
Expand Down
10 changes: 5 additions & 5 deletions detekt-generator/src/test/resources/RuleSetConfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ style:
active: true
rulesetconfig1: true
rulesetconfig2:
- foo
- bar
- 'foo'
- 'bar'
rulesetconfig3:
- first
- 'first'
- 'se*cond'
WildcardImport:
active: true
excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/jsTest/**', '**/iosTest/**']
conf1: foo
conf3:
- a
- b
- 'a'
- 'b'
conf5: 120
EqualsNull:
active: false
Expand Down

0 comments on commit 5048b8b

Please sign in to comment.