tkrotoff/throw-on

View on GitHub

Showing 26 of 58 total issues

File inspect.test.ts has 635 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable unicorn/prefer-number-properties, func-names, @typescript-eslint/no-empty-function, new-cap, no-new-func,
no-new-object, no-new-wrappers, unicorn/new-for-builtins, no-regex-spaces, unicorn/error-message, no-inner-declarations */

import assert from 'node:assert';
import { inspect as nodeInspect } from 'node:util';
Severity: Major
Found in src/util/inspect.test.ts - About 1 day to fix

    Function str has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
    Open

    function str(key: string | number | symbol, holder: any, recurseTimes: number): string {
      recurseTimes++;
    
      const value = holder[key];
    
    
    Severity: Minor
    Found in src/util/inspect.ts - 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 format has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

    export function format(str?: any, ...values: any[]) {
      if (typeof str !== 'string') {
        return (str === undefined ? values : [str, ...values])
          .map(value => (typeof value === 'string' ? value : inspect(value)))
          .join(' ');
    Severity: Minor
    Found in src/util/format.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 str has 101 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function str(key: string | number | symbol, holder: any, recurseTimes: number): string {
      recurseTimes++;
    
      const value = holder[key];
    
    
    Severity: Major
    Found in src/util/inspect.ts - About 4 hrs to fix

      Function format has 100 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function format(str?: any, ...values: any[]) {
        if (typeof str !== 'string') {
          return (str === undefined ? values : [str, ...values])
            .map(value => (typeof value === 'string' ? value : inspect(value)))
            .join(' ');
      Severity: Major
      Found in src/util/format.ts - About 4 hrs to fix

        Function o has 82 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            .replace(/%[%sdifjoOc]/g, match => {
              if (match === '%%') return '%';
        
              if (nbSpecifiers >= values.length) return match;
        
        
        Severity: Major
        Found in src/util/format.ts - About 3 hrs to fix

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

          function getName(object: any) {
            let name = '';
          
            if (object.constructor === undefined) {
              name = '[Object: null prototype]';
          Severity: Minor
          Found in src/util/inspect.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 loopObject has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          function loopObject(keys: Key[], object: object, recurseTimes: number) {
            const items: string[] = [];
          
            for (const k of keys) {
              const key = strKey(k, recurseTimes);
          Severity: Minor
          Found in src/util/inspect.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 throwOnConsole has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          export function throwOnConsole(methodName: ConsoleMethodName, options: Options = {}) {
            const { ignore } = options;
          
            if (methodName === 'assert') {
              console.assert = (condition?: boolean, ...data: any[]) => {
          Severity: Minor
          Found in src/throwOnConsole.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

          Avoid deeply nested control flow statements.
          Open

                  if (res.length > 0) res += ' ';
          Severity: Major
          Found in src/util/inspect.ts - About 45 mins to fix

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

            function loopArray(array: any[] | TypedArray, recurseTimes: number) {
              const items: string[] = [];
            
              for (let i = 0; i < array.length; i++) {
                try {
            Severity: Minor
            Found in src/util/inspect.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

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

            function strKey(key: Key, recurseTimes: number) {
              switch (typeof key) {
                case 'string': {
                  // Because Object.keys() return (string | symbol)[] thus
                  // const arr = []; arr[10] = 11;
            Severity: Minor
            Found in src/util/inspect.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

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

            function loopSet(set: Set<any>, recurseTimes: number) {
              const items: string[] = [];
            
              for (const v of set) {
                try {
            Severity: Minor
            Found in src/util/inspect.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 String(value);
            Severity: Major
            Found in src/util/format.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return Number.NaN.toString();
              Severity: Major
              Found in src/util/format.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                              return '[Circular]';
                Severity: Major
                Found in src/util/format.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                              return Number.NaN.toString();
                  Severity: Major
                  Found in src/util/format.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return Number.parseFloat(value).toString();
                    Severity: Major
                    Found in src/util/format.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                      return Number.parseInt(value, 10).toString();
                      Severity: Major
                      Found in src/util/format.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                    return JSON.stringify(value);
                        Severity: Major
                        Found in src/util/format.ts - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language