Skip to content

Commit ac6f2e5

Browse files
author
David Hasani
committed
fix more detekt issues
1 parent cdeacd6 commit ac6f2e5

File tree

6 files changed

+35
-32
lines changed

6 files changed

+35
-32
lines changed

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/constants/CodeTransformChatItems.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -312,13 +312,13 @@ fun buildUserInputLanguageUpgradeChatContent(project: Project, validationResult:
312312
}
313313

314314
fun buildUserInputSQLConversionMetadataChatContent() = CodeTransformChatMessageContent(
315-
message = message("codemodernizer.chat.form.user_selection.item.choose_sql_metadata_file"),
316-
buttons = listOf(
317-
confirmUserSelectionSQLConversionMetadataButton,
318-
cancelUserSelectionButton,
319-
),
320-
type = CodeTransformChatMessageType.FinalizedAnswer,
321-
)
315+
message = message("codemodernizer.chat.form.user_selection.item.choose_sql_metadata_file"),
316+
buttons = listOf(
317+
confirmUserSelectionSQLConversionMetadataButton,
318+
cancelUserSelectionButton,
319+
),
320+
type = CodeTransformChatMessageType.FinalizedAnswer,
321+
)
322322

323323
fun buildModuleSchemaFormChatContent(project: Project, javaModules: List<VirtualFile>, schemaOptions: Set<String>) = CodeTransformChatMessageContent(
324324
type = CodeTransformChatMessageType.FinalizedAnswer,
@@ -353,7 +353,7 @@ fun buildSQLMetadataValidationSuccessDetailsChatContent(validationResult: SqlMet
353353
| **Source DB** | ${validationResult.sourceVendor} |
354354
| **Target DB** | ${validationResult.targetVendor} |
355355
| **Host** | ${validationResult.sourceServerName} |
356-
""".trimIndent(),
356+
""".trimIndent(),
357357
)
358358

359359
fun buildSQLMetadataValidationErrorChatContent(errorReason: String) = CodeTransformChatMessageContent(

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/model/CodeModernizerSessionContext.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ data class CodeModernizerSessionContext(
199199
val files = root?.let {
200200
VfsUtil.collectChildrenRecursively(it).filter { child ->
201201
val childPath = Path(child.path)
202-
!child.isDirectory && directoriesToExclude.none { childPath.startsWith(it.toPath()) }
202+
!child.isDirectory && directoriesToExclude.none { dir -> childPath.startsWith(dir.toPath()) }
203203
}
204204
}
205205
val dependencyFiles = if (depDirectory != null) {
@@ -217,8 +217,11 @@ data class CodeModernizerSessionContext(
217217
if (sqlMetadataZip != null) {
218218
// doing a SQL conversion, not language upgrade
219219
val sctFileName = sqlMetadataZip.listFiles { file -> file.name.endsWith(".sct") }.first().name
220-
manifest = ZipManifest(requestedConversions = RequestedConversions(
221-
SQLConversion(sourceVendor, targetVendor, schema, sourceServerName, sctFileName)))
220+
manifest = ZipManifest(
221+
requestedConversions = RequestedConversions(
222+
SQLConversion(sourceVendor, targetVendor, schema, sourceServerName, sctFileName)
223+
)
224+
)
222225
}
223226
mapper.writeValueAsString(manifest)
224227
.byteInputStream()

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/panels/managers/BuildProgressSplitterPanelManager.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class BuildProgressSplitterPanelManager(private val project: Project) :
115115
}
116116
}
117117

118-
fun handleProgressStateChanged(newState: TransformationStatus, plan: TransformationPlan?, jdk: JavaSdkVersion, transformationType: CodeTransformType) {
118+
fun handleProgressStateChanged(newState: TransformationStatus, plan: TransformationPlan?, jdk: JavaSdkVersion, transformType: CodeTransformType) {
119119
val currentState = statusTreePanel.getCurrentElements()
120120
val loadingPanelText: String
121121
// show the details panel when there are progress updates
@@ -128,7 +128,7 @@ class BuildProgressSplitterPanelManager(private val project: Project) :
128128

129129
fun maybeAdd(stepId: ProgressStepId, string: String) {
130130
// don't show building message for SQL conversions since we don't build the code
131-
if (string == message("codemodernizer.toolwindow.progress.building") && transformationType == CodeTransformType.SQL_CONVERSION) {
131+
if (string == message("codemodernizer.toolwindow.progress.building") && transformType == CodeTransformType.SQL_CONVERSION) {
132132
return
133133
}
134134
if (currentState.none { it.id == stepId }) {
@@ -146,7 +146,7 @@ class BuildProgressSplitterPanelManager(private val project: Project) :
146146
maybeAdd(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building"))
147147
}
148148
// immediately jump to planning stage for SQL conversions after upload completes since we don't build the code
149-
if (newState in setOf(TransformationStatus.PREPARED, newState == TransformationStatus.PLANNING) || transformationType == CodeTransformType.SQL_CONVERSION) {
149+
if (newState in setOf(TransformationStatus.PREPARED, newState == TransformationStatus.PLANNING) || transformType == CodeTransformType.SQL_CONVERSION) {
150150
maybeAdd(ProgressStepId.UPLOADING, message("codemodernizer.toolwindow.progress.uploading"))
151151
maybeAdd(ProgressStepId.BUILDING, message("codemodernizer.toolwindow.progress.building"))
152152
maybeAdd(ProgressStepId.PLANNING, message("codemodernizer.toolwindow.progress.planning"))
@@ -217,7 +217,7 @@ class BuildProgressSplitterPanelManager(private val project: Project) :
217217
}
218218

219219
TransformationStatus.PREPARING -> {
220-
loadingPanelText = if (transformationType != CodeTransformType.SQL_CONVERSION) {
220+
loadingPanelText = if (transformType != CodeTransformType.SQL_CONVERSION) {
221221
message("codemodernizer.toolwindow.scan_in_progress.building", jdk.description)
222222
} else {
223223
message("codemodernizer.toolwindow.scan_in_progress.planning")
@@ -226,7 +226,7 @@ class BuildProgressSplitterPanelManager(private val project: Project) :
226226
}
227227

228228
TransformationStatus.PREPARED -> {
229-
loadingPanelText = if (transformationType != CodeTransformType.SQL_CONVERSION) {
229+
loadingPanelText = if (transformType != CodeTransformType.SQL_CONVERSION) {
230230
message("codemodernizer.toolwindow.scan_in_progress.building", jdk.description)
231231
} else {
232232
message("codemodernizer.toolwindow.scan_in_progress.planning")
@@ -235,7 +235,7 @@ class BuildProgressSplitterPanelManager(private val project: Project) :
235235
}
236236

237237
TransformationStatus.PLANNING -> {
238-
loadingPanelText = if (transformationType != CodeTransformType.SQL_CONVERSION) {
238+
loadingPanelText = if (transformType != CodeTransformType.SQL_CONVERSION) {
239239
message("codemodernizer.toolwindow.scan_in_progress.building", jdk.description)
240240
} else {
241241
message("codemodernizer.toolwindow.scan_in_progress.planning")

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/utils/CodeTransformFileUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ fun validateSctMetadata(sctFile: File?): SqlMetadataValidationResult {
180180
} else {
181181
fullNameNodeInfo = fullNameNodeInfo as List<Map<*, *>>
182182
}
183-
fullNameNodeInfo.forEach{ node ->
183+
fullNameNodeInfo.forEach { node ->
184184
if ((node["typeNode"] as String).lowercase() == "schema") {
185185
schemaNames.add((node["nameNode"] as String).uppercase()) // user will choose one later
186186
}

plugins/amazonq/codetransform/jetbrains-community/src/software/aws/toolkits/jetbrains/services/codemodernizer/utils/CodeTransformProjectUtils.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,23 @@ fun Project.getSupportedModules(supportedJavaMappings: Map<JavaSdkVersion, Set<J
8282
// return the first file or directory found inside each open Java module, so that user can select a Module for us to ZIP
8383
// does not strictly need to return the first file or directory found, any one would work fine
8484
fun Project.getJavaModules() = this.modules.flatMap { module ->
85-
val rootManager = ModuleRootManager.getInstance(module)
86-
if (rootManager.sdk?.sdkType?.name?.lowercase()?.contains("java") == true) {
87-
val contentRoots = rootManager.contentRoots
88-
if (contentRoots.isNotEmpty()) {
89-
val firstContentRoot = contentRoots.first()
90-
val children = firstContentRoot.children
91-
if (children.isNotEmpty()) {
92-
listOf(children.first())
93-
} else {
94-
emptyList()
95-
}
85+
val rootManager = ModuleRootManager.getInstance(module)
86+
if (rootManager.sdk?.sdkType?.name?.lowercase()?.contains("java") == true) {
87+
val contentRoots = rootManager.contentRoots
88+
if (contentRoots.isNotEmpty()) {
89+
val firstContentRoot = contentRoots.first()
90+
val children = firstContentRoot.children
91+
if (children.isNotEmpty()) {
92+
listOf(children.first())
9693
} else {
9794
emptyList()
9895
}
9996
} else {
10097
emptyList()
10198
}
99+
} else {
100+
emptyList()
102101
}
102+
}
103103

104104
fun Project.getModuleOrProjectNameForFile(file: VirtualFile?) = file?.let { ModuleUtil.findModuleForFile(it, this)?.name } ?: this.name

plugins/amazonq/codetransform/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/codemodernizer/CodeWhispererCodeModernizerUtilsTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ class CodeWhispererCodeModernizerUtilsTest : CodeWhispererCodeModernizerTestBase
277277
</ProjectModel>
278278
</instances>
279279
</tree>
280-
""".trimIndent()
280+
""".trimIndent()
281281

282282
val tempFile = createTempFile("valid-sctFile", ".xml").toFile()
283283
tempFile.writeText(sampleFileContents)
@@ -336,7 +336,7 @@ class CodeWhispererCodeModernizerUtilsTest : CodeWhispererCodeModernizerTestBase
336336
</ProjectModel>
337337
</instances>
338338
</tree>
339-
""".trimIndent()
339+
""".trimIndent()
340340

341341
val tempFile = createTempFile("invalid-sctFile1", ".xml").toFile()
342342
tempFile.writeText(sampleFileContents)
@@ -391,7 +391,7 @@ class CodeWhispererCodeModernizerUtilsTest : CodeWhispererCodeModernizerTestBase
391391
</ProjectModel>
392392
</instances>
393393
</tree>
394-
""".trimIndent()
394+
""".trimIndent()
395395

396396
val tempFile = createTempFile("invalid-sctFile2", ".xml").toFile()
397397
tempFile.writeText(sampleFileContents)

0 commit comments

Comments
 (0)