jeffy-g/rm-cstyle-cmts

View on GitHub

Showing 47 of 53 total issues

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 getTransformer has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

const getTransformer: NsGulpRmc.TTransformerFactory = (
    /* istanbul ignore next */
    options = {}
): NsGulpRmc.StreamTransform => {

Severity: Minor
Found in src/gulp/index.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

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

Function getExtraArgs has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

function getExtraArgs(args_config, debug = false) {
    // debug log, if need.
    debug && console.log("process.argv: ", process.argv);
    /** @type {typeof ArgsConfig} */
    // @ts- ignore will be not `Partial`
Severity: Minor
Found in scripts/tiny/get-extra-args.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 fn has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

        fn() {
            const thisPackage = utils.readJson("./package.json");
            const recordPath = params.dest || "./logs/webpack-size.json";
            /** @type {Record<TVersionString, { webpack?: number; umd?: number}>} */
            const sizeRecord = fs.existsSync(recordPath)? utils.readJson(recordPath): {};
Severity: Minor
Found in scripts/tiny/tools.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 detectRegex has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

export const detectRegex = (line: string): TBC<TRegexDetectResult> => {

    if (!reValidFirst.test(line) || reLFCR.test(line)) return null;

    let groupIndex = 0,
Severity: Minor
Found in src/reutil.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

Function task has 92 lines of code (exceeds 25 allowed). Consider refactoring.
Open

 async function task(
    grmc, settings, mode = "cjs"
) {

    const BASE_PREFIX = settings.useExtern ? "[If you want to scan external node_modules directory etc., set path here]" : ".";
Severity: Major
Found in scripts/grmc-test-task.js - About 3 hrs to fix

    Function createWebpackProgressPluginHandler has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    function createWebpackProgressPluginHandler(logFilePath, disableRenderLine = false) {
    
        const formatPercentage = (/** @type {number} */pct) => {
            return `processing ${(pct * 100).toFixed(4)}%`;
        };
    Severity: Minor
    Found in scripts/tiny/progress/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 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 processSources has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

        function processSources(
            taskName,
            process, {
                base = "./build", bases,
                test = /\.js$/,
        Severity: Minor
        Found in scripts/tiny/tools.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

        File tools.js has 273 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #!/usr/bin/env node
        /*!
         - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
          Copyright (C) 2019 jeffy-g <hirotom1107@gmail.com>
          Released under the MIT license
        Severity: Minor
        Found in scripts/tiny/tools.js - 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 getTransformer has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const getTransformer: NsGulpRmc.TTransformerFactory = (
                /* istanbul ignore next */
                options = {}
            ): NsGulpRmc.StreamTransform => {
            
            
            Severity: Major
            Found in src/gulp/index.ts - About 2 hrs to fix

              Function createWebpackConfig has 55 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const createWebpackConfig = (target, output, mode = "production", extraOpt = {}) =>  {
              
                  const {
                      beautify,
                      forceSourceMap,
              Severity: Major
              Found in webpack.config.js - About 2 hrs to fix

                Function fn has 52 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        fn() {
                            const thisPackage = utils.readJson("./package.json");
                            const recordPath = params.dest || "./logs/webpack-size.json";
                            /** @type {Record<TVersionString, { webpack?: number; umd?: number}>} */
                            const sizeRecord = fs.existsSync(recordPath)? utils.readJson(recordPath): {};
                Severity: Major
                Found in scripts/tiny/tools.js - About 2 hrs to fix

                  Function detectRegex has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export const detectRegex = (line: string): TBC<TRegexDetectResult> => {
                  
                      if (!reValidFirst.test(line) || reLFCR.test(line)) return null;
                  
                      let groupIndex = 0,
                  Severity: Minor
                  Found in src/reutil.ts - About 1 hr to fix

                    Function grmcBatchTest has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        const grmcBatchTest = () => {
                    
                            console.log(settings);
                            // 2020/4/14
                            grmc.getRmcInterface().setListener(
                    Severity: Minor
                    Found in scripts/grmc-test-task.js - About 1 hr to fix

                      Function eachModule has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function eachModule(path: string) {
                      
                          let grmc: typeof import("../src/gulp/");
                          beforeAll(async () => {
                              grmc = await import(path);
                      Severity: Minor
                      Found in __tests__/grmc-test.ts - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language