Skip to content

Commit 45bc0f4

Browse files
authored
Turn on more detekt rules (#3272)
1 parent e189118 commit 45bc0f4

File tree

51 files changed

+592
-214
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+592
-214
lines changed

buildSrc/src/main/kotlin/toolkit-detekt.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies {
1717
detekt {
1818
val rulesProject = project(":detekt-rules").projectDir
1919
source.setFrom("$projectDir")
20-
buildUponDefaultConfig = false
20+
buildUponDefaultConfig = true
2121
parallel = true
2222
allRules = false
2323
config = files("$rulesProject/detekt.yml")

core/detekt-baseline-main.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<?xml version='1.0' encoding='UTF-8'?>
22
<SmellBaseline>
33
<ManuallySuppressedIssues/>
4-
<CurrentIssues/>
4+
<CurrentIssues>
5+
<ID>UseCheckOrError:LambdaRuntime.kt$LambdaRuntime$throw IllegalStateException("LambdaRuntime has no runtime or override string")</ID>
6+
<ID>UseCheckOrError:ToolkitRegionProvider.kt$ToolkitRegionProvider$throw IllegalStateException("$serviceId in ${region.partitionId} lacks a partitionEndpoint")</ID>
7+
<ID>UseCheckOrError:ToolkitRegionProvider.kt$ToolkitRegionProvider$throw IllegalStateException("$serviceId is not global in ${region.partitionId}")</ID>
8+
<ID>UseCheckOrError:ToolkitRegionProvider.kt$ToolkitRegionProvider$throw IllegalStateException("Partition data is missing for ${region.partitionId}")</ID>
9+
<ID>UseCheckOrError:ToolkitRegionProvider.kt$ToolkitRegionProvider$throw IllegalStateException("Unknown service $serviceId in ${region.partitionId}")</ID>
10+
</CurrentIssues>
511
</SmellBaseline>

core/detekt-baseline.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
<?xml version="1.0" ?>
1+
<?xml version='1.0' encoding='UTF-8'?>
22
<SmellBaseline>
3-
<ManuallySuppressedIssues></ManuallySuppressedIssues>
3+
<ManuallySuppressedIssues/>
44
<CurrentIssues>
5-
<ID>AbsentOrWrongFileLicense:ExceptionUtils.kt$software.aws.toolkits.core.utils.ExceptionUtils.kt</ID>
5+
<ID>UseCheckOrError:LambdaRuntime.kt$LambdaRuntime$throw IllegalStateException("LambdaRuntime has no runtime or override string")</ID>
6+
<ID>UseCheckOrError:ToolkitRegionProvider.kt$ToolkitRegionProvider$throw IllegalStateException("$serviceId in ${region.partitionId} lacks a partitionEndpoint")</ID>
7+
<ID>UseCheckOrError:ToolkitRegionProvider.kt$ToolkitRegionProvider$throw IllegalStateException("$serviceId is not global in ${region.partitionId}")</ID>
8+
<ID>UseCheckOrError:ToolkitRegionProvider.kt$ToolkitRegionProvider$throw IllegalStateException("Partition data is missing for ${region.partitionId}")</ID>
9+
<ID>UseCheckOrError:ToolkitRegionProvider.kt$ToolkitRegionProvider$throw IllegalStateException("Unknown service $serviceId in ${region.partitionId}")</ID>
610
</CurrentIssues>
711
</SmellBaseline>

core/tst/software/aws/toolkits/core/utils/LogUtilsTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,6 @@ class LogUtilsTest {
175175
"hello"
176176
}
177177

178+
@Suppress("FunctionOnlyReturningConstant")
178179
private fun willNeverBeNull(): String = "hello"
179180
}

detekt-rules/detekt.yml

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ comments:
2727
licenseTemplateFile: ./license.template
2828
licenseTemplateIsRegex: true
2929

30+
complexity:
31+
active: false
32+
3033
coroutines:
3134
active: true
3235
GlobalCoroutineUsage:
@@ -38,6 +41,14 @@ coroutines:
3841
SuspendFunWithFlowReturnType:
3942
active: true
4043

44+
empty-blocks:
45+
EmptyFunctionBlock:
46+
active: false
47+
48+
exceptions:
49+
# there might actually be some useful rules in here
50+
active: false
51+
4152
# unfortunately, does not respect .editorconfig in the project folder
4253
# also needs to be manually updated if there are new rules upstream
4354
formatting:
@@ -201,6 +212,11 @@ naming:
201212
parameterPattern: '[a-z][A-Za-z0-9]*'
202213
excludeClassPattern: '$^'
203214
ignoreOverridden: true
215+
# prefer rule provided by ktlint
216+
MatchingDeclarationName:
217+
active: false
218+
MemberNameEqualsClassName:
219+
active: false
204220
NoNameShadowing:
205221
active: true
206222
ObjectPropertyNaming:
@@ -223,6 +239,10 @@ naming:
223239
excludeClassPattern: '$^'
224240
ignoreOverridden: true
225241

242+
performance:
243+
SpreadOperator:
244+
active: false
245+
226246
potential-bugs:
227247
active: true
228248
CastToNullableType:
@@ -287,22 +307,25 @@ potential-bugs:
287307
active: true
288308

289309
style:
290-
EqualsNullCall:
291-
active: true
292310
ExpressionBodySyntax:
293311
active: true
294312
includeLineWrapping: true
295-
MayBeConst:
296-
active: true
297-
ModifierOrder:
298-
active: true
313+
ForbiddenComment:
314+
active: false
315+
MagicNumber:
316+
active: false
317+
# prefer rule provided by ktlint in the formatting section
318+
MaxLineLength:
319+
active: false
299320
NoTabs:
300321
active: true
301-
OptionalAbstractKeyword:
302-
active: true
303-
SafeCast:
304-
active: true
305-
UnusedPrivateClass:
306-
active: true
322+
ReturnCount:
323+
active: false
324+
ThrowsCount:
325+
active: false
326+
UnnecessaryAbstractClass:
327+
active: false
328+
UnusedPrivateMember:
329+
allowedNames: '(_|ignored|expected|serialVersionUID|createUIComponents)'
307330
VarCouldBeVal:
308331
active: false

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apacheCommons = "2.8.0"
33
assertJ = "3.20.2" # Upgrading leads to SAM errors: https://youtrack.jetbrains.com/issue/KT-17765
44
awsSdk = "2.17.219"
55
commonmark = "0.17.1"
6-
detekt = "1.20.0"
6+
detekt = "1.21.0"
77
intellijGradle = "1.7.0"
88
intellijRemoteRobot = "0.11.14"
99
jackson = "2.13.3"

jetbrains-core/detekt-baseline-integrationTest.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<?xml version="1.0" ?>
1+
<?xml version='1.0' encoding='UTF-8'?>
22
<SmellBaseline>
3-
<ManuallySuppressedIssues></ManuallySuppressedIssues>
3+
<ManuallySuppressedIssues/>
44
<CurrentIssues>
55
<ID>UnsafeCallOnNullableType:CreateFunctionIntegrationTest.kt$CreateFunctionIntegrationTest$AwsRegionProvider.getInstance()[Region.US_WEST_2.id()]!!</ID>
66
<ID>UnsafeCallOnNullableType:EcrPullIntegrationTest.kt$EcrPullIntegrationTest$dockerAdapter.buildLocalImage(dockerfile)!!</ID>
@@ -11,7 +11,6 @@
1111
<ID>UnsafeCallOnNullableType:JavaAwsConnectionExtensionIntegrationTest.kt$JavaAwsConnectionExtensionIntegrationTest$LocalFileSystem.getInstance().refreshAndFindFileByPath(jdkHome)!!</ID>
1212
<ID>UnsafeCallOnNullableType:JavaAwsConnectionExtensionIntegrationTest.kt$JavaAwsConnectionExtensionIntegrationTest$SdkConfigurationUtil.setupSdk(emptyArray(), jdkHomeDir, JavaSdk.getInstance(), false, null, jdkName)!!</ID>
1313
<ID>UnsafeCallOnNullableType:JavaLocalLambdaRunConfigurationIntegrationTest.kt$JavaLocalLambdaRunConfigurationIntegrationTest$projectRule.fixture.tempDirFixture.createFile("tmp", "\"Hello World\"").canonicalPath!!</ID>
14-
<ID>UnsafeCallOnNullableType:PythonAwsConnectionExtensionIntegrationTest.kt$PythonAwsConnectionExtensionIntegrationTest$detectSystemWideSdks(null, emptyList()).first().homePath!!</ID>
1514
<ID>UnsafeCallOnNullableType:PythonLocalLambdaRunConfigurationIntegrationTest.kt$PythonLocalLambdaRunConfigurationIntegrationTest$FileDocumentManager.getInstance().getDocument(lambdaClass.virtualFile)!!</ID>
1615
<ID>UnsafeCallOnNullableType:PythonLocalLambdaRunConfigurationIntegrationTest.kt$PythonLocalLambdaRunConfigurationIntegrationTest$LambdaRuntime.fromValue(runtime)!!</ID>
1716
<ID>UnsafeCallOnNullableType:PythonLocalLambdaRunConfigurationIntegrationTest.kt$PythonLocalLambdaRunConfigurationIntegrationTest$projectRule.fixture.tempDirFixture.createFile("tmp", "Hello World").canonicalPath!!</ID>

0 commit comments

Comments
 (0)