Showing 87 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.
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) {
- Read upRead up
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._
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)
- Read upRead up
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)
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
- Read upRead up
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) {
- Read upRead up
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 {
- Read upRead up
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
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) {
- Read upRead up
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.
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)
- Read upRead up
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 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)
- Read upRead up
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 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))
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()