lib/network/modules/components/shared/LabelSplitter.js

Summary

Maintainability
F
5 days
Test Coverage

Function splitMarkdownBlocks has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

  splitMarkdownBlocks(text) {
    let blocks = [];

    // TODO: consolidate following + methods/closures with splitHtmlBlocks()
    // NOTE: sequences of tabs and spaces are reduced to single space; scan usage of `this.spacing` within method
Severity: Minor
Found in lib/network/modules/components/shared/LabelSplitter.js - About 1 day 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 splitHtmlBlocks has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

  splitHtmlBlocks(text) {
    let blocks = [];

    // TODO: consolidate following + methods/closures with splitMarkdownBlocks()
    // NOTE: sequences of tabs and spaces are reduced to single space; scan usage of `this.spacing` within method
Severity: Minor
Found in lib/network/modules/components/shared/LabelSplitter.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

File LabelSplitter.js has 365 lines of code (exceeds 250 allowed). Consider refactoring.
Open

let LabelAccumulator = require('./LabelAccumulator').default;
let ComponentUtil = require('./ComponentUtil').default;


/**
Severity: Minor
Found in lib/network/modules/components/shared/LabelSplitter.js - About 4 hrs to fix

    Function process has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

      process(text) {
        if (!ComponentUtil.isValidLabel(text)) {
          return this.lines.finalize();
        }
    
    
    Severity: Minor
    Found in lib/network/modules/components/shared/LabelSplitter.js - About 4 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 splitMarkdownBlocks has 113 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      splitMarkdownBlocks(text) {
        let blocks = [];
    
        // TODO: consolidate following + methods/closures with splitHtmlBlocks()
        // NOTE: sequences of tabs and spaces are reduced to single space; scan usage of `this.spacing` within method
    Severity: Major
    Found in lib/network/modules/components/shared/LabelSplitter.js - About 4 hrs to fix

      Function splitHtmlBlocks has 109 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        splitHtmlBlocks(text) {
          let blocks = [];
      
          // TODO: consolidate following + methods/closures with splitMarkdownBlocks()
          // NOTE: sequences of tabs and spaces are reduced to single space; scan usage of `this.spacing` within method
      Severity: Major
      Found in lib/network/modules/components/shared/LabelSplitter.js - About 4 hrs to fix

        Function process has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          process(text) {
            if (!ComponentUtil.isValidLabel(text)) {
              return this.lines.finalize();
            }
        
        
        Severity: Minor
        Found in lib/network/modules/components/shared/LabelSplitter.js - About 1 hr to fix

          Function splitStringIntoLines has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            splitStringIntoLines(str, mod = 'normal', appendLast = false) {
              // Still-present spaces are relevant, retain them
              str = str.replace(/^( +)/g, '$1\r');
              str = str.replace(/([^\r][^ ]*)( +)/g, '$1\r$2\r');
              let words = str.split('\r');
          Severity: Minor
          Found in lib/network/modules/components/shared/LabelSplitter.js - About 1 hr 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 splitStringIntoLines has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            splitStringIntoLines(str, mod = 'normal', appendLast = false) {
              // Still-present spaces are relevant, retain them
              str = str.replace(/^( +)/g, '$1\r');
              str = str.replace(/([^\r][^ ]*)( +)/g, '$1\r$2\r');
              let words = str.split('\r');
          Severity: Minor
          Found in lib/network/modules/components/shared/LabelSplitter.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                    if (/</.test(text.substr(s.position,4))) {
                      s.add("<");
                      s.position += 3;
                    } else if (/&amp;/.test(text.substr(s.position,5))) {
                      s.add("&");
            Severity: Major
            Found in lib/network/modules/components/shared/LabelSplitter.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                    } else if (!s.mono && (s.mod() === "ital") && /\_/.test(ch)) {
                      if ((s.position === text.length-1) || /[.,*` \t\n]/.test(text.charAt(s.position+1))) {
                        s.emitBlock();
                        s.ital = false;
                        s.modStack.shift();
              Severity: Major
              Found in lib/network/modules/components/shared/LabelSplitter.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                          if (/ \t/.test(ch)) {
                            s.spacing = true;
                          } else {
                            s.add(ch);
                            s.beginable = false;
                Severity: Major
                Found in lib/network/modules/components/shared/LabelSplitter.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                          if ((s.position === text.length-1) || /[.,_` \t\n]/.test(text.charAt(s.position+1))) {
                            s.emitBlock();
                            s.bold = false;
                            s.modStack.shift();
                          } else {
                  Severity: Major
                  Found in lib/network/modules/components/shared/LabelSplitter.js - About 45 mins to fix

                    Avoid too many return statements within this function.
                    Open

                              return 'ital';
                    Severity: Major
                    Found in lib/network/modules/components/shared/LabelSplitter.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                return 'ital';
                      Severity: Major
                      Found in lib/network/modules/components/shared/LabelSplitter.js - About 30 mins to fix

                        TODO found
                        Open

                            // TODO: consolidate following + methods/closures with splitHtmlBlocks()

                        TODO found
                        Open

                              // TODO: This can be done more efficiently with caching

                        TODO found
                        Open

                            // TODO: consolidate following + methods/closures with splitMarkdownBlocks()

                        There are no issues that match your filters.

                        Category
                        Status