intellij-lsp/intellij-lsp-plugin

View on GitHub

Showing 774 of 774 total issues

Function start has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  override def start(): Unit = {
    val serverSocket = new ServerSocket(port)
    val socketThread = new Thread(() => {
      try
        socket = serverSocket.accept

    Function canProcessElement has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      override def canProcessElement(element: PsiElement): Boolean = {
        element match {
          case lsp: LSPPsiElement => true
          case file: PsiFile =>
            val editorO = FileEditorManager.getInstance(file.getProject).getAllEditors(file.getVirtualFile).collectFirst { case t: TextEditor => t.getEditor }

      Function applyEdit has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def applyEdit(elem: PsiElement, newName: String, infos: Array[UsageInfo], listener: RefactoringElementListener, openedEditors: Iterable[VirtualFile]): Unit = {
          val edits = mutable.Map[String, mutable.ListBuffer[TextEdit]]()
          elem match {
            case lspElem: LSPPsiElement =>
              if (infos.forall(info => info.getElement.isInstanceOf[LSPPsiElement])) {

        Constructor has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        class EditorEventManager(val editor: Editor, val mouseListener: EditorMouseListener, val mouseMotionListener: EditorMouseMotionListener,
                                 val documentListener: DocumentListener, val selectionListener: SelectionListener,
                                 val requestManager: RequestManager, val serverOptions: ServerOptions, val wrapper: LanguageServerWrapperImpl) {

          Function references has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def references(offset: Int, getOriginalElement: Boolean = false, close: Boolean = false): (Iterable[PsiElement], Iterable[VirtualFile]) = {
              val lspPos = DocumentUtils.offsetToLSPPos(editor, offset)
              val params = new ReferenceParams(new ReferenceContext(getOriginalElement))
              params.setPosition(lspPos)
              params.setTextDocument(identifier)
          Severity: Minor
          Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 55 mins to fix

          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 actionPerformed has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            override def actionPerformed(e: AnActionEvent): Unit = {
              val editor = e.getData(CommonDataKeys.EDITOR)
              val project = e.getData(CommonDataKeys.PROJECT)
              if (editor != null) {
                val file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument)

          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 canProcessElement has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            override def canProcessElement(element: PsiElement): Boolean = {
              element match {
                case lsp: LSPPsiElement => true
                case file: PsiFile =>
                  val editorO = FileEditorManager.getInstance(file.getProject).getAllEditors(file.getVirtualFile).collectFirst { case t: TextEditor => t.getEditor }

          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

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

            override def completionItemResolve(unresolved: CompletionItem): CompletableFuture[CompletionItem] =
              if (checkStatus) try {
                if (serverCapabilities.getCompletionProvider != null && serverCapabilities.getCompletionProvider.getResolveProvider) textDocumentService.resolveCompletionItem(unresolved) else null
              } catch {
                case e: Exception => crashed(e)
          src/main/scala/com/github/gtache/lsp/client/languageserver/requestmanager/SimpleRequestManager.scala on lines 276..282
          src/main/scala/com/github/gtache/lsp/client/languageserver/requestmanager/SimpleRequestManager.scala on lines 292..298

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 84.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

            override def resolveCodeLens(unresolved: CodeLens): CompletableFuture[CodeLens] =
              if (checkStatus) try {
                if (serverCapabilities.getCodeLensProvider != null && serverCapabilities.getCodeLensProvider.isResolveProvider) textDocumentService.resolveCodeLens(unresolved) else null
              } catch {
                case e: Exception => crashed(e)
          src/main/scala/com/github/gtache/lsp/client/languageserver/requestmanager/SimpleRequestManager.scala on lines 173..179
          src/main/scala/com/github/gtache/lsp/client/languageserver/requestmanager/SimpleRequestManager.scala on lines 292..298

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 84.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

            override def documentLinkResolve(unresolved: DocumentLink): CompletableFuture[DocumentLink] =
              if (checkStatus) try {
                if (serverCapabilities.getDocumentLinkProvider != null && serverCapabilities.getDocumentLinkProvider.getResolveProvider) textDocumentService.documentLinkResolve(unresolved) else null
              } catch {
                case e: Exception => crashed(e)
          src/main/scala/com/github/gtache/lsp/client/languageserver/requestmanager/SimpleRequestManager.scala on lines 173..179
          src/main/scala/com/github/gtache/lsp/client/languageserver/requestmanager/SimpleRequestManager.scala on lines 276..282

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 84.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          /**
           *     Copyright 2017-2018 Guillaume Tâche
           *
           *     Licensed under the Apache License, Version 2.0 (the "License");
           *     you may not use this file except in compliance with the License.
          src/main/scala/com/github/gtache/lsp/editor/listeners/DocumentListenerImpl.scala on lines 1..46

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 83.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          /**
           *     Copyright 2017-2018 Guillaume Tâche
           *
           *     Licensed under the Apache License, Version 2.0 (the "License");
           *     you may not use this file except in compliance with the License.
          src/main/scala/com/github/gtache/lsp/editor/listeners/EditorMouseMotionListenerImpl.scala on lines 1..34

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 83.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Constructor has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          case class LSPNavigationItem(name: String, container: String, project: Project, file: VirtualFile, line: Int, col: Int, icon: Icon = null) extends OpenFileDescriptor(project, file, line, col) with NavigationItem {

            Constructor has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            case class ServerOptions(syncKind: TextDocumentSyncKind, completionOptions: CompletionOptions, signatureHelpOptions: SignatureHelpOptions, codeLensOptions: CodeLensOptions, documentOnTypeFormattingOptions: DocumentOnTypeFormattingOptions, documentLinkOptions: DocumentLinkOptions, executeCommandOptions: ExecuteCommandOptions) {

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                override def onTypeFormatting(params: DocumentOnTypeFormattingParams): CompletableFuture[java.util.List[_ <: TextEdit]] =
                  if (checkStatus) try {
                    if (serverCapabilities.getDocumentOnTypeFormattingProvider != null) textDocumentService.onTypeFormatting(params) else null
                  } catch {
                    case e: Exception => crashed(e)
              src/main/scala/com/github/gtache/lsp/client/languageserver/requestmanager/SimpleRequestManager.scala on lines 268..274

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 81.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                override def codeLens(params: CodeLensParams): CompletableFuture[java.util.List[_ <: CodeLens]] =
                  if (checkStatus) try {
                    if (serverCapabilities.getCodeLensProvider != null) textDocumentService.codeLens(params) else null
                  } catch {
                    case e: Exception => crashed(e)
              src/main/scala/com/github/gtache/lsp/client/languageserver/requestmanager/SimpleRequestManager.scala on lines 244..250

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 81.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                override def didSave(params: DidSaveTextDocumentParams): Unit =
                  if (checkStatus) try {
                    if (textDocumentOptions == null || textDocumentOptions.getSave != null) textDocumentService.didSave(params)
                  } catch {
                    case e: Exception => crashed(e)
              src/main/scala/com/github/gtache/lsp/client/languageserver/requestmanager/SimpleRequestManager.scala on lines 129..134

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 76.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                override def didChange(params: DidChangeTextDocumentParams): Unit =
                  if (checkStatus) try {
                    if (textDocumentOptions == null || textDocumentOptions.getChange != null) textDocumentService.didChange(params)
                  } catch {
                    case e: Exception => crashed(e)
              src/main/scala/com/github/gtache/lsp/client/languageserver/requestmanager/SimpleRequestManager.scala on lines 151..156

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 76.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Avoid deeply nested control flow statements.
              Open

                                if (ctrlRange != null) ctrlRange.dispose()
              Severity: Major
              Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                              if (highlights != null) {
                                wrapper.notifySuccess(Timeouts.DOC_HIGHLIGHT)
                                val offset = DocumentUtils.LSPPosToOffset(editor, serverPos)
                                highlights.asScala.find(dh => DocumentUtils.LSPPosToOffset(editor, dh.getRange.getStart) <= offset
                                  && offset <= DocumentUtils.LSPPosToOffset(editor, dh.getRange.getEnd)).fold(new Range(serverPos, serverPos))(dh => dh.getRange)
                Severity: Major
                Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 45 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language