-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy pathSonarLintIntelliJClient.kt
More file actions
1098 lines (982 loc) · 53.2 KB
/
Copy pathSonarLintIntelliJClient.kt
File metadata and controls
1098 lines (982 loc) · 53.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* SonarLint for IntelliJ IDEA
* Copyright (C) SonarSource Sàrl
* sonarlint@sonarsource.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
*/
package org.sonarlint.intellij
import com.intellij.ide.BrowserUtil
import com.intellij.ide.util.PropertiesComponent
import com.intellij.notification.Notification
import com.intellij.notification.NotificationAction
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.ApplicationInfo
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.ApplicationNamesInfo
import com.intellij.openapi.application.ModalityState
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.fileEditor.OpenFileDescriptor
import com.intellij.openapi.module.Module
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.ProgressManager
import com.intellij.openapi.progress.Task
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.project.guessModuleDir
import com.intellij.openapi.project.guessProjectDir
import com.intellij.openapi.roots.TestSourcesFilter.isTestSources
import com.intellij.openapi.ui.MessageDialogBuilder
import com.intellij.openapi.util.io.FileUtilRt
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.util.net.ssl.CertificateManager
import com.intellij.util.proxy.CommonProxy
import java.io.ByteArrayInputStream
import java.io.IOException
import java.net.Authenticator
import java.net.InetSocketAddress
import java.net.Proxy
import java.net.URI
import java.net.URL
import java.nio.file.Path
import java.nio.file.Paths
import java.security.cert.CertificateException
import java.security.cert.CertificateFactory
import java.security.cert.X509Certificate
import java.util.UUID
import java.util.concurrent.CancellationException
import java.util.concurrent.CompletableFuture
import java.util.concurrent.TimeoutException
import kotlinx.html.emptyMap
import org.apache.commons.text.StringEscapeUtils
import org.eclipse.lsp4j.jsonrpc.ResponseErrorException
import org.eclipse.lsp4j.jsonrpc.messages.ResponseError
import org.eclipse.lsp4j.jsonrpc.messages.ResponseErrorCode
import org.sonarlint.intellij.actions.OpenInBrowserAction
import org.sonarlint.intellij.actions.RestartBackendNotificationAction
import org.sonarlint.intellij.actions.SonarLintToolWindow
import org.sonarlint.intellij.analysis.AnalysisReadinessCache
import org.sonarlint.intellij.analysis.AnalysisSubmitter
import org.sonarlint.intellij.analysis.AnalysisSubmitter.Companion.collectContributedLanguages
import org.sonarlint.intellij.analysis.InferredAnalysisPropertiesProvider.collectContributedExtraProperties
import org.sonarlint.intellij.analysis.InferredAnalysisPropertiesProvider.getConfigurationFromConfiguratorEP
import org.sonarlint.intellij.analysis.LocalFileExclusions
import org.sonarlint.intellij.analysis.OnTheFlyFindingsCoordinator
import org.sonarlint.intellij.analysis.OpenInIdeFindingCache
import org.sonarlint.intellij.analysis.RunningAnalysesTracker
import org.sonarlint.intellij.binding.BindingSuggestionHandler.findOverriddenModules
import org.sonarlint.intellij.binding.BindingSuggestionHandler.getAutoShareConfigParams
import org.sonarlint.intellij.binding.ClientBindingSuggestion
import org.sonarlint.intellij.cayc.NewCodePeriodCache
import org.sonarlint.intellij.common.analysis.FilesContributor
import org.sonarlint.intellij.common.ui.ReadActionUtils.Companion.computeReadActionSafely
import org.sonarlint.intellij.common.ui.SonarLintConsole
import org.sonarlint.intellij.common.util.FileUtils.isFileValidForSonarLintWithExtensiveChecks
import org.sonarlint.intellij.common.util.SonarLintUtils.getService
import org.sonarlint.intellij.common.util.SonarLintUtils.isRider
import org.sonarlint.intellij.common.vcs.VcsRepo
import org.sonarlint.intellij.common.vcs.VcsRepoProvider
import org.sonarlint.intellij.config.Settings.getGlobalSettings
import org.sonarlint.intellij.config.Settings.getSettingsFor
import org.sonarlint.intellij.config.global.AutomaticServerConnectionCreator
import org.sonarlint.intellij.config.global.credentials.CredentialsService
import org.sonarlint.intellij.config.global.wizard.ManualServerConnectionCreator
import org.sonarlint.intellij.connected.SonarProjectBranchCache
import org.sonarlint.intellij.core.BackendService
import org.sonarlint.intellij.core.BackendService.Companion.findModule
import org.sonarlint.intellij.core.ProjectBindingManager
import org.sonarlint.intellij.documentation.SonarLintDocumentation.Intellij.CONNECTED_MODE_BENEFITS_LINK
import org.sonarlint.intellij.documentation.SonarLintDocumentation.Intellij.CONNECTED_MODE_SETUP_LINK
import org.sonarlint.intellij.documentation.SonarLintDocumentation.Intellij.SUPPORT_POLICY_LINK
import org.sonarlint.intellij.documentation.SonarLintDocumentation.Intellij.TROUBLESHOOTING_CONNECTED_MODE_SETUP_LINK
import org.sonarlint.intellij.editor.EditorHighlightRefresh
import org.sonarlint.intellij.finding.Finding
import org.sonarlint.intellij.finding.ShowFinding
import org.sonarlint.intellij.finding.hotspot.LiveSecurityHotspot
import org.sonarlint.intellij.finding.issue.LiveIssue
import org.sonarlint.intellij.finding.issue.vulnerabilities.LocalTaintVulnerability
import org.sonarlint.intellij.finding.issue.vulnerabilities.TaintVulnerabilitiesCache
import org.sonarlint.intellij.finding.issue.vulnerabilities.TaintVulnerabilityMatcher
import org.sonarlint.intellij.finding.sca.DependencyRisksCache
import org.sonarlint.intellij.finding.sca.LocalDependencyRisk
import org.sonarlint.intellij.fix.ShowFixSuggestion
import org.sonarlint.intellij.messages.PLUGIN_STATUS_CHANGE_TOPIC
import org.sonarlint.intellij.notifications.AnalysisRequirementNotifications.notifyOnceForSkippedPlugins
import org.sonarlint.intellij.notifications.GenerateTokenAction
import org.sonarlint.intellij.notifications.OpenLinkAction
import org.sonarlint.intellij.notifications.OpenProjectSettingsAction
import org.sonarlint.intellij.notifications.OpenSupportedLanguagesPanelAction
import org.sonarlint.intellij.notifications.SonarLintProjectNotifications.Companion.get
import org.sonarlint.intellij.notifications.SonarLintProjectNotifications.Companion.projectLessNotification
import org.sonarlint.intellij.notifications.binding.BindingSuggestion
import org.sonarlint.intellij.progress.BackendTaskProgressReporter
import org.sonarlint.intellij.promotion.PromotionProvider
import org.sonarlint.intellij.sharing.ConfigurationSharing
import org.sonarlint.intellij.sharing.SharedConnectedModeUtils.Companion.findConnectedModeFile
import org.sonarlint.intellij.sharing.SharedConnectedModeUtils.Companion.findSharedFolder
import org.sonarlint.intellij.ui.UiUtils.Companion.runOnUiThread
import org.sonarlint.intellij.util.GlobalLogOutput
import org.sonarlint.intellij.util.ProjectUtils.tryFindFile
import org.sonarlint.intellij.util.SonarLintAppUtils.findModuleForFile
import org.sonarlint.intellij.util.SonarLintAppUtils.getRelativePathForAnalysis
import org.sonarlint.intellij.util.SonarLintAppUtils.visitAndAddAllFilesForModule
import org.sonarlint.intellij.util.VirtualFileUtils
import org.sonarlint.intellij.util.VirtualFileUtils.getFileContent
import org.sonarlint.intellij.util.computeInEDT
import org.sonarlint.intellij.util.computeOnPooledThread
import org.sonarlint.intellij.util.runOnPooledThread
import org.sonarsource.sonarlint.core.client.utils.ClientLogOutput
import org.sonarsource.sonarlint.core.rpc.client.ConfigScopeNotFoundException
import org.sonarsource.sonarlint.core.rpc.client.SonarLintCancelChecker
import org.sonarsource.sonarlint.core.rpc.client.SonarLintRpcClientDelegate
import org.sonarsource.sonarlint.core.rpc.protocol.backend.config.binding.BindingSuggestionDto
import org.sonarsource.sonarlint.core.rpc.protocol.backend.config.binding.BindingSuggestionOrigin
import org.sonarsource.sonarlint.core.rpc.protocol.backend.plugin.PluginStateDto
import org.sonarsource.sonarlint.core.rpc.protocol.backend.plugin.PluginStatusDto
import org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.DependencyRiskDto
import org.sonarsource.sonarlint.core.rpc.protocol.backend.tracking.TaintVulnerabilityDto
import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.AssistBindingParams
import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.AssistBindingResponse
import org.sonarsource.sonarlint.core.rpc.protocol.client.binding.NoBindingSuggestionFoundParams
import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.AssistCreatingConnectionParams
import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.AssistCreatingConnectionResponse
import org.sonarsource.sonarlint.core.rpc.protocol.client.connection.ConnectionSuggestionDto
import org.sonarsource.sonarlint.core.rpc.protocol.client.fix.FixSuggestionDto
import org.sonarsource.sonarlint.core.rpc.protocol.client.hotspot.HotspotDetailsDto
import org.sonarsource.sonarlint.core.rpc.protocol.client.hotspot.RaisedHotspotDto
import org.sonarsource.sonarlint.core.rpc.protocol.client.http.GetProxyPasswordAuthenticationResponse
import org.sonarsource.sonarlint.core.rpc.protocol.client.http.ProxyDto
import org.sonarsource.sonarlint.core.rpc.protocol.client.http.X509CertificateDto
import org.sonarsource.sonarlint.core.rpc.protocol.client.issue.IssueDetailsDto
import org.sonarsource.sonarlint.core.rpc.protocol.client.issue.RaisedIssueDto
import org.sonarsource.sonarlint.core.rpc.protocol.client.log.LogLevel
import org.sonarsource.sonarlint.core.rpc.protocol.client.log.LogParams
import org.sonarsource.sonarlint.core.rpc.protocol.client.message.MessageActionItem
import org.sonarsource.sonarlint.core.rpc.protocol.client.message.MessageType
import org.sonarsource.sonarlint.core.rpc.protocol.client.message.ShowMessageRequestResponse
import org.sonarsource.sonarlint.core.rpc.protocol.client.message.ShowSoonUnsupportedMessageParams
import org.sonarsource.sonarlint.core.rpc.protocol.client.plugin.DidSkipLoadingPluginParams
import org.sonarsource.sonarlint.core.rpc.protocol.client.progress.ReportProgressParams
import org.sonarsource.sonarlint.core.rpc.protocol.client.progress.StartProgressParams
import org.sonarsource.sonarlint.core.rpc.protocol.client.smartnotification.ShowSmartNotificationParams
import org.sonarsource.sonarlint.core.rpc.protocol.client.telemetry.TelemetryClientLiveAttributesResponse
import org.sonarsource.sonarlint.core.rpc.protocol.common.ClientFileDto
import org.sonarsource.sonarlint.core.rpc.protocol.common.Either
import org.sonarsource.sonarlint.core.rpc.protocol.common.FlowDto
import org.sonarsource.sonarlint.core.rpc.protocol.common.Language
import org.sonarsource.sonarlint.core.rpc.protocol.common.SonarCloudRegion
import org.sonarsource.sonarlint.core.rpc.protocol.common.TextRangeDto
import org.sonarsource.sonarlint.core.rpc.protocol.common.TokenDto
import org.sonarsource.sonarlint.core.rpc.protocol.common.UsernamePasswordDto
private const val INTERRUPTED_MESSAGE = "Interrupted while waiting for Sonar project branch matching result"
private const val TIMEOUT_MESSAGE = "Timeout while waiting for Sonar project branch matching result"
object SonarLintIntelliJClient : SonarLintRpcClientDelegate {
private const val SONAR_SCANNER_CONFIG_FILENAME = "sonar-project.properties"
private const val SKIP_AUTO_SHARE_CONFIGURATION_DIALOG_PROPERTY = "SonarLint.AutoShareConfiguration"
private const val AUTOSCAN_CONFIG_FILENAME = ".sonarcloud.properties"
private const val SONARLINT_CONFIGURATION_FOLDER = ".sonarlint"
private val backendTaskProgressReporter = BackendTaskProgressReporter()
override fun suggestBinding(suggestionsByConfigScopeId: Map<String, List<BindingSuggestionDto>>) {
suggestionsByConfigScopeId.forEach { (configScopeId, suggestions) -> suggestAutoBind(findProject(configScopeId), suggestions) }
}
/**
* In IntelliJ, a project is associated with a specific project key and connection.
* Overridden modules are linked to different project keys but share the same connection as the original project.
*
* This method aims to:
* - Group all suggestions by their project
* - For each project group:
* - Identify the main project and its associated connection
* - Collect all overridden modules that share the same connection but have different project keys
* - Send a single binding notification for the main project along with its related modules
*/
override fun suggestConnection(suggestionsByConfigScope: Map<String, List<ConnectionSuggestionDto>>) {
// It was decided to only handle the case where there is only one notification per configuration scope
// A future improvement could allow the user to choose its preferred binding
val clientSuggestions = suggestionsByConfigScope.filter { (_, suggestions) -> suggestions.size == 1 }.mapNotNull { (configScopeId, suggestions) ->
findProject(configScopeId)?.let { ClientBindingSuggestion(configScopeId, it, null, suggestions.first()) } ?:
findModule(configScopeId)?.let { ClientBindingSuggestion(configScopeId, it.project, it, suggestions.first()) }
}
val moduleSuggestionsPerProject = clientSuggestions.groupBy { it.project }
moduleSuggestionsPerProject.forEach { (_, suggestions) ->
val projectBinding = suggestions.firstOrNull { it.module == null } ?: return@forEach
val overridesPerModule = findOverriddenModules(suggestions, projectBinding)
val (connectionKind, projKey, connectionName) = getAutoShareConfigParams(projectBinding.suggestion)
val optionalModulesBindingMessage = if (overridesPerModule.isEmpty()) "" else "Some of your modules will also be automatically bound.\n"
val textNotif = when (projectBinding.suggestion.origin) {
BindingSuggestionOrigin.SHARED_CONFIGURATION -> "A connected mode configuration file is available"
BindingSuggestionOrigin.PROPERTIES_FILE -> "A SonarQube property file was found"
else -> "A matching SonarQube connection was found"
}
ConfigurationSharing.showAutoSharedConfigurationNotification(
projectBinding.project,
overridesPerModule,
"""
$textNotif for binding project '%s' on %s '%s'.
$optionalModulesBindingMessage
The binding can also be manually configured later.
""".trimIndent().format(projKey, connectionKind, connectionName),
SKIP_AUTO_SHARE_CONFIGURATION_DIALOG_PROPERTY,
projectBinding.suggestion
)
}
}
private fun suggestAutoBind(project: Project?, suggestions: List<BindingSuggestionDto>) {
if (project == null) {
GlobalLogOutput.get().log("Discarding binding suggestions, project was closed", ClientLogOutput.Level.DEBUG)
return
}
if (getSettingsFor(project).isBindingSuggestionsEnabled && !getSettingsFor(project).isBound) {
val notifications = get(project)
notifications.suggestBindingOptions(suggestions.map {
BindingSuggestion(it.connectionId, it.sonarProjectKey, it.sonarProjectName, it.origin)
})
}
}
private fun findProject(configScopeId: String): Project? {
// XXX modules?
return ProjectManager.getInstance().openProjects.find { configScopeId == BackendService.projectId(it) }
}
override fun openUrlInBrowser(url: URL) {
BrowserUtil.browse(url)
}
override fun showMessage(type: MessageType, text: String) {
projectLessNotification(null, text, convert(type))
}
override fun showMessageRequest(type: MessageType, text: String, actions: List<MessageActionItem>): ShowMessageRequestResponse {
GlobalLogOutput.get().log("Received a message request", ClientLogOutput.Level.DEBUG)
if (actions.isEmpty()) {
showMessage(type, text)
return ShowMessageRequestResponse(null, false)
}
val responseFuture = CompletableFuture<String>()
val notificationActions = actions.map { actionItem ->
object : NotificationAction(actionItem.displayText) {
override fun actionPerformed(e: AnActionEvent, notification: Notification) {
responseFuture.complete(actionItem.key)
notification.expire()
}
}
}.toTypedArray()
val notification = projectLessNotification(null, text, convert(type), *notificationActions)
notification.whenExpired {
if (!responseFuture.isDone) {
responseFuture.complete(null)
}
}
val selectedActionKey = try {
responseFuture.get()
} catch (_: Exception) {
null
}
return ShowMessageRequestResponse(selectedActionKey, false)
}
override fun log(params: LogParams) {
val configScopeId = params.configScopeId
configScopeId?.let {
val project = findModule(configScopeId)?.project ?: BackendService.findProject(configScopeId)
project?.let {
val console: SonarLintConsole = getService(project, SonarLintConsole::class.java)
logProjectLevel(params.level, params.toString(), console)
return
}
}
val globalLogOutput = getService(GlobalLogOutput::class.java)
globalLogOutput.log(params.toString(), mapLevel(params.level))
}
private fun mapLevel(level: LogLevel): ClientLogOutput.Level {
return when (level) {
LogLevel.ERROR -> {
ClientLogOutput.Level.ERROR
}
LogLevel.WARN -> {
ClientLogOutput.Level.WARN
}
LogLevel.INFO -> {
ClientLogOutput.Level.INFO
}
LogLevel.DEBUG -> {
ClientLogOutput.Level.DEBUG
}
LogLevel.TRACE -> {
ClientLogOutput.Level.TRACE
}
}
}
override fun showSoonUnsupportedMessage(params: ShowSoonUnsupportedMessageParams) {
val project = findModule(params.configurationScopeId)?.project
?: BackendService.findProject(params.configurationScopeId) ?: return
showOneTimeBalloon(project, params.text, params.doNotShowAgainId, OpenLinkAction(SUPPORT_POLICY_LINK, "Learn more"))
}
private fun logProjectLevel(
logLevel: LogLevel,
message: String,
console: SonarLintConsole,
) {
when (logLevel) {
LogLevel.TRACE -> {
// Do not log TRACE level messages to avoid flooding the console
}
LogLevel.DEBUG -> console.debug(message)
LogLevel.ERROR -> console.error(message)
else -> console.info(message)
}
}
override fun showSmartNotification(params: ShowSmartNotificationParams) {
val projects = params.scopeIds.mapNotNull {
findModule(it)?.project ?: BackendService.findProject(it)
}.toSet()
projects.map { get(it).handle(params) }
}
private fun showOneTimeBalloon(project: Project, message: String, doNotShowAgainId: String, action: AnAction?) {
if (!PropertiesComponent.getInstance().getBoolean(doNotShowAgainId)) {
get(project).showOneTimeBalloon(message, doNotShowAgainId, action)
}
}
override fun getClientLiveDescription(): String {
var description = ApplicationInfo.getInstance().fullVersion
val edition = ApplicationNamesInfo.getInstance().editionName
if (edition != null) {
description += " ($edition)"
}
val openProjects = ProjectManager.getInstance().openProjects
if (openProjects.isNotEmpty()) {
description += " - " + openProjects.joinToString(", ") { it.name }
}
return description
}
private fun convert(type: MessageType): NotificationType {
if (type == MessageType.ERROR) return NotificationType.ERROR
if (type == MessageType.WARNING) return NotificationType.WARNING
return NotificationType.INFORMATION
}
override fun showHotspot(configurationScopeId: String, hotspotDetails: HotspotDetailsDto) {
showFinding(configurationScopeId, hotspotDetails.ideFilePath, hotspotDetails.key, hotspotDetails.rule.key, hotspotDetails.textRange, hotspotDetails.codeSnippet, LiveSecurityHotspot::class.java, emptyList(), hotspotDetails.message)
}
override fun showIssue(configurationScopeId: String, issueDetails: IssueDetailsDto) {
val findingType = if (issueDetails.isTaint) LocalTaintVulnerability::class.java else LiveIssue::class.java
showFinding(configurationScopeId, issueDetails.ideFilePath, issueDetails.issueKey, issueDetails.ruleKey, issueDetails.textRange, issueDetails.codeSnippet, findingType, issueDetails.flows, issueDetails.message)
}
override fun showFixSuggestion(configurationScopeId: String, issueKey: String, fixSuggestion: FixSuggestionDto) {
val project = findModule(configurationScopeId)?.project ?: BackendService.findProject(configurationScopeId)
?: throw IllegalStateException("Unable to find project with id '$configurationScopeId'")
val file = tryFindFile(project, fixSuggestion.fileEdit().idePath())
if (file == null) {
if (!project.isDisposed) {
get(project).simpleNotification(
null,
"Unable to open the fix suggestion. Cannot find the file: ${fixSuggestion.fileEdit().idePath()}." +
" Please verify you are in the right branch.",
NotificationType.WARNING
)
}
return
}
ShowFixSuggestion(project, file).show(fixSuggestion)
}
private fun <T : Finding> showFinding(
configScopeId: String, filePath: Path, findingKey: String, ruleKey: String,
textRange: TextRangeDto, codeSnippet: String?, type: Class<T>, flows: List<FlowDto>, flowMessage: String,
) {
val project = findModule(configScopeId)?.project ?: BackendService.findProject(configScopeId)
?: throw IllegalStateException("Unable to find project with id '$configScopeId'")
if (!project.isDisposed) {
get(project).expireCurrentFindingNotificationIfNeeded()
}
val file = tryFindFile(project, filePath)
if (file == null) {
if (!project.isDisposed) {
get(project).simpleNotification(null, "Unable to open finding. Cannot find the file: $filePath" +
". Please verify you are in the right branch.", NotificationType.WARNING)
}
return
}
val module = findModuleForFile(file, project)
if (module == null) {
if (!project.isDisposed) {
get(project).simpleNotification(
null, "Unable to open finding. Cannot find the module corresponding to file: $filePath", NotificationType.WARNING
)
}
return
}
val descriptor = OpenFileDescriptor(project, file, textRange.startLine - 1, -1)
runOnUiThread(project, ModalityState.defaultModalityState()) {
FileEditorManager.getInstance(project).openTextEditor(
descriptor, true
)
}
val showFinding = ShowFinding(
module,
ruleKey,
findingKey,
file,
textRange,
codeSnippet,
ShowFinding.handleFlows(module.project, flows),
flowMessage,
type
)
getService(project, OpenInIdeFindingCache::class.java).finding = showFinding
getService(project, OpenInIdeFindingCache::class.java).analysisQueued = false
if (getService(project, AnalysisReadinessCache::class.java).isProjectReady) {
getService(project, AnalysisSubmitter::class.java).analyzeFileAndTrySelectFinding(showFinding)
}
}
override fun assistCreatingConnection(
params: AssistCreatingConnectionParams,
cancelChecker: SonarLintCancelChecker,
): AssistCreatingConnectionResponse {
val isSQ = params.connectionParams.isLeft
val serverOrOrg = if (isSQ) params.connectionParams.left.serverUrl else params.connectionParams.right.organizationKey
val tokenName = if (isSQ) params.connectionParams.left.tokenName else params.connectionParams.right.tokenName
val tokenValue = if (isSQ) params.connectionParams.left.tokenValue else params.connectionParams.right.tokenValue
val region = if (isSQ) null else SonarCloudRegion.valueOf(params.connectionParams.right.region.name)
val response = if (tokenName != null && tokenValue != null) {
setUpAutomaticConnection(serverOrOrg, tokenValue, isSQ, region)
} else {
if (isSQ) {
setUpManualConnection(serverOrOrg)
} else {
throw CancellationException("SonarQube for IDE cannot assist with manual connection to SonarQube Cloud organization")
}
}
projectLessNotification(
"",
"You have successfully established a connection to the ${if (isSQ) "SonarQube Server instance" else "SonarQube Cloud organization"}",
NotificationType.INFORMATION
)
return response
}
private fun setUpAutomaticConnection(serverOrOrg: String, tokenValue: String,
isSQ: Boolean, region: SonarCloudRegion?): AssistCreatingConnectionResponse {
val newConnection = ApplicationManager.getApplication().computeInEDT {
AutomaticServerConnectionCreator(serverOrOrg, tokenValue, isSQ, region).chooseResolution()
} ?: run {
throw CancellationException("Connection creation cancelled by the user")
}
return AssistCreatingConnectionResponse(newConnection.name)
}
private fun setUpManualConnection(serverUrl: String): AssistCreatingConnectionResponse {
val warningTitle = "Trust This SonarQube Server Instance?"
val message = """
The server <b>${StringEscapeUtils.escapeHtml4(serverUrl)}</b> is attempting to set up a connection with SonarQube for IDE. Letting SonarQube for IDE connect to an untrusted SonarQube Server instance is potentially dangerous.
If you don’t trust this server, we recommend canceling this action and <a href="$CONNECTED_MODE_SETUP_LINK">manually setting up Connected Mode<icon src="AllIcons.Ide.External_link_arrow" href="$CONNECTED_MODE_SETUP_LINK"></a>.
""".trimIndent()
val connectButtonText = "Connect to This SonarQube Server Instance"
val dontTrustButtonText = "I Don't Trust This Server"
val choice = ApplicationManager.getApplication().computeInEDT {
MessageDialogBuilder.Message(warningTitle, message).buttons(connectButtonText, dontTrustButtonText)
.defaultButton(connectButtonText).focusedButton(dontTrustButtonText).asWarning().show()
}
if (connectButtonText != choice) {
throw CancellationException("Connection creation rejected by the user")
}
val newConnection = ApplicationManager.getApplication().computeInEDT {
ManualServerConnectionCreator().createThroughWizard(serverUrl)
} ?: throw CancellationException("Connection creation cancelled by the user")
return AssistCreatingConnectionResponse(newConnection.name)
}
override fun assistBinding(params: AssistBindingParams, cancelChecker: SonarLintCancelChecker): AssistBindingResponse {
val connectionId = params.connectionId
val projectKey = params.projectKey
val configScopeId = params.configScopeId
val project: Project? = configScopeId?.let {
findModule(it)?.project ?: findProject(it)
}
return if (project == null) {
AssistBindingResponse(null)
} else {
val connection = getGlobalSettings().getServerConnectionByName(connectionId)
.orElseThrow { IllegalStateException("Unable to find connection '$connectionId'") }
val binding = getService(project, ProjectBindingManager::class.java).binding
if (binding == null || binding.projectKey != projectKey || binding.connectionName != connection.name) {
getService(project, ProjectBindingManager::class.java).bindTo(connection, projectKey, emptyMap(),
params.origin)
get(project).simpleNotification(
"Project successfully bound",
"Local project bound to project '$projectKey' of SonarQube Server instance '${connection.name}'. "
+ "You can now enjoy all capabilities of SonarQube for IDE Connected Mode. The binding of this project can be updated in the SonarQube for IDE Settings.",
NotificationType.INFORMATION,
OpenInBrowserAction("Learn More in Documentation", null, CONNECTED_MODE_BENEFITS_LINK)
)
}
AssistBindingResponse(BackendService.projectId(project))
}
}
override fun startProgress(params: StartProgressParams) {
backendTaskProgressReporter.startTask(params)
}
override fun reportProgress(params: ReportProgressParams) {
if (params.notification.isLeft) {
backendTaskProgressReporter.updateProgress(params.taskId, params.notification.left)
} else {
backendTaskProgressReporter.completeTask(params.taskId)
}
}
override fun didSynchronizeConfigurationScopes(configurationScopeIds: Set<String>) {
GlobalLogOutput.get().log("Did synchronize config scopes $configurationScopeIds", ClientLogOutput.Level.INFO)
}
override fun getCredentials(connectionId: String): Either<TokenDto, UsernamePasswordDto> {
val connectionOpt = getGlobalSettings().getServerConnectionByName(connectionId)
if (connectionOpt.isEmpty) {
throw ResponseErrorException(ResponseError(ResponseErrorCode.InvalidParams, "Unknown connection: $connectionId", connectionId))
}
val connection = connectionOpt.get()
return runCatching {
getService(CredentialsService::class.java).getCredentials(connection)
}.getOrElse { e ->
val errorMessage = "Failed to retrieve credentials for connection '$connectionId': ${e.message}"
GlobalLogOutput.get().logError(errorMessage, e)
throw ResponseErrorException(ResponseError(ResponseErrorCode.InternalError, errorMessage, connectionId))
}
}
override fun getProxyPasswordAuthentication(
host: String,
port: Int,
protocol: String,
prompt: String,
scheme: String,
targetHost: URL,
): GetProxyPasswordAuthenticationResponse {
val auth = CommonProxy.getInstance().authenticator.requestPasswordAuthenticationInstance(host, null, port, protocol, prompt, scheme, targetHost, Authenticator.RequestorType.PROXY)
return GetProxyPasswordAuthenticationResponse(auth?.userName, auth?.let { String(it.password) })
}
override fun checkServerTrusted(chain: List<X509CertificateDto>, authType: String): Boolean {
val certificateFactory = CertificateFactory.getInstance("X.509")
val certificates: Array<X509Certificate> = chain.stream().map { certificateFactory.generateCertificate(ByteArrayInputStream(it.pem.toByteArray())) as X509Certificate }.toList().toTypedArray()
return try {
CertificateManager.getInstance().trustManager.checkServerTrusted(certificates, authType)
true
} catch (e: CertificateException) {
GlobalLogOutput.get().logError("Certificate is not trusted", e)
false
}
}
override fun selectProxies(uri: URI): List<ProxyDto> {
return CommonProxy.getInstance().select(uri).stream().map {
if (it.type() != Proxy.Type.DIRECT && it.address() is InetSocketAddress) {
val socketAddress = it.address() as InetSocketAddress
ProxyDto(it.type(), socketAddress.hostString, socketAddress.port)
} else {
ProxyDto.NO_PROXY
}
}.toList()
}
override fun getTelemetryLiveAttributes(): TelemetryClientLiveAttributesResponse {
return TelemetryClientLiveAttributesResponse(emptyMap())
}
override fun noBindingSuggestionFound(params: NoBindingSuggestionFoundParams) {
val serverType = if (params.isSonarCloud) "SonarQube Cloud" else "SonarQube Server"
projectLessNotification(
"No matching open project found",
"SonarQube for IDE cannot match $serverType project '${params.projectKey}' to any of the currently open projects. Please open your project and try again.",
NotificationType.WARNING,
OpenInBrowserAction("Open Troubleshooting Documentation", null, TROUBLESHOOTING_CONNECTED_MODE_SETUP_LINK)
)
}
override fun didChangeAnalysisReadiness(configurationScopeIds: Set<String>, areReadyForAnalysis: Boolean) {
GlobalLogOutput.get().log("Analysis became ready=$areReadyForAnalysis for $configurationScopeIds", ClientLogOutput.Level.DEBUG)
val projectToModulesMap = configurationScopeIds
.mapNotNull { configScopeId ->
val module = findModule(configScopeId)
val project = module?.project ?: findProject(configScopeId)
if (project != null) project to module else null
}
.groupBy({ it.first }, { it.second }) // Group by project, collecting modules into a list
projectToModulesMap.forEach { (project, modules) ->
if (project.isDisposed) return@forEach
modules.filterNotNull().forEach { module ->
getService(project, AnalysisReadinessCache::class.java).setReadinessForModule(module, areReadyForAnalysis)
}
getService(project, AnalysisReadinessCache::class.java).isProjectReady = areReadyForAnalysis
if (areReadyForAnalysis) {
runOnPooledThread(project) {
runOnUiThread(project) { getService(project, SonarLintToolWindow::class.java).setAnalysisReadyCurrentFile() }
val findingToShow = getService(project, OpenInIdeFindingCache::class.java).finding
if (findingToShow != null && !getService(project, OpenInIdeFindingCache::class.java).analysisQueued) {
getService(project, AnalysisSubmitter::class.java).analyzeFileAndTrySelectFinding(findingToShow)
}
}
}
}
}
override fun matchSonarProjectBranch(
configurationScopeId: String,
mainBranchName: String,
allBranchesNames: Set<String>,
cancelChecker: SonarLintCancelChecker,
): String? {
val matchStart = System.currentTimeMillis()
val repositoriesEPs = VcsRepoProvider.EP_NAME.extensionList
val repositories = findModule(configurationScopeId)?.let { module ->
matchSonarModule(module, repositoriesEPs)
} ?: run {
BackendService.findProject(configurationScopeId)?.let { project ->
matchSonarProject(project, repositoriesEPs)
}
} ?: return null
val repo = repositories.first()
val project = findModule(configurationScopeId)?.project
?: BackendService.findProject(configurationScopeId) ?: return null
val resultFuture = CompletableFuture<String>()
ProgressManager.getInstance().run(object : Task.Backgroundable(
project,
"Matching project branch…",
true,
ALWAYS_BACKGROUND
) {
override fun run(indicator: ProgressIndicator) {
try {
val result = repo.electBestMatchingServerBranchForCurrentHead(mainBranchName, allBranchesNames) ?: mainBranchName
resultFuture.complete(result)
} catch (e: InterruptedException) {
if (!project.isDisposed) {
getService(project, SonarLintConsole::class.java).error(INTERRUPTED_MESSAGE, e)
}
} catch (e: TimeoutException) {
if (!project.isDisposed) {
getService(project, SonarLintConsole::class.java).error(TIMEOUT_MESSAGE, e)
}
}
}
})
return computeOnPooledThread(project, "Waiting for branch matching result") {
try {
val matched = resultFuture.get()
getService(project, SonarLintConsole::class.java).debug(
"Matched Sonar project branch '$matched' for $configurationScopeId (${allBranchesNames.size} server branches) in ${System.currentTimeMillis() - matchStart} ms"
)
matched
} catch (e: InterruptedException) {
if (!project.isDisposed) {
getService(project, SonarLintConsole::class.java).error(INTERRUPTED_MESSAGE, e)
}
null
} catch (e: TimeoutException) {
if (!project.isDisposed) {
getService(project, SonarLintConsole::class.java).error(TIMEOUT_MESSAGE, e)
}
null
}
}
}
private fun matchSonarModule(module: Module, repositoriesEPs: List<VcsRepoProvider>): List<VcsRepo>? {
val repositories = computeOnPooledThread(module.project, "Match Sonar Project Branch Task") {
repositoriesEPs.mapNotNull { it.getRepoFor(module) }.toList()
}
if (repositories.isNullOrEmpty()) {
return null
}
if (repositories.size > 1) {
getService(
module.project,
SonarLintConsole::class.java
).debug("Several candidate VCS repositories detected for module $module, choosing first")
}
return repositories
}
private fun matchSonarProject(project: Project, repositoriesEPs: List<VcsRepoProvider>): List<VcsRepo>? {
val repositories = computeOnPooledThread(project, "Match Sonar Project Branch Task") {
repositoriesEPs.mapNotNull { it.getRepoFor(project) }.toList()
}
if (repositories.isNullOrEmpty()) {
return null
}
if (repositories.size > 1) {
getService(
project,
SonarLintConsole::class.java
).debug("Several candidate VCS repositories detected for project $project, choosing first")
}
return repositories
}
override fun didChangeMatchedSonarProjectBranch(configScopeId: String, newMatchedBranchName: String) {
val module = findModule(configScopeId)
if (module != null) {
getService(module.project, SonarProjectBranchCache::class.java).setMatchedBranch(module, newMatchedBranchName)
} else {
val project = findProject(configScopeId) ?: return
getService(project, SonarProjectBranchCache::class.java).setMatchedBranch(project, newMatchedBranchName)
}
}
override fun listFiles(configScopeId: String): List<ClientFileDto> {
val project = findModule(configScopeId)?.project ?: findProject(configScopeId)
val timeStart = System.currentTimeMillis()
val listClientFiles = findModule(configScopeId)?.let { module ->
listModuleFiles(module, configScopeId)
} ?: project?.let { foundProject ->
val listProjectFiles = listProjectFiles(foundProject, configScopeId)
computeSharedConfiguration(foundProject, configScopeId)?.let { listProjectFiles.add(it) }
listProjectFiles
}
?: emptyList()
val timeEnd = System.currentTimeMillis()
if (project != null) {
SonarLintConsole.get(project).debug("Listed ${listClientFiles.size} files for $configScopeId in ${(timeEnd - timeStart)} ms")
} else {
GlobalLogOutput.get().log(
"Listed ${listClientFiles.size} files for $configScopeId in ${(timeEnd - timeStart)} ms",
ClientLogOutput.Level.DEBUG
)
}
return listClientFiles
}
private fun computeSharedConfiguration(project: Project, configScopeId: String): ClientFileDto? {
val sonarlintFolder = findSharedFolder(project) ?: return null
return findConnectedModeFile(sonarlintFolder, project, configScopeId)
}
private fun listModuleFiles(module: Module, configScopeId: String): List<ClientFileDto> {
val filesInContentRoots = visitAndAddAllFilesForModule(module)
FilesContributor.EP_NAME.extensionList.forEach {
filesInContentRoots.addAll(it.listFiles(module))
}
val forcedLanguages = collectContributedLanguages(module, filesInContentRoots)
val clientFiles = filesInContentRoots.mapNotNull { file ->
val forcedLanguage = forcedLanguages[file]?.let { fl -> Language.valueOf(fl.name) }
getRelativePathForAnalysis(module, file)?.let { relativePath ->
toClientFileDto(
module.project,
configScopeId,
file,
relativePath,
forcedLanguage
)
}
}.toMutableList()
if (isRider()) {
computeSharedConfiguration(module.project, configScopeId)?.let {
clientFiles.add(it)
}
}
return clientFiles
}
private fun listProjectFiles(project: Project, configScopeId: String): MutableList<ClientFileDto> {
return listFilesInProjectBaseDir(project).mapNotNull { file ->
getRelativePathForAnalysis(project, file)?.let { relativePath ->
toClientFileDto(
project,
configScopeId,
file,
relativePath,
null
)
}
}.toMutableList()
}
// useful for Rider where the files to find are not located in content roots
private fun listFilesInProjectBaseDir(project: Project): Set<VirtualFile> {
return project.guessProjectDir()?.children?.filter {
!it.isDirectory && isFileValidForSonarLintWithExtensiveChecks(it, project)
}?.toSet() ?: return emptySet()
}
@JvmOverloads
fun toClientFileDto(
project: Project,
configScopeId: String,
file: VirtualFile,
relativePath: String,
language: Language?,
includeFileContent: Boolean = false,
): ClientFileDto? {
if (!file.isValid || FileUtilRt.isTooLarge(file.length)) return null
val uri = VirtualFileUtils.toURI(file) ?: return null
return try {
computeReadActionSafely(file, project) {
ClientFileDto(
uri,
Paths.get(relativePath),
configScopeId,
isTestSources(file, project),
VirtualFileUtils.getEncoding(file, project),
Paths.get(file.path),
readFileContentIfNeeded(file, includeFileContent),
language,
true
)
}
} catch (e: IOException) {
SonarLintConsole.get(project).error("Error while computing ClientFileDto", e)
null
}
}
private fun readFileContentIfNeeded(file: VirtualFile, includeFileContent: Boolean): String? {
val shouldReadContent = includeFileContent
|| file.name == SONAR_SCANNER_CONFIG_FILENAME
|| file.name == AUTOSCAN_CONFIG_FILENAME
|| file.parent?.name == SONARLINT_CONFIGURATION_FOLDER
// Notebooks require special parsing, we should always send the content
|| file.extension == "ipynb"
if (!shouldReadContent || FileUtilRt.isTooLarge(file.length)) return null
return getFileContent(file)
}
override fun didChangeTaintVulnerabilities(
configurationScopeId: String, closedTaintVulnerabilityIds: Set<UUID>, addedTaintVulnerabilities: List<TaintVulnerabilityDto>,
updatedTaintVulnerabilities: List<TaintVulnerabilityDto>,
) {
val project = findProject(configurationScopeId) ?: return
val taintVulnerabilityMatcher = TaintVulnerabilityMatcher(project)
val (locallyMatchedAddedTaintVulnerabilities, locallyMatchedUpdatedTaintVulnerabilities) = computeReadActionSafely(project) {
addedTaintVulnerabilities.map { taintVulnerabilityMatcher.match(it) } to updatedTaintVulnerabilities.map { taintVulnerabilityMatcher.match(it) }
} ?: return
getService(project, TaintVulnerabilitiesCache::class.java)
.update(closedTaintVulnerabilityIds, locallyMatchedAddedTaintVulnerabilities, locallyMatchedUpdatedTaintVulnerabilities)
getService(project, OnTheFlyFindingsCoordinator::class.java).applyHighlightRefreshAndRefreshPanels(EditorHighlightRefresh.enabled())
}
override fun didChangeDependencyRisks(
configurationScopeId: String,
closedDependencyRiskIds: Set<UUID>,
addedDependencyRisks: List<DependencyRiskDto>,
updatedDependencyRisks: List<DependencyRiskDto>
) {
val project = findProject(configurationScopeId) ?: return
val added = addedDependencyRisks.map { LocalDependencyRisk(it) }
val updated = updatedDependencyRisks.map { LocalDependencyRisk(it) }
getService(project, DependencyRisksCache::class.java).update(closedDependencyRiskIds, added, updated)
getService(project, OnTheFlyFindingsCoordinator::class.java).applyHighlightRefreshAndRefreshPanels(EditorHighlightRefresh.enabled())
}
override fun raiseIssues(
configurationScopeId: String,
issuesByFileUri: Map<URI, List<RaisedIssueDto>>,
isIntermediatePublication: Boolean,
analysisId: UUID?,
) {
val module = findModule(configurationScopeId)
val project = module?.project ?: BackendService.findProject(configurationScopeId) ?: return
val runningAnalysis = analysisId?.let { getService(project, RunningAnalysesTracker::class.java).getById(it) }
getService(project, NewCodePeriodCache::class.java).refreshAsync()
if (runningAnalysis != null) {
runningAnalysis.addRawIssues(analysisId, issuesByFileUri, isIntermediatePublication)
} else if (module != null) {
val onTheFlyFindingsHolder = getService(project, AnalysisSubmitter::class.java).onTheFlyFindingsHolder
onTheFlyFindingsHolder.updateViewsWithNewIssues(module, issuesByFileUri, isIntermediatePublication)
}
}
override fun raiseHotspots(
configurationScopeId: String,
hotspotsByFileUri: Map<URI, List<RaisedHotspotDto>>,
isIntermediatePublication: Boolean,
analysisId: UUID?,
) {
val module = findModule(configurationScopeId)
val project = module?.project ?: BackendService.findProject(configurationScopeId) ?: return
val runningAnalysis = analysisId?.let { getService(project, RunningAnalysesTracker::class.java).getById(it) }
getService(project, NewCodePeriodCache::class.java).refreshAsync()
if (runningAnalysis != null) {
runningAnalysis.addRawHotspots(analysisId, hotspotsByFileUri, isIntermediatePublication)
} else if (module != null) {
val onTheFlyFindingsHolder = getService(project, AnalysisSubmitter::class.java).onTheFlyFindingsHolder
onTheFlyFindingsHolder.updateViewsWithNewSecurityHotspots(module, hotspotsByFileUri, isIntermediatePublication)
}
}
override fun didSkipLoadingPlugin(
configurationScopeId: String, language: Language, reason: DidSkipLoadingPluginParams.SkipReason,
minVersion: String, currentVersion: String?,
) {
val project = findModule(configurationScopeId)?.project
?: BackendService.findProject(configurationScopeId) ?: return
notifyOnceForSkippedPlugins(project, language, reason, minVersion, currentVersion)
}
override fun didDetectSecret(configurationScopeId: String) {
val project = findModule(configurationScopeId)?.project
?: BackendService.findProject(configurationScopeId) ?: return
if (getGlobalSettings().isSecretsNeverBeenAnalysed) {
get(project).sendNotification()
getGlobalSettings().rememberNotificationOnSecretsBeenSent()