intellij-lsp/intellij-lsp-plugin

View on GitHub

Showing 774 of 774 total issues

Function selectionChanged has 41 lines of code (exceeds 25 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()

    Function editorOpened has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def editorOpened(editor: Editor): Unit = {
        if (!loadedExtensions) {
          val extensions = LanguageServerDefinition.getAllDefinitions.filter(s => !extToServerDefinition.contains(s.ext))
          LOG.info("Added serverDefinitions " + extensions + " from plugins")
          extToServerDefinition = extToServerDefinition ++ extensions.map(s => (s.ext, s))
    Severity: Minor
    Found in src/main/scala/com/github/gtache/lsp/PluginMain.scala - About 1 hr to fix

      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))

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

                            fields.get(label).fold("") {
                              case t: JTextField => t.getText().trim
                              case tb: TextFieldWithBrowseButton => tb.getText.trim
                              case b: JComboBox[String@unchecked] => b.getSelectedItem.asInstanceOf[String]
                              case u: JComponent => LOG.error("Unknown JComponent : " + u)
                        src/main/scala/com/github/gtache/lsp/settings/gui/ServersGUIRow.scala on lines 57..63

                        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 111.

                        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

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

                            Array(typ) ++ fields.values.map {
                              case t: JTextField => t.getText().trim
                              case tb: TextFieldWithBrowseButton => tb.getText.trim
                              case b: JComboBox[String@unchecked] => b.getSelectedItem.asInstanceOf[String]
                              case u: JComponent => LOG.error("Unknown JComponent : " + u)
                        src/main/scala/com/github/gtache/lsp/settings/gui/ServersGUIRow.scala on lines 44..50

                        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 111.

                        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

                        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)

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

                                  EditorEventManager.forEditor(editor) match {
                                    case Some(manager) =>
                                      val renameTo = Messages.showInputDialog(editor.getProject, "Enter new name: ", "Rename", Messages.getQuestionIcon, "", new NonEmptyInputValidator())
                                      if (renameTo != null && renameTo != "") manager.rename(renameTo)
                                    case None =>
                              src/main/scala/com/github/gtache/lsp/actions/LSPRefactoringAction.scala on lines 32..37

                              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 102.

                              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

                              Severity
                              Category
                              Status
                              Source
                              Language