tomchentw/medium-editor-tc-mention

View on GitHub
src/index.js

Summary

Maintainability
C
1 day
Test Coverage

Function hidePanel has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  hidePanel(isArrowTowardsLeft) {
    this.mentionPanel.classList.remove(`medium-editor-mention-panel-active`);
    const extraActivePanelClassName = this.extraActivePanelClassName || this.extraActiveClassName;

    if (extraActivePanelClassName) {
Severity: Minor
Found in src/index.js - 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

File index.js has 267 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  default as MediumEditor,
} from "medium-editor";

function last(text) {
Severity: Minor
Found in src/index.js - About 2 hrs to fix

    Function hidePanel has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      hidePanel(isArrowTowardsLeft) {
        this.mentionPanel.classList.remove(`medium-editor-mention-panel-active`);
        const extraActivePanelClassName = this.extraActivePanelClassName || this.extraActiveClassName;
    
        if (extraActivePanelClassName) {
    Severity: Minor
    Found in src/index.js - About 1 hr to fix

      Function wrapWordInMentionAt has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        wrapWordInMentionAt() {
          const selection = this.document.getSelection();
          if (!selection.rangeCount) {
            return;
          }
      Severity: Minor
      Found in src/index.js - About 1 hr to fix

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

          getWordFromSelection(target, initialDiff) {
            const {
              startContainer,
              startOffset,
              endContainer,
        Severity: Minor
        Found in src/index.js - About 1 hr to fix

          Function getWordFromSelection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            getWordFromSelection(target, initialDiff) {
              const {
                startContainer,
                startOffset,
                endContainer,
          Severity: Minor
          Found in src/index.js - 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 wrapWordInMentionAt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            wrapWordInMentionAt() {
              const selection = this.document.getSelection();
              if (!selection.rangeCount) {
                return;
              }
          Severity: Minor
          Found in src/index.js - 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

          Unexpected if as the only statement in an else block.
          Open

                  if (textNode.textContent.length === 0 && firstChild.textContent.length > 1) {
          Severity: Minor
          Found in src/index.js by eslint

          disallow if statements as the only statement in else blocks (no-lonely-if)

          If an if statement is the only statement in the else block, it is often clearer to use an else if form.

          if (foo) {
              // ...
          } else {
              if (bar) {
                  // ...
              }
          }

          should be rewritten as

          if (foo) {
              // ...
          } else if (bar) {
              // ...
          }

          Rule Details

          This rule disallows if statements as the only statement in else blocks.

          Examples of incorrect code for this rule:

          /*eslint no-lonely-if: "error"*/
          
          if (condition) {
              // ...
          } else {
              if (anotherCondition) {
                  // ...
              }
          }
          
          if (condition) {
              // ...
          } else {
              if (anotherCondition) {
                  // ...
              } else {
                  // ...
              }
          }

          Examples of correct code for this rule:

          /*eslint no-lonely-if: "error"*/
          
          if (condition) {
              // ...
          } else if (anotherCondition) {
              // ...
          }
          
          if (condition) {
              // ...
          } else if (anotherCondition) {
              // ...
          } else {
              // ...
          }
          
          if (condition) {
              // ...
          } else {
              if (anotherCondition) {
                  // ...
              }
              doSomething();
          }

          When Not To Use It

          Disable this rule if the code is clearer without requiring the else if form. Source: http://eslint.org/docs/rules/

          Use default import syntax to import 'MediumEditor'.
          Open

            default as MediumEditor,
          Severity: Minor
          Found in src/index.js by eslint

          For more information visit Source: http://eslint.org/docs/rules/

          There are no issues that match your filters.

          Category
          Status