Skip to content

Commit df541b5

Browse files
authored
More detekt rules (#3101)
1 parent d7c82fa commit df541b5

File tree

8 files changed

+32
-25
lines changed

8 files changed

+32
-25
lines changed

detekt-rules/detekt.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ formatting:
6464
EnumEntryNameCase:
6565
active: false
6666
autoCorrect: true
67-
ExpressionBodySyntax:
68-
includeLineWrapping: true
6967
Filename:
7068
active: true
7169
FinalNewline:
@@ -283,3 +281,24 @@ potential-bugs:
283281
active: false
284282
WrongEqualsTypeParameter:
285283
active: true
284+
285+
style:
286+
EqualsNullCall:
287+
active: true
288+
ExpressionBodySyntax:
289+
active: true
290+
includeLineWrapping: true
291+
MayBeConst:
292+
active: true
293+
ModifierOrder:
294+
active: true
295+
NoTabs:
296+
active: true
297+
OptionalAbstractKeyword:
298+
active: true
299+
SafeCast:
300+
active: true
301+
UnusedPrivateClass:
302+
active: true
303+
VarCouldBeVal:
304+
active: true

jetbrains-core/src/software/aws/toolkits/jetbrains/services/dynamic/CloudControlApiResources.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ import software.aws.toolkits.jetbrains.core.map
1616
import software.aws.toolkits.jetbrains.services.s3.resources.S3Resources
1717

1818
object CloudControlApiResources {
19-
fun listResources(typeName: String): Resource<List<DynamicResource>> {
20-
return when (typeName) {
19+
fun listResources(typeName: String): Resource<List<DynamicResource>> =
20+
when (typeName) {
2121
S3_BUCKET -> S3Resources.LIST_BUCKETS.map { it.name() }
2222
else -> ClientBackedCachedResource(CloudControlClient::class, "cloudcontrolapi.dynamic.resources.$typeName") {
2323
this.listResourcesPaginator { req -> req.typeName(typeName) }
2424
.flatMap { page -> page.resourceDescriptions().map { it.identifier() } }
2525
}
2626
}.map { DynamicResource(resourceTypeFromResourceTypeName(typeName), it) }
27-
}
2827

2928
fun resourceTypeFromResourceTypeName(typeName: String): ResourceType {
3029
val (_, svc, type) = typeName.split("::")

jetbrains-core/src/software/aws/toolkits/jetbrains/services/ecr/CreateEcrRepoDialog.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ class CreateEcrRepoDialog(
5656

5757
override fun continuousValidation() = false
5858

59-
override fun doValidateAll(): List<ValidationInfo> {
60-
return panel.validateCallbacks.mapNotNull { it() }
61-
}
59+
override fun doValidateAll(): List<ValidationInfo> =
60+
panel.validateCallbacks.mapNotNull { it() }
6261

6362
override fun doOKAction() {
6463
val validation = doValidateAll()

jetbrains-core/src/software/aws/toolkits/jetbrains/services/federation/AwsConsoleUrlFactory.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ object AwsConsoleUrlFactory {
7373
return "$consoleHome${fragment ?: "/"}"
7474
}
7575

76-
fun getSigninUrl(connectionSettings: ConnectionSettings, destination: String?, httpClientBuilder: HttpClientBuilder = defaultHttpClientBuilder): String {
77-
return getSigninUrl(getSigninToken(connectionSettings, httpClientBuilder), destination, connectionSettings.region)
78-
}
76+
fun getSigninUrl(connectionSettings: ConnectionSettings, destination: String?, httpClientBuilder: HttpClientBuilder = defaultHttpClientBuilder): String =
77+
getSigninUrl(getSigninToken(connectionSettings, httpClientBuilder), destination, connectionSettings.region)
7978

8079
fun getSigninToken(connectionSettings: ConnectionSettings, httpClientBuilder: HttpClientBuilder = defaultHttpClientBuilder): String {
8180
val resolvedCreds = connectionSettings.credentials.resolveCredentials()

jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/wizard/SamInitProjectBuilderCommon.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ import javax.swing.JTextField
2323
@JvmOverloads
2424
fun setupSamSelectionElements(samExecutableField: JTextField, editButton: JButton, label: JComponent, postEditCallback: Runnable? = null) {
2525
fun getSamExecutable(): ExecutableInstance.ExecutableWithPath? =
26-
ExecutableManager.getInstance().getExecutableIfPresent<SamExecutable>().let {
27-
if (it is ExecutableInstance.ExecutableWithPath) {
28-
it
29-
} else {
30-
null
31-
}
32-
}
26+
ExecutableManager.getInstance().getExecutableIfPresent<SamExecutable>().let { it as? ExecutableInstance.ExecutableWithPath }
3327

3428
fun updateUi(validSamPath: Boolean) {
3529
runInEdt(ModalityState.any()) {

jetbrains-core/src/software/aws/toolkits/jetbrains/services/schemas/resources/SchemasResources.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ import software.aws.toolkits.jetbrains.services.lambda.wizard.SchemaSelectionIte
1414
import java.time.Duration
1515

1616
object SchemasResources {
17-
@JvmField
18-
val AWS_EVENTS_REGISTRY = "aws.events"
17+
const val AWS_EVENTS_REGISTRY = "aws.events"
1918

20-
@JvmField
2119
val LIST_REGISTRIES: Resource.Cached<List<RegistrySummary>> =
2220
ClientBackedCachedResource(SchemasClient::class, "schemas.list_registries") {
2321
listRegistriesPaginator { it.build() }
@@ -26,7 +24,6 @@ object SchemasResources {
2624
.toList()
2725
}
2826

29-
@JvmField
3027
val LIST_REGISTRIES_AND_SCHEMAS: Resource.Cached<List<SchemaSelectionItem>> =
3128
ClientBackedCachedResource(SchemasClient::class, "schemas.list_registries_and_schemas") {
3229
listRegistriesPaginator { it.build() }

jetbrains-core/tst/software/aws/toolkits/jetbrains/services/dynamic/explorer/DynamicResourceUpdateManagerTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class DynamicResourceUpdateManagerTest {
6666

6767
@Test
6868
fun `Resource State Change Triggers are correctly reflected`() {
69-
var testOperationState: MutableList<ResourceMutationState> = mutableListOf()
69+
val testOperationState: MutableList<ResourceMutationState> = mutableListOf()
7070
dynamicResourceUpdateManager = DynamicResourceUpdateManager.getInstance(projectRule.project)
7171

7272
cloudControlClient.stub {
@@ -115,7 +115,7 @@ class DynamicResourceUpdateManagerTest {
115115

116116
@Test
117117
fun `Resource State Change Triggers are updates status text`() {
118-
var testOperationStatus: MutableList<OperationStatus> = mutableListOf()
118+
val testOperationStatus: MutableList<OperationStatus> = mutableListOf()
119119
dynamicResourceUpdateManager = DynamicResourceUpdateManager.getInstance(projectRule.project)
120120

121121
cloudControlClient.stub {

jetbrains-ultimate/src/software/aws/toolkits/jetbrains/services/clouddebug/nodejs/NodeJsDebuggerSupport.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,6 @@ class NodeJsDebuggerSupport : DebuggerSupport() {
8686

8787
private companion object {
8888
private val NODE_EXECUTABLES = setOf("node", "nodejs")
89-
private val NODE_DEBUG = "--inspect-brk"
89+
private const val NODE_DEBUG = "--inspect-brk"
9090
}
9191
}

0 commit comments

Comments
 (0)