intellij-lsp/intellij-lsp-plugin

View on GitHub

Showing 87 of 774 total issues

Function connect has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def connect(editor: Editor): Unit = {
    val uri = FileUtils.editorToURIString(editor)
    if (!this.connectedEditors.contains(uri)) {
      start()
      if (this.initializeFuture != null && editor != null) {

    Function signatureHelp has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def signatureHelp(): Unit = {
        val lPos = editor.getCaretModel.getCurrentCaret.getLogicalPosition
        val point = editor.logicalPositionToXY(lPos)
        val params = new TextDocumentPositionParams(identifier, DocumentUtils.logicalToLSPPos(lPos, editor))
        pool(() => {

      Function mouseMoved has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def mouseMoved(e: EditorMouseEvent): Unit = {
          if (e.getEditor == editor) {
            val language = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument).getLanguage
            if ((EditorSettingsExternalizable.getInstance().isShowQuickDocOnMouseOverElement && //Fixes double doc if documentation provider is present
              (LanguageDocumentation.INSTANCE.allForLanguage(language).isEmpty || language.equals(PlainTextLanguage.INSTANCE))) || isCtrlDown) {

        Function workspaceSymbols has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def workspaceSymbols(name: String, pattern: String, project: Project, includeNonProjectItems: Boolean = false, onlyKind: Set[SymbolKind] = Set()): Array[NavigationItem] = {
            projectToLanguageWrappers.get(FileUtils.pathToUri(project.getBasePath)) match {
              case Some(set) =>
                val params: WorkspaceSymbolParams = new WorkspaceSymbolParams(name)
                val servDefToReq = set.collect {
        Severity: Minor
        Found in src/main/scala/com/github/gtache/lsp/PluginMain.scala - About 1 hr to fix

          Function documentChanged has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def documentChanged(event: DocumentEvent): Unit = {
              if (!editor.isDisposed) {
                if (event.getDocument == editor.getDocument) {
                  predTime = System.nanoTime() //So that there are no hover events while typing
                  changesParams.getTextDocument.setVersion({

            Function createCtrlRange has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private def createCtrlRange(serverPos: Position, range: Range): Unit = {
                val loc = requestDefinition(serverPos)
                if (loc != null) {
                  if (!editor.isDisposed) {
                    val corRange = if (range == null) {

              Function requestDoc has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                def requestDoc(editor: Editor, offset: Int): String = {
                  if (editor == this.editor) {
                    if (offset != -1) {
                      val serverPos = DocumentUtils.offsetToLSPPos(editor, offset)
                      val request = requestManager.hover(new TextDocumentPositionParams(identifier, serverPos))

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function checkFile has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                override def checkFile(file: PsiFile, manager: InspectionManager, isOnTheFly: Boolean): Array[ProblemDescriptor] = {
                  val virtualFile = file.getVirtualFile
                  if (PluginMain.isExtensionSupported(virtualFile.getExtension)) {
                    val uri = FileUtils.VFSToURI(virtualFile)
              
              

                Function willSaveWaitUntil has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private def willSaveWaitUntil(): Unit = {
                    if (wrapper.isWillSaveWaitUntil) {
                      pool(() => {
                        if (!editor.isDisposed) {
                          val params = new WillSaveTextDocumentParams(identifier, TextDocumentSaveReason.Manual)

                  Function diagnostics has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def diagnostics(diagnostics: Iterable[Diagnostic]): Unit = {
                      pool(() => {
                        if (!editor.isDisposed) {
                          invokeLater(() => {
                            diagnosticsHighlights.foreach(highlight => editor.getMarkupModel.removeHighlighter(highlight.rangeHighlighter))

                    Function documentReferences has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def documentReferences(offset: Int): Iterable[(Int, Int)] = {
                        val params = new ReferenceParams()
                        val context = new ReferenceContext()
                        context.setIncludeDeclaration(true)
                        params.setContext(context)

                      Function checkFile has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                        override def checkFile(file: PsiFile, manager: InspectionManager, isOnTheFly: Boolean): Array[ProblemDescriptor] = {
                          val virtualFile = file.getVirtualFile
                          if (PluginMain.isExtensionSupported(virtualFile.getExtension)) {
                            val uri = FileUtils.VFSToURI(virtualFile)
                      
                      

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Function connect has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                      Open

                        @throws[IOException]
                        def connect(editor: Editor): Unit = {
                          val uri = FileUtils.editorToURIString(editor)
                          if (!this.connectedEditors.contains(uri)) {
                            start()

                      Cognitive Complexity

                      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                      A method's cognitive complexity is based on a few simple rules:

                      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                      • Code is considered more complex for each "break in the linear flow of the code"
                      • Code is considered more complex when "flow breaking structures are nested"

                      Further reading

                      Function requestDoc has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def requestDoc(editor: Editor, offset: Int): String = {
                          if (editor == this.editor) {
                            if (offset != -1) {
                              val serverPos = DocumentUtils.offsetToLSPPos(editor, offset)
                              val request = requestManager.hover(new TextDocumentPositionParams(identifier, serverPos))

                        Function showReferences has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def showReferences(includeDefinition: Boolean = true): Unit = {
                            pool(() => {
                              if (!editor.isDisposed) {
                                val context = new ReferenceContext(includeDefinition)
                                val params = new ReferenceParams(context)

                          Function requestAndShowDoc has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            private def requestAndShowDoc(curTime: Long, editorPos: LogicalPosition, point: Point): Unit = {
                              val serverPos = computableReadAction[Position](() => DocumentUtils.logicalToLSPPos(editorPos, editor))
                              val request = requestManager.hover(new TextDocumentPositionParams(identifier, serverPos))
                              if (request != null) {
                                try {

                            Function executeCommands has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              def executeCommands(commands: Iterable[Command]): Unit = {
                                pool(() => {
                                  if (!editor.isDisposed) {
                                    commands.map(c => {
                                      val params = new ExecuteCommandParams()

                              Function getElementAtOffset has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def getElementAtOffset(offset: Int): LSPPsiElement = {
                                  computableReadAction(() => {
                                    if (!editor.isDisposed) {
                                      val params = new TextDocumentPositionParams(identifier, DocumentUtils.offsetToLSPPos(editor, offset))
                                      val future = requestManager.documentHighlight(params)

                                Function selectionChanged has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                Open

                                  def selectionChanged(e: SelectionEvent): Unit = {
                                    if (CodeInsightSettings.getInstance().HIGHLIGHT_IDENTIFIER_UNDER_CARET) {
                                      if (e.getEditor == editor) {
                                        selectedSymbHighlights.foreach(h => editor.getMarkupModel.removeHighlighter(h))
                                        selectedSymbHighlights.clear()

                                Cognitive Complexity

                                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                A method's cognitive complexity is based on a few simple rules:

                                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                • Code is considered more complex for each "break in the linear flow of the code"
                                • Code is considered more complex when "flow breaking structures are nested"

                                Further reading

                                Method createComboBox has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    private JComboBox<String> createComboBox(final JPanel panel, final String selected) {
                                        final JComboBox<String> typeBox = new ComboBox<>();
                                        final ConfigurableTypes[] types = ConfigurableTypes.values();
                                        for (final ConfigurableTypes type : types) {
                                            typeBox.addItem(type.getTyp());
                                Severity: Minor
                                Found in src/main/scala/com/github/gtache/lsp/settings/gui/ServersGUI.java - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language