intellij-lsp/intellij-lsp-plugin

View on GitHub

Showing 87 of 774 total issues

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

Avoid deeply nested control flow statements.
Open

              val oldTextLength = if (oldLines.isEmpty) 0 else oldLines.last.length
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 (syncOptions != null) {
                    if (syncOptions.isRight) syncKind = syncOptions.getRight.getChange
                    else if (syncOptions.isLeft) syncKind = syncOptions.getLeft
                    val mouseListener = new EditorMouseListenerImpl
                    val mouseMotionListener = new EditorMouseMotionListenerImpl

      Avoid deeply nested control flow statements.
      Open

                    val column = if (oldLines.length == 1) startColumn + oldTextLength else oldTextLength
      Severity: Major
      Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 45 mins to fix

        Function replace has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          def replace[T](key: Key[T], @Nullable oldValue: T, @Nullable newValue: T): Boolean = {
            while (true) {
              val map = getUserMap
              if (map.get(key) != oldValue) {
                return false

        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

        Avoid deeply nested control flow statements.
        Open

                          if (currentHint != null) currentHint.hide()
        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

                        invokeLater(() => if (!editor.isDisposed) currentHint = createAndShowEditorHint(editor, string, point, flags = HintManager.HIDE_BY_OTHER_HINT))
          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

                          val syncOptions: Either[TextDocumentSyncKind, TextDocumentSyncOptions] = if (capabilities == null) null else capabilities.getTextDocumentSync

              Consider simplifying this complex logical expression.
              Open

                              if (curTime - predTime > HOVER_TIME_THRES && mouseInEditor && editor.getContentComponent.hasFocus && (!isKeyPressed || isCtrlDown)) {
                                val editorOffset = computableReadAction[Int](() => editor.logicalPositionToOffset(editorPos))
                                val inHighlights = diagnosticsHighlights.filter(diag =>
                                  diag.rangeHighlighter.getStartOffset <= editorOffset &&
                                    editorOffset <= diag.rangeHighlighter.getEndOffset)
              Severity: Major
              Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 40 mins to fix

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

                case class LSPPsiElement(var name: String, project: Project, start: Int, end: Int, file: PsiFile) extends PsiNameIdentifierOwner with NavigatablePsiElement {

                  Method workspaceSymbols has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    def workspaceSymbols(name: String, pattern: String, project: Project, includeNonProjectItems: Boolean = false, onlyKind: Set[SymbolKind] = Set()): Array[NavigationItem] = {
                  Severity: Minor
                  Found in src/main/scala/com/github/gtache/lsp/PluginMain.scala - About 35 mins to fix

                    Method applyEdit has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def applyEdit(elem: PsiElement, newName: String, infos: Array[UsageInfo], listener: RefactoringElementListener, openedEditors: Iterable[VirtualFile]): Unit = {
                    Severity: Minor
                    Found in src/main/scala/com/github/gtache/lsp/requests/WorkspaceEditHandler.scala - About 35 mins to fix

                      Method createAndShowEditorHint has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        def createAndShowEditorHint(editor: Editor, string: String, point: Point, constraint: Short = HintManager.ABOVE,
                                                    flags: Int = HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING): Hint = {
                      Severity: Minor
                      Found in src/main/scala/com/github/gtache/lsp/utils/GUIUtils.scala - About 35 mins to fix

                        Function maySaveDocument has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                          override def maySaveDocument(document: Document, isSaveExplicit: Boolean): Boolean = {
                            EditorEventManager.forUri(FileUtils.documentToUri(document)) match {
                              case Some(m) =>
                                if (m.needSave) {
                                  m.needSave = false

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

                          override def crashed(e: Exception): Unit = {
                            crashCount += 1
                            if (crashCount < 2) {
                              val editors = connectedEditors.clone().toMap.keys
                              stop()

                        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 createCtrlRange has a Cognitive Complexity of 6 (exceeds 5 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) {
                        Severity: Minor
                        Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 25 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 fromArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                          override def fromArray(arr: Array[String]): ExeLanguageServerDefinition = {
                            if (arr.head == typ) {
                              val arrTail = arr.tail
                              if (arrTail.length < 2) {
                                LOG.warn("Not enough elements to translate into a ServerDefinition : " + arr)

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

                          private def requestDefinition(position: Position): Location = {
                            val params = new TextDocumentPositionParams(identifier, position)
                            val request = requestManager.definition(params)
                            if (request != null) {
                              try {
                        Severity: Minor
                        Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 25 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 fromArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                          override def fromArray(arr: Array[String]): CommandServerDefinition = {
                            if (arr.head == typ) {
                              val arrTail = arr.tail
                              if (arrTail.length > 1) {
                                RawCommandServerDefinition(arrTail.head, arrTail.tail)

                        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 documentReferences has a Cognitive Complexity of 6 (exceeds 5 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)
                        Severity: Minor
                        Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 25 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

                        Severity
                        Category
                        Status
                        Source
                        Language