intellij-lsp/intellij-lsp-plugin

View on GitHub

Showing 774 of 774 total issues

File EditorEventManager.scala has 1164 lines of code (exceeds 250 allowed). 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.
Severity: Major
Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 2 days to fix

    Function mouseMoved has a Cognitive Complexity of 68 (exceeds 5 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) {
    Severity: Minor
    Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 1 day 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

    EditorEventManager has 46 methods (exceeds 20 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) {
    
      import EditorEventManager._
    Severity: Minor
    Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 6 hrs to fix

      Function completion has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

        def completion(pos: Position): Iterable[_ <: LookupElement] = {
          val request = requestManager.completion(new CompletionParams(identifier, pos))
          if (request != null) {
            try {
              val res = request.get(COMPLETION_TIMEOUT, TimeUnit.MILLISECONDS)
      Severity: Minor
      Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 6 hrs 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 completion has 88 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def completion(pos: Position): Iterable[_ <: LookupElement] = {
          val request = requestManager.completion(new CompletionParams(identifier, pos))
          if (request != null) {
            try {
              val res = request.get(COMPLETION_TIMEOUT, TimeUnit.MILLISECONDS)
      Severity: Major
      Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 3 hrs to fix

        File LanguageServerWrapperImpl.scala has 310 lines of code (exceeds 250 allowed). 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.

          Function createLookupItem has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

                    def createLookupItem(item: CompletionItem): LookupElement = {
                      val addTextEdits = item.getAdditionalTextEdits
                      val command = item.getCommand
                      val data = item.getData
                      val detail = item.getDetail
          Severity: Minor
          Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 3 hrs 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 getHoverString has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

            def getHoverString(@NonNull hover: Hover): String = {
              import scala.collection.JavaConverters._
              if (hover != null && hover.getContents != null) {
                val hoverContents = hover.getContents
                if (hoverContents.isLeft) {
          Severity: Minor
          Found in src/main/scala/com/github/gtache/lsp/requests/HoverHandler.scala - About 3 hrs 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 applyEdit has 73 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def applyEdit(edit: WorkspaceEdit, name: String = "LSP edits", toClose: Iterable[VirtualFile] = Seq()): Boolean = {
              import scala.collection.JavaConverters._
              if (edit != null) {
                val changes = if (edit.getChanges != null) edit.getChanges.asScala else null
                val dChanges = if (edit.getDocumentChanges != null) edit.getDocumentChanges.asScala else null

            Function requestAndShowDoc has a Cognitive Complexity of 19 (exceeds 5 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 {
            Severity: Minor
            Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 2 hrs 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 showReferences has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private def showReferences(references: Iterable[Location]): Unit = {
                var name: String = ""
            
                /**
                  * Opens the editor and get the required infos
            Severity: Major
            Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 2 hrs to fix

              Function doRename has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                def doRename(elementToRename: PsiElement, editor: Editor, dataContext: DataContext): InplaceRefactoring = {
                  elementToRename match {
                    case owner: PsiNameIdentifierOwner =>
                      val processor = RenamePsiElementProcessor.forElement(elementToRename)
                      if (processor.isInplaceRenameSupported) {

              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

              File ServersGUI.java has 265 lines of code (exceeds 250 allowed). 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.
              Severity: Minor
              Found in src/main/scala/com/github/gtache/lsp/settings/gui/ServersGUI.java - About 2 hrs to fix

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

                  def start(): Unit = {
                    if (status == STOPPED && !alreadyShownCrash && !alreadyShownTimeout) {
                      setStatus(STARTING)
                      try {
                        val (inputStream, outputStream) = serverDefinition.start(rootPath)

                  Function sanitizeURI has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def sanitizeURI(uri: String): String = {
                      val reconstructed: StringBuilder = StringBuilder.newBuilder
                      var uriCp = new String(uri).replace(" ", SPACE_ENCODED) //Don't trust servers
                      if (!uri.startsWith(URI_FILE_BEGIN)) {
                        LOG.warn("Malformed uri : " + uri)
                  Severity: Minor
                  Found in src/main/scala/com/github/gtache/lsp/utils/FileUtils.scala - About 1 hr 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

                  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/settings/MiscSettings.java on lines 1..79

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

                  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/settings/TimeoutSettings.java on lines 1..84

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

                  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 references has 47 lines of code (exceeds 25 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)

                    Function showReferencesWindow has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      private def showReferencesWindow(locations: Array[(String, Int, Int, String)], name: String, point: Point): Unit = {
                        if (locations.isEmpty) {
                          invokeLater(() => if (!editor.isDisposed) currentHint = createAndShowEditorHint(editor, "No usages found", point))
                        } else {
                          val frame = new JFrame()

                      Function getServerCapabilities has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                      Open

                        @Nullable def getServerCapabilities: ServerCapabilities = {
                          if (this.initializeResult != null) this.initializeResult.getCapabilities else {
                            try {
                              start()
                              if (this.initializeFuture != null) this.initializeFuture.get(if (capabilitiesAlreadyRequested) 0 else Timeout.INIT_TIMEOUT, TimeUnit.MILLISECONDS)

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language