intellij-lsp/intellij-lsp-plugin

View on GitHub
src/main/scala/com/github/gtache/lsp/requests/HoverHandler.scala

Summary

Maintainability
B
4 hrs
Test Coverage
F
0%

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

    If block needs braces
    Open

        if (hover != null && hover.getContents != null) {

    If block needs braces
    Open

                if (c.isLeft) c.getLeft else if (c.isRight) {

    If block needs braces
    Open

                  val string = if (markedString.getLanguage != null && !markedString.getLanguage.isEmpty)

    Avoid wildcard imports
    Open

        import scala.collection.JavaConverters._

    Imports should be grouped together
    Open

        import scala.collection.JavaConverters._

    If block needs braces
    Open

          } else if (hoverContents.isRight) {

    Cyclomatic complexity of 13 exceeds max of 10
    Open

      def getHoverString(@NonNull hover: Hover): String = {

    There are no issues that match your filters.

    Category
    Status