File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed
src/software/aws/toolkits/gradle/detekt/rules
tst/software/aws/toolkits/gradle/detekt/rules
jetbrains-core/tst/software/aws/toolkits/jetbrains/services/codewhisperer Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,16 @@ class BannedImportsRule : Rule() {
69
69
)
70
70
)
71
71
}
72
+
73
+ if (importedFqName == " com.google.gson.Gson" ) {
74
+ report(
75
+ CodeSmell (
76
+ issue,
77
+ Entity .from(element),
78
+ message = " Use jacksonObjectMapper() insted of Gson"
79
+ )
80
+ )
81
+ }
72
82
}
73
83
}
74
84
}
Original file line number Diff line number Diff line change @@ -24,6 +24,13 @@ class BannedImportsRuleTest {
24
24
.matches { it.id == " BannedImports" && it.message == " Use AssertJ instead of Hamcrest assertions" }
25
25
}
26
26
27
+ @Test
28
+ fun `Importing Gson fails` () {
29
+ assertThat(rule.lint(" import com.google.gson.Gson" ))
30
+ .singleElement()
31
+ .matches { it.id == " BannedImports" && it.message == " Use jacksonObjectMapper() insted of Gson" }
32
+ }
33
+
27
34
@Test
28
35
fun `Importing Kotlin test assert fails` () {
29
36
assertThat(rule.lint(" import kotlin.test.assertTrue" ))
Original file line number Diff line number Diff line change 3
3
4
4
package software.aws.toolkits.jetbrains.services.codewhisperer
5
5
6
- import com.google.gson.Gson
6
+ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
7
7
import com.intellij.openapi.application.ApplicationManager
8
8
import com.intellij.openapi.command.WriteCommandAction
9
9
import com.intellij.openapi.editor.Editor
@@ -379,14 +379,15 @@ class CodeWhispererTelemetryTest : CodeWhispererTestBase() {
379
379
fun `test user Decision events record CodeWhisperer reference info` () {
380
380
val userGroup = CodeWhispererUserGroupSettings .getInstance().getUserGroup()
381
381
withCodeWhispererServiceInvokedAndWait {}
382
+ val mapper = jacksonObjectMapper()
382
383
argumentCaptor<MetricEvent >().apply {
383
384
verify(batcher, atLeastOnce()).enqueue(capture())
384
385
pythonResponse.completions().forEach {
385
386
assertEventsContainsFieldsAndCount(
386
387
allValues,
387
388
userDecision,
388
389
1 ,
389
- " codewhispererSuggestionReferences" to Gson ().toJson (it.references().map { ref -> ref.licenseName() }.toSet()),
390
+ " codewhispererSuggestionReferences" to mapper.writeValueAsString (it.references().map { ref -> ref.licenseName() }.toSet()),
390
391
" codewhispererSuggestionReferenceCount" to it.references().size.toString(),
391
392
" codewhispererUserGroup" to userGroup.name,
392
393
atLeast = true
You can’t perform that action at this time.
0 commit comments