enclose-io/compiler

View on GitHub
current/lib/path.js

Summary

Maintainability
F
2 mos
Test Coverage

File path.js has 992 lines of code (exceeds 250 allowed). Consider refactoring.
Open

// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
Severity: Major
Found in current/lib/path.js - About 2 days to fix

    Function resolve has a Cognitive Complexity of 79 (exceeds 5 allowed). Consider refactoring.
    Open

      resolve(...args) {
        let resolvedDevice = '';
        let resolvedTail = '';
        let resolvedAbsolute = false;
    
    
    Severity: Minor
    Found in current/lib/path.js - 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 parse has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
    Open

      parse(path) {
        validateString(path, 'path');
    
        const ret = { root: '', dir: '', base: '', ext: '', name: '' };
        if (path.length === 0)
    Severity: Minor
    Found in current/lib/path.js - 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 dirname has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

      dirname(path) {
        validateString(path, 'path');
        const len = path.length;
        if (len === 0)
          return '.';
    Severity: Minor
    Found in current/lib/path.js - 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 normalize has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

      normalize(path) {
        validateString(path, 'path');
        const len = path.length;
        if (len === 0)
          return '.';
    Severity: Minor
    Found in current/lib/path.js - 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 basename has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
    Open

      basename(path, ext) {
        if (ext !== undefined)
          validateString(ext, 'ext');
        validateString(path, 'path');
        let start = 0;
    Severity: Minor
    Found in current/lib/path.js - 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 basename has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
    Open

      basename(path, ext) {
        if (ext !== undefined)
          validateString(ext, 'ext');
        validateString(path, 'path');
    
    
    Severity: Minor
    Found in current/lib/path.js - About 6 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 normalizeString has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
    Open

    function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
      let res = '';
      let lastSegmentLength = 0;
      let lastSlash = -1;
      let dots = 0;
    Severity: Minor
    Found in current/lib/path.js - About 6 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 relative has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

      relative(from, to) {
        validateString(from, 'from');
        validateString(to, 'to');
    
        if (from === to)
    Severity: Minor
    Found in current/lib/path.js - About 6 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 parse has 103 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      parse(path) {
        validateString(path, 'path');
    
        const ret = { root: '', dir: '', base: '', ext: '', name: '' };
        if (path.length === 0)
    Severity: Major
    Found in current/lib/path.js - About 4 hrs to fix

      Function relative has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

        relative(from, to) {
          validateString(from, 'from');
          validateString(to, 'to');
      
          if (from === to)
      Severity: Minor
      Found in current/lib/path.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 parse has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

        parse(path) {
          validateString(path, 'path');
      
          const ret = { root: '', dir: '', base: '', ext: '', name: '' };
          if (path.length === 0)
      Severity: Minor
      Found in current/lib/path.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 resolve has 92 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        resolve(...args) {
          let resolvedDevice = '';
          let resolvedTail = '';
          let resolvedAbsolute = false;
      
      
      Severity: Major
      Found in current/lib/path.js - About 3 hrs to fix

        Function join has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

          join(...args) {
            if (args.length === 0)
              return '.';
        
            let joined;
        Severity: Minor
        Found in current/lib/path.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

        Function relative has 78 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          relative(from, to) {
            validateString(from, 'from');
            validateString(to, 'to');
        
            if (from === to)
        Severity: Major
        Found in current/lib/path.js - About 3 hrs to fix

          Function extname has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

            extname(path) {
              validateString(path, 'path');
              let start = 0;
              let startDot = -1;
              let startPart = 0;
          Severity: Minor
          Found in current/lib/path.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

          Function normalize has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            normalize(path) {
              validateString(path, 'path');
              const len = path.length;
              if (len === 0)
                return '.';
          Severity: Major
          Found in current/lib/path.js - About 2 hrs to fix

            Function extname has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
            Open

              extname(path) {
                validateString(path, 'path');
                let startDot = -1;
                let startPart = 0;
                let end = -1;
            Severity: Minor
            Found in current/lib/path.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

            Function basename has 60 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              basename(path, ext) {
                if (ext !== undefined)
                  validateString(ext, 'ext');
                validateString(path, 'path');
                let start = 0;
            Severity: Major
            Found in current/lib/path.js - About 2 hrs to fix

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

                dirname(path) {
                  validateString(path, 'path');
                  const len = path.length;
                  if (len === 0)
                    return '.';
              Severity: Major
              Found in current/lib/path.js - About 2 hrs to fix

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

                  parse(path) {
                    validateString(path, 'path');
                
                    const ret = { root: '', dir: '', base: '', ext: '', name: '' };
                    if (path.length === 0)
                Severity: Major
                Found in current/lib/path.js - About 2 hrs to fix

                  Function normalizeString has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
                    let res = '';
                    let lastSegmentLength = 0;
                    let lastSlash = -1;
                    let dots = 0;
                  Severity: Major
                  Found in current/lib/path.js - About 2 hrs to fix

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

                      basename(path, ext) {
                        if (ext !== undefined)
                          validateString(ext, 'ext');
                        validateString(path, 'path');
                    
                    
                    Severity: Major
                    Found in current/lib/path.js - About 2 hrs to fix

                      Function relative has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        relative(from, to) {
                          validateString(from, 'from');
                          validateString(to, 'to');
                      
                          if (from === to)
                      Severity: Minor
                      Found in current/lib/path.js - About 1 hr to fix

                        Function extname has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          extname(path) {
                            validateString(path, 'path');
                            let start = 0;
                            let startDot = -1;
                            let startPart = 0;
                        Severity: Minor
                        Found in current/lib/path.js - About 1 hr to fix

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

                            join(...args) {
                              if (args.length === 0)
                                return '.';
                          
                              let joined;
                          Severity: Minor
                          Found in current/lib/path.js - About 1 hr to fix

                            Function dirname has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                            Open

                              dirname(path) {
                                validateString(path, 'path');
                                if (path.length === 0)
                                  return '.';
                                const hasRoot = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
                            Severity: Minor
                            Found in current/lib/path.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 extname has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              extname(path) {
                                validateString(path, 'path');
                                let startDot = -1;
                                let startPart = 0;
                                let end = -1;
                            Severity: Minor
                            Found in current/lib/path.js - About 1 hr to fix

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

                                toNamespacedPath(path) {
                                  // Note: this will *probably* throw somewhere.
                                  if (typeof path !== 'string')
                                    return path;
                              
                              
                              Severity: Minor
                              Found in current/lib/path.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

                              Avoid deeply nested control flow statements.
                              Open

                                          if (j !== last) {
                                            // We matched a UNC root with leftovers
                              
                                            // Offset by 1 to include the separator after the UNC root to
                                            // treat it as a "normal root" on top of a (UNC) root
                              Severity: Major
                              Found in current/lib/path.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                          if (res.length > 2) {
                                            const lastSlashIndex = res.lastIndexOf(separator);
                                            if (lastSlashIndex === -1) {
                                              res = '';
                                              lastSegmentLength = 0;
                                Severity: Major
                                Found in current/lib/path.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                              while (j < len && !isPathSeparator(path.charCodeAt(j))) {
                                                j++;
                                              }
                                  Severity: Major
                                  Found in current/lib/path.js - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                while (j < len && !isPathSeparator(path.charCodeAt(j))) {
                                                  j++;
                                                }
                                    Severity: Major
                                    Found in current/lib/path.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                  while (j < len && !isPathSeparator(path.charCodeAt(j))) {
                                                    j++;
                                                  }
                                      Severity: Major
                                      Found in current/lib/path.js - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                    if (j !== last) {
                                                      // We matched a UNC root with leftovers
                                                      device = `\\\\${firstPart}\\${path.slice(last, j)}`;
                                                      rootEnd = j;
                                                    }
                                        Severity: Major
                                        Found in current/lib/path.js - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                    while (j < len && !isPathSeparator(path.charCodeAt(j))) {
                                                      j++;
                                                    }
                                          Severity: Major
                                          Found in current/lib/path.js - About 45 mins to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                        if (code === ext.charCodeAt(extIdx)) {
                                                          if (--extIdx === -1) {
                                                            // We matched the extension, so mark this as the end of our path
                                                            // component
                                                            end = i;
                                            Severity: Major
                                            Found in current/lib/path.js - About 45 mins to fix

                                              Avoid deeply nested control flow statements.
                                              Open

                                                          if (j === len) {
                                                            // We matched a UNC root only
                                                            // Return the normalized version of the UNC root since there
                                                            // is nothing left to process
                                                            return `\\\\${firstPart}\\${path.slice(last)}\\`;
                                              Severity: Major
                                              Found in current/lib/path.js - About 45 mins to fix

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

                                                  normalize(path) {
                                                    validateString(path, 'path');
                                                
                                                    if (path.length === 0)
                                                      return '.';
                                                Severity: Minor
                                                Found in current/lib/path.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 (j < len && j !== last) {
                                                            const firstPart = path.slice(last, j);
                                                            // Matched!
                                                            last = j;
                                                            // Match 1 or more path separators
                                                Severity: Major
                                                Found in current/lib/path.js - About 45 mins to fix

                                                  Avoid deeply nested control flow statements.
                                                  Open

                                                              if (code === ext.charCodeAt(extIdx)) {
                                                                if (--extIdx === -1) {
                                                                  // We matched the extension, so mark this as the end of our path
                                                                  // component
                                                                  end = i;
                                                  Severity: Major
                                                  Found in current/lib/path.js - About 45 mins to fix

                                                    Avoid deeply nested control flow statements.
                                                    Open

                                                            if (len > 2 && isPathSeparator(path.charCodeAt(2))) {
                                                              // Treat separator following drive name as an absolute path
                                                              // indicator
                                                              isAbsolute = true;
                                                              rootEnd = 3;
                                                    Severity: Major
                                                    Found in current/lib/path.js - About 45 mins to fix

                                                      Avoid deeply nested control flow statements.
                                                      Open

                                                                  if (j === len) {
                                                                    // We matched a UNC root only
                                                                    return path;
                                                                  }
                                                      Severity: Major
                                                      Found in current/lib/path.js - About 45 mins to fix

                                                        Avoid deeply nested control flow statements.
                                                        Open

                                                                    if (j === len) {
                                                                      // We matched a UNC root only
                                                                      rootEnd = j;
                                                                    } else if (j !== last) {
                                                                      // We matched a UNC root with leftovers
                                                        Severity: Major
                                                        Found in current/lib/path.js - About 45 mins to fix

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

                                                            join(...args) {
                                                              if (args.length === 0)
                                                                return '.';
                                                              let joined;
                                                              for (let i = 0; i < args.length; ++i) {
                                                          Severity: Minor
                                                          Found in current/lib/path.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

                                                          Consider simplifying this complex logical expression.
                                                          Open

                                                              if (startDot === -1 ||
                                                                  end === -1 ||
                                                                  // We saw a non-dot character immediately before the dot
                                                                  preDotState === 0 ||
                                                                  // The (right-most) trimmed path component is exactly '..'
                                                          Severity: Major
                                                          Found in current/lib/path.js - About 40 mins to fix

                                                            Consider simplifying this complex logical expression.
                                                            Open

                                                                if (startDot === -1 ||
                                                                    end === -1 ||
                                                                    // We saw a non-dot character immediately before the dot
                                                                    preDotState === 0 ||
                                                                    // The (right-most) trimmed path component is exactly '..'
                                                            Severity: Major
                                                            Found in current/lib/path.js - About 40 mins to fix

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

                                                                resolve(...args) {
                                                                  let resolvedPath = '';
                                                                  let resolvedAbsolute = false;
                                                              
                                                                  for (let i = args.length - 1; i >= -1 && !resolvedAbsolute; i--) {
                                                              Severity: Minor
                                                              Found in current/lib/path.js - 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 ret;
                                                              Severity: Major
                                                              Found in current/lib/path.js - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                          return toOrig.slice(toStart + i);
                                                                Severity: Major
                                                                Found in current/lib/path.js - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                      return isAbsolute ? `${device}\\${tail}` : `${device}${tail}`;
                                                                  Severity: Major
                                                                  Found in current/lib/path.js - About 30 mins to fix

                                                                    Avoid too many return statements within this function.
                                                                    Open

                                                                        return `${out}${to.slice(toStart + lastCommonSep)}`;
                                                                    Severity: Major
                                                                    Found in current/lib/path.js - About 30 mins to fix

                                                                      Avoid too many return statements within this function.
                                                                      Open

                                                                          return path;
                                                                      Severity: Major
                                                                      Found in current/lib/path.js - About 30 mins to fix

                                                                        Avoid too many return statements within this function.
                                                                        Open

                                                                              return `\\\\?\\${resolvedPath}`;
                                                                        Severity: Major
                                                                        Found in current/lib/path.js - About 30 mins to fix

                                                                          Avoid too many return statements within this function.
                                                                          Open

                                                                                    return ret;
                                                                          Severity: Major
                                                                          Found in current/lib/path.js - About 30 mins to fix

                                                                            Avoid too many return statements within this function.
                                                                            Open

                                                                                return toOrig.slice(toStart, toEnd);
                                                                            Severity: Major
                                                                            Found in current/lib/path.js - About 30 mins to fix

                                                                              Avoid too many return statements within this function.
                                                                              Open

                                                                                    return `${out}${toOrig.slice(toStart, toEnd)}`;
                                                                              Severity: Major
                                                                              Found in current/lib/path.js - About 30 mins to fix

                                                                                Avoid too many return statements within this function.
                                                                                Open

                                                                                    return path.slice(0, end);
                                                                                Severity: Major
                                                                                Found in current/lib/path.js - About 30 mins to fix

                                                                                  Avoid too many return statements within this function.
                                                                                  Open

                                                                                            return toOrig.slice(toStart + i + 1);
                                                                                  Severity: Major
                                                                                  Found in current/lib/path.js - About 30 mins to fix

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

                                                                                    const win32 = {
                                                                                      // path.resolve([from ...], to)
                                                                                      resolve(...args) {
                                                                                        let resolvedDevice = '';
                                                                                        let resolvedTail = '';
                                                                                    Severity: Major
                                                                                    Found in current/lib/path.js and 1 other location - About 1 mo to fix
                                                                                    lts/lib/path.js on lines 128..969

                                                                                    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 5929.

                                                                                    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.
                                                                                    Open

                                                                                    const posix = {
                                                                                      // path.resolve([from ...], to)
                                                                                      resolve(...args) {
                                                                                        let resolvedPath = '';
                                                                                        let resolvedAbsolute = false;
                                                                                    Severity: Major
                                                                                    Found in current/lib/path.js and 1 other location - About 2 wks to fix
                                                                                    lts/lib/path.js on lines 971..1366

                                                                                    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 2786.

                                                                                    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.
                                                                                    Open

                                                                                    function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
                                                                                      let res = '';
                                                                                      let lastSegmentLength = 0;
                                                                                      let lastSlash = -1;
                                                                                      let dots = 0;
                                                                                    Severity: Major
                                                                                    Found in current/lib/path.js and 1 other location - About 3 days to fix
                                                                                    lts/lib/path.js on lines 52..113

                                                                                    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 592.

                                                                                    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.
                                                                                    Open

                                                                                    function _format(sep, pathObject) {
                                                                                      if (pathObject === null || typeof pathObject !== 'object') {
                                                                                        throw new ERR_INVALID_ARG_TYPE('pathObject', 'Object', pathObject);
                                                                                      }
                                                                                      const dir = pathObject.dir || pathObject.root;
                                                                                    Severity: Major
                                                                                    Found in current/lib/path.js and 1 other location - About 6 hrs to fix
                                                                                    lts/lib/path.js on lines 115..126

                                                                                    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 162.

                                                                                    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

                                                                                    There are no issues that match your filters.

                                                                                    Category
                                                                                    Status