intellij-lsp/intellij-lsp-plugin

View on GitHub

Showing 87 of 774 total issues

Function scheduleDocumentation has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  private def scheduleDocumentation(time: Long, editorPos: LogicalPosition, point: Point): Unit = {
    if (editorPos != null) {
      if (time - predTime > SCHEDULE_THRES) {
        try {
          hoverThread.schedule(new TimerTask {

    Function getHoverString has 27 lines of code (exceeds 25 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 1 hr to fix

      Function getEditsRunnable has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def getEditsRunnable(version: Int = Int.MaxValue, edits: Iterable[TextEdit], name: String = "Apply LSP edits"): Runnable = {
          if (version >= this.version) {
            val document = editor.getDocument
            if (document.isWritable) {
              () => {

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

          def mouseClicked(e: EditorMouseEvent): Unit = {
            if (isCtrlDown) {
              if (ctrlRange == null)
                createCtrlRange(DocumentUtils.logicalToLSPPos(editor.xyToLogicalPosition(e.getMouseEvent.getPoint), editor), null)
              if (ctrlRange != null) {

          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

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

                      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

                          Avoid deeply nested control flow statements.
                          Open

                                        if (!editor.isDisposed) {
                                          try {
                                            val resp = request.get(DOC_HIGHLIGHT_TIMEOUT, TimeUnit.MILLISECONDS)
                                            wrapper.notifySuccess(Timeouts.DOC_HIGHLIGHT)
                                            if (resp != null) {
                          Severity: Major
                          Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 45 mins to fix

                            Method isModified has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                            Open

                                @Override
                                public boolean isModified() {
                                    if (serverDefinitions.size() == rows.stream().filter(row -> Arrays.stream(row.toStringArray()).skip(1).anyMatch(s -> s != null && !s.isEmpty())).collect(Collectors.toList()).size()) {
                                        for (final ServersGUIRow row : rows) {
                                            final UserConfigurableServerDefinition stateDef = serverDefinitions.get(row.getText(EXT));
                            Severity: Minor
                            Found in src/main/scala/com/github/gtache/lsp/settings/gui/ServersGUI.java - 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

                                                  if (command != null) executeCommands(Iterable(command))
                            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 (inHighlights.isEmpty || isCtrlDown) {
                                                  requestAndShowDoc(curTime, editorPos, point)
                                                }
                              Severity: Major
                              Found in src/main/scala/com/github/gtache/lsp/editor/EditorEventManager.scala - About 45 mins to fix

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

                                  override def findReferences(element: PsiElement, searchInCommentsAndStrings: Boolean): util.Collection[PsiReference] = {
                                    import scala.collection.JavaConverters._
                                    element match {
                                      case lsp: LSPPsiElement => if (elements.contains(lsp)) elements.map(e => e.getReference).asJava else {
                                        EditorEventManager.forEditor(FileUtils.editorFromPsiFile(lsp.getContainingFile)) match {

                                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