jeffy-g/rm-cstyle-cmts

View on GitHub

Showing 53 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 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 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 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 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 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

              Identical blocks of code found in 2 locations. Consider refactoring.
              Confirmed

              const test_text = `:Key Binding:${ 234 }}
              //                ^  <- parse by class BackQuoteScanner
              }
              about                   [alt+A]
                  ${
              Severity: Major
              Found in samples/es6-rm_ws-true.js and 1 other location - About 2 hrs to fix
              samples/es6-rm_ws-false.js on lines 37..78

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 80.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Confirmed

              var HTMLIZE_TEXT = {
                title: `/anything/g`,
                
                description: '--- nothing ---',
                
              Severity: Major
              Found in samples/es6-rm_ws-false.js and 1 other location - About 2 hrs to fix
              samples/es6-rm_ws-true.js on lines 65..88

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 80.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Confirmed

              var HTMLIZE_TEXT = {
                title: `/anything/g`,
                description: '--- nothing ---',
                qre: "/(<button)\\s+([\\w\\-]+(?:=\"[^\"]+\")?)?\\s*([\\w\\-]+(?:=\"[^\"]+\")?)?\\s*([\\w\\-]+(?:=\"[^\"]+\")?)?\\s*([\\w\\-]+(?:=\"[^\"]+\")?)?\\s*([\\w\\-]+(?:=\"[^\"]+\")?)?\\s*([\\w\\-]+(?:=\"[^\"]+\")?)?\\s*([\\w\\-]+(?:=\"[^\"]+\")?)?\\s*(>.*<\\/button>)/g.toString()",
                re: /(<button)\s+([\w\-]+(?:="[^"]+")?)?\s*([\w\-]+(?:="[^"]+")?)?\s*([\w\-]+(?:=`[^`]+`)?)?\s*([\w\-]+(?:="[^"]+")?)?\s*([\w\-]+(?:="[^"]+")?)?\s*([\w\-]+(?:="[^"]+")?)?\s*([\w\-]+(?:="[^"]+")?)?\s*(>.*<\/button>)/g.toString(),
              Severity: Major
              Found in samples/es6-rm_ws-true.js and 1 other location - About 2 hrs to fix
              samples/es6-rm_ws-false.js on lines 93..122

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 80.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Confirmed

              const test_text = `:Key Binding:${ 234 }}
              //                ^  <- parse by class BackQuoteScanner
              }
              about                   [alt+A]
                  ${
              Severity: Major
              Found in samples/es6-rm_ws-false.js and 1 other location - About 2 hrs to fix
              samples/es6-rm_ws-true.js on lines 16..57

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 80.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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
                Severity
                Category
                Status
                Source
                Language