jeffy-g/rm-cstyle-cmts

View on GitHub

Showing 53 of 53 total issues

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

          Function createWebpackProgressPluginHandler has 41 lines of code (exceeds 25 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 1 hr to fix

            Function task has a Cognitive Complexity of 13 (exceeds 5 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: Minor
            Found in scripts/grmc-test-task.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 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 getExtraArgs has 34 lines of code (exceeds 25 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 1 hr to fix

                Function wppHandlerV5 has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                const wppHandlerV5 = ((renderer, cwd) => {
                    return (percentage, message, ...args) => {
                        if (!message) {
                            message = "- done -";
                        }
                Severity: Minor
                Found in scripts/tiny/progress/progress-extras.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 emitMainFunction has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                const emitMainFunction = <
                    T extends typeof apply | typeof walk,
                    R extends ReturnType<T>
                >(fn: T): (...args: Parameters<T>) => R => {
                
                
                Severity: Minor
                Found in src/index.ts - 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 fn has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        fn: () => {
                            let {
                                major, minor/*, patch*/,
                                pkgJsons = ["./package.json"]
                            } = params;
                Severity: Minor
                Found in scripts/tiny/tools.js - About 1 hr to fix

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

                      const transform: NsGulpRmc.FixTransformFunction = function (vinyl, encoding, callback) {
                  
                          // plugin main
                          if (vinyl.isBuffer()) {
                              if (extensions.includes(vinyl.extname)) {
                  Severity: Minor
                  Found in src/gulp/index.ts - About 1 hr to fix

                    Function createContext has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    const createContext = (options: NsGulpRmc.TOptions) => {
                    
                        /** @type {TRemoveCStyleCommentsOpt} */
                        const opt: TRemoveCStyleCommentsOpt = {
                            preserveBlanks: options.preserveBlanks,
                    Severity: Minor
                    Found in src/gulp/index.ts - About 1 hr to fix

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

                      function writeTextUTF8(content, dest, callback) {
                          // need dest parent dir check.
                          lib.checkParentDirectory(dest);
                      
                          const ws = fs.createWriteStream(dest)
                      Severity: Minor
                      Found in scripts/tiny/utils.js - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                            if (settings.p === true) {
                                const stdin = process.stdin;
                                stdin.resume().setEncoding("utf8");
                                inputs = "";
                        
                        
                        Severity: Major
                        Found in src/bench/index.ts - About 1 hr to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if (value === void 0 || value.startsWith(actualConfig.prefix)) {
                                                  value = true;
                                              } else {
                                                  // DEVNOTE: now possible to process array parameters
                                                  // DEVNOTE: 2020/2/28 - support regex parameter
                          Severity: Major
                          Found in scripts/tiny/get-extra-args.js - About 45 mins 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 (scanListener!(eventContext)) {
                                                    ctx.result += fragment;
                                                }
                            Severity: Major
                            Found in src/js-scanner.ts - About 45 mins to fix

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

                              function writeTextUTF8(content, dest, callback) {
                                  // need dest parent dir check.
                                  lib.checkParentDirectory(dest);
                              
                                  const ws = fs.createWriteStream(dest)
                              Severity: Minor
                              Found in scripts/tiny/utils.js - 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
                                Severity
                                Category
                                Status
                                Source
                                Language