wahanegi/vibereport

View on GitHub
app/javascript/components/UI/rich-text/cursor.js

Summary

Maintainability
D
1 day
Test Coverage

Function getCurrentCursorPosition has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

    static getCurrentCursorPosition(parentElement, initCoord = {x: 0, y: 0}) {
        if(window.getSelection()) {
            const selection = window.getSelection()
            let charCount = -1
            let focusNode = null
Severity: Minor
Found in app/javascript/components/UI/rich-text/cursor.js - About 7 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 _createRange has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    static _createRange(node, chars, range) {
        if (!range) {
            range = document.createRange()
            range.selectNode(node);
            range.setStart(node, 0);
Severity: Minor
Found in app/javascript/components/UI/rich-text/cursor.js - 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 getCurrentCursorPosition has 60 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    static getCurrentCursorPosition(parentElement, initCoord = {x: 0, y: 0}) {
        if(window.getSelection()) {
            const selection = window.getSelection()
            let charCount = -1
            let focusNode = null
Severity: Major
Found in app/javascript/components/UI/rich-text/cursor.js - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                            if (node === parentElement) {
                                break;
                            }
    Severity: Major
    Found in app/javascript/components/UI/rich-text/cursor.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if (node.previousSibling) {
                                  node = node.previousSibling;
                                  charCount += node.textContent.length;
                                  realPos +=
                                      (node.outerHTML === undefined ? RichText.encodeSpace(RichText.decodeSpace160(node.textContent)) : node.outerHTML).length
      Severity: Major
      Found in app/javascript/components/UI/rich-text/cursor.js - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status