jeffy-g/rm-cstyle-cmts

View on GitHub
src/js-scanner.ts

Summary

Maintainability
F
3 days
Test Coverage

Function backQuote has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

const backQuote: TCharScannerFunction = (src: string, ctx: TScannerContext): boolean | never => {

    // store "next" postion character. 
    let ch: TBD<string>;
    // cache start offset
Severity: Minor
Found in src/js-scanner.ts - 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 slash has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

const slash: TCharScannerFunction = (src: string, ctx: TScannerContext): boolean => {

    // cache start offset
    const startOffset = ctx.offset;
    // fetch next char.
Severity: Minor
Found in src/js-scanner.ts - About 5 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 apply has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

const apply = (src: string, opt: TRemoveCStyleCommentsOpt): string => {

    //
    // step 1. remove {line, block} comments
    //
Severity: Minor
Found in src/js-scanner.ts - 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

File js-scanner.ts has 287 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  Copyright (C) 2020 jeffy-g <hirotom1107@gmail.com>
  Released under the MIT license
  https://opensource.org/licenses/mit-license.php
Severity: Minor
Found in src/js-scanner.ts - About 2 hrs to fix

    Function slash has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const slash: TCharScannerFunction = (src: string, ctx: TScannerContext): boolean => {
    
        // cache start offset
        const startOffset = ctx.offset;
        // fetch next char.
    Severity: Major
    Found in src/js-scanner.ts - About 2 hrs to fix

      Function apply has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const apply = (src: string, opt: TRemoveCStyleCommentsOpt): string => {
      
          //
          // step 1. remove {line, block} comments
          //
      Severity: Major
      Found in src/js-scanner.ts - About 2 hrs to fix

        Function backQuote has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const backQuote: TCharScannerFunction = (src: string, ctx: TScannerContext): boolean | never => {
        
            // store "next" postion character. 
            let ch: TBD<string>;
            // cache start offset
        Severity: Minor
        Found in src/js-scanner.ts - About 1 hr to fix

          Function quote has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          const quote: TCharScannerFunction = (src: string, ctx: TScannerContext): boolean => {
          
              const startOffset = ctx.offset;
              const q = src[startOffset];
              // limiter
          Severity: Minor
          Found in src/js-scanner.ts - About 45 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

          Avoid deeply nested control flow statements.
          Open

                              if (!ctx.isWalk) {
                                  ctx.result += src.substring(prevOffset, next);
                              }
          Severity: Major
          Found in src/js-scanner.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if (!inspectable) {
                                    next++;
                                    continue;
                                }
            Severity: Major
            Found in src/js-scanner.ts - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if (scanListener!(eventContext)) {
                                      ctx.result += fragment;
                                  }
              Severity: Major
              Found in src/js-scanner.ts - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if (code === EMetaChars.RIGHT_CURLY) {
                                        startOffset = ++next;
                                        /* https://coderwall
                                        when(prevOffset);
                                        /*/
                Severity: Major
                Found in src/js-scanner.ts - About 45 mins to fix

                  Function walk has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const walk = (src: string, opt: TRemoveCStyleCommentsOpt): void => {
                  
                      //
                      // run as walk through mode
                      //
                  Severity: Minor
                  Found in src/js-scanner.ts - About 35 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

                  Avoid too many return statements within this function.
                  Open

                      return true;
                  Severity: Major
                  Found in src/js-scanner.ts - About 30 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status