Skip to content

Commit cad10ef

Browse files
committed
Fixing lint issues
1 parent 600f91a commit cad10ef

File tree

4 files changed

+17
-27
lines changed

4 files changed

+17
-27
lines changed

plugins/amazonq/chat/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonq/lsp/artifacts/ManifestFetcherTest.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
package software.aws.toolkits.jetbrains.services.amazonq.lsp.artifacts
55

6-
76
import io.mockk.every
87
import io.mockk.spyk
98
import io.mockk.verify
@@ -23,10 +22,8 @@ class ManifestFetcherTest {
2322
manifest = ManifestManager.Manifest()
2423
}
2524

26-
2725
@Test
2826
fun `should return null when both local and remote manifests are null`() {
29-
3027
val fetchLocalManifestMock = spyk<ManifestFetcher>(recordPrivateCalls = true)
3128

3229
every { fetchLocalManifestMock["fetchManifestFromLocal"]() } returns null
@@ -39,7 +36,6 @@ class ManifestFetcherTest {
3936

4037
@Test
4138
fun `should return valid result from local should not execute remote method`() {
42-
4339
val fetchLocalManifestMock = spyk<ManifestFetcher>(recordPrivateCalls = true)
4440

4541
every { fetchLocalManifestMock["fetchManifestFromLocal"]() } returns manifest
@@ -51,7 +47,6 @@ class ManifestFetcherTest {
5147

5248
@Test
5349
fun `should return valid result from remote`() {
54-
5550
val fetchLocalManifestMock = spyk<ManifestFetcher>(recordPrivateCalls = true)
5651

5752
every { fetchLocalManifestMock["fetchManifestFromLocal"]() } returns null

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/artifacts/ManifestFetcher.kt

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import software.aws.toolkits.jetbrains.services.amazonq.project.manifest.Manifes
1616
import java.nio.file.Path
1717
import java.nio.file.Paths
1818

19-
2019
class ManifestFetcher {
2120

2221
private val lspManifestUrl = "https://aws-toolkit-language-servers.amazonaws.com/codewhisperer/0/manifest.json"
@@ -30,7 +29,7 @@ class ManifestFetcher {
3029
/**
3130
* Method which will be used to fetch latest manifest.
3231
* */
33-
fun fetch() : ManifestManager.Manifest? {
32+
fun fetch(): ManifestManager.Manifest? {
3433
val localManifest = fetchManifestFromLocal()
3534
if (localManifest != null) {
3635
return localManifest
@@ -39,13 +38,12 @@ class ManifestFetcher {
3938
return remoteManifest
4039
}
4140

42-
private fun fetchManifestFromRemote() : ManifestManager.Manifest? {
43-
val manifest : ManifestManager.Manifest?
41+
private fun fetchManifestFromRemote(): ManifestManager.Manifest? {
42+
val manifest: ManifestManager.Manifest?
4443
try {
4544
val manifestString = getTextFromUrl(lspManifestUrl)
4645
manifest = manifestManager.readManifestFile(manifestString) ?: return null
47-
}
48-
catch (e: Exception) {
46+
} catch (e: Exception) {
4947
logger.error("error fetching lsp manifest from remote URL ${e.message}", e)
5048
return null
5149
}
@@ -61,23 +59,21 @@ class ManifestFetcher {
6159
private fun updateManifestCache() {
6260
try {
6361
saveFileFromUrl(lspManifestUrl, lspManifestFilePath)
64-
}
65-
catch (e: Exception) {
62+
} catch (e: Exception) {
6663
logger.error("error occurred while saving lsp manifest to local cache ${e.message}", e)
6764
}
6865
}
6966

70-
private fun fetchManifestFromLocal() : ManifestManager.Manifest? {
71-
var manifest : ManifestManager.Manifest? = null
67+
private fun fetchManifestFromLocal(): ManifestManager.Manifest? {
68+
var manifest: ManifestManager.Manifest? = null
7269
val localETag = getManifestETagFromLocal()
7370
val remoteETag = getManifestETagFromUrl()
7471
// If local and remote have same ETag, we can re-use the manifest file from local to fetch artifacts.
7572
if (localETag != null && remoteETag != null && localETag == remoteETag) {
7673
try {
7774
val manifestContent = lspManifestFilePath.readText()
7875
manifest = manifestManager.readManifestFile(manifestContent) ?: return null
79-
}
80-
catch (e: Exception) {
76+
} catch (e: Exception) {
8177
logger.error("error reading lsp manifest file from local ${e.message}", e)
8278
return null
8379
}
@@ -86,21 +82,20 @@ class ManifestFetcher {
8682
return manifest
8783
}
8884

89-
private fun getManifestETagFromLocal() : String? {
90-
if(lspManifestFilePath.exists()) {
85+
private fun getManifestETagFromLocal(): String? {
86+
if (lspManifestFilePath.exists()) {
9187
val messageDigest = DigestUtil.md5()
9288
DigestUtil.updateContentHash(messageDigest, lspManifestFilePath)
9389
return StringUtil.toHexString(messageDigest.digest())
9490
}
9591
return null
9692
}
9793

98-
private fun getManifestETagFromUrl() : String? {
94+
private fun getManifestETagFromUrl(): String? {
9995
try {
10096
val actualETag = getETagFromUrl(lspManifestUrl)
10197
return actualETag.trim('"')
102-
}
103-
catch (e: Exception) {
98+
} catch (e: Exception) {
10499
logger.error("error fetching ETag of lsp manifest from url.", e)
105100
}
106101
return null

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/project/manifest/ManifestManager.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ class ManifestManager {
4444
@JsonProperty("name")
4545
val name: String? = null,
4646
@JsonProperty("version")
47-
val version: String? = null
47+
val version: String? = null,
4848
)
4949

5050
data class Capabilities(
5151
@JsonProperty("name")
5252
val name: String? = null,
5353
@JsonProperty("version")
54-
val version: String? = null
54+
val version: String? = null,
5555
)
5656

5757
data class Protocol(
5858
@JsonProperty("name")
59-
val name: String?= null,
59+
val name: String? = null,
6060
@JsonProperty("version")
61-
val version: String? = null
61+
val version: String? = null,
6262
)
6363

6464
data class Version(

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/core/HttpUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fun writeJsonToUrl(url: String, jsonString: String, indicator: ProgressIndicator
2525
request.readString(indicator)
2626
}
2727

28-
fun getETagFromUrl(url: String) : String =
28+
fun getETagFromUrl(url: String): String =
2929
HttpRequests.head(url)
3030
.userAgent("AWS Toolkit for JetBrains")
3131
.connect { request ->

0 commit comments

Comments
 (0)