enclose-io/compiler

View on GitHub
lts/lib/internal/modules/cjs/loader.js

Summary

Maintainability
F
1 mo
Test Coverage

File loader.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 lts/lib/internal/modules/cjs/loader.js - About 2 days to fix

    Function resolveExportsTarget has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
    Open

    function resolveExportsTarget(baseUrl, target, subpath, mappingKey) {
      if (typeof target === 'string') {
        let resolvedTarget, resolvedTargetPath;
        const pkgPathPath = baseUrl.pathname;
        if (StringPrototypeStartsWith(target, './')) {
    Severity: Minor
    Found in lts/lib/internal/modules/cjs/loader.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 _findPath has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

    Module._findPath = function(request, paths, isMain) {
      const absoluteRequest = path.isAbsolute(request);
      if (absoluteRequest) {
        paths = [''];
      } else if (!paths || paths.length === 0) {
    Severity: Minor
    Found in lts/lib/internal/modules/cjs/loader.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 _resolveFilename has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

    Module._resolveFilename = function(request, parent, isMain, options) {
      if (NativeModule.canBeRequiredByUsers(request)) {
        return request;
      }
    
    
    Severity: Minor
    Found in lts/lib/internal/modules/cjs/loader.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 applyExports has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

    function applyExports(basePath, expansion) {
      const mappingKey = `.${expansion}`;
    
      let pkgExports = readPackageExports(basePath);
      if (pkgExports === undefined || pkgExports === null)
    Severity: Minor
    Found in lts/lib/internal/modules/cjs/loader.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 _load has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    Module._load = function(request, parent, isMain) {
      let relResolveCacheIdentifier;
      if (parent) {
        debug('Module._load REQUEST %s parent: %s', request, parent.id);
        // Fast path for (lazy loaded) modules in the same directory. The indirect
    Severity: Minor
    Found in lts/lib/internal/modules/cjs/loader.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 resolveExportsTarget has 76 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function resolveExportsTarget(baseUrl, target, subpath, mappingKey) {
      if (typeof target === 'string') {
        let resolvedTarget, resolvedTargetPath;
        const pkgPathPath = baseUrl.pathname;
        if (StringPrototypeStartsWith(target, './')) {
    Severity: Major
    Found in lts/lib/internal/modules/cjs/loader.js - About 3 hrs to fix

      Function _findPath has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Module._findPath = function(request, paths, isMain) {
        const absoluteRequest = path.isAbsolute(request);
        if (absoluteRequest) {
          paths = [''];
        } else if (!paths || paths.length === 0) {
      Severity: Major
      Found in lts/lib/internal/modules/cjs/loader.js - About 2 hrs to fix

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

          Module._nodeModulePaths = function(from) {
            // Guarantee that 'from' is absolute.
            from = path.resolve(from);
        
            // note: this approach *only* works when the path is guaranteed
        Severity: Minor
        Found in lts/lib/internal/modules/cjs/loader.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 _compile has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

        Module.prototype._compile = function(content, filename) {
          let moduleURL;
          let redirects;
          if (manifest) {
            moduleURL = pathToFileURL(filename);
        Severity: Minor
        Found in lts/lib/internal/modules/cjs/loader.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 _load has 59 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Module._load = function(request, parent, isMain) {
          let relResolveCacheIdentifier;
          if (parent) {
            debug('Module._load REQUEST %s parent: %s', request, parent.id);
            // Fast path for (lazy loaded) modules in the same directory. The indirect
        Severity: Major
        Found in lts/lib/internal/modules/cjs/loader.js - About 2 hrs to fix

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

          Module._resolveFilename = function(request, parent, isMain, options) {
            if (NativeModule.canBeRequiredByUsers(request)) {
              return request;
            }
          
          
          Severity: Major
          Found in lts/lib/internal/modules/cjs/loader.js - About 2 hrs to fix

            Function _nodeModulePaths has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

              Module._nodeModulePaths = function(from) {
                // Guarantee that 'from' is absolute.
                from = path.resolve(from);
                // Return early not only to avoid unnecessary work, but to *avoid* returning
                // an array of two items for a root: [ '//node_modules', '/node_modules' ]
            Severity: Minor
            Found in lts/lib/internal/modules/cjs/loader.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 wrapSafe has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function wrapSafe(filename, content, cjsModuleInstance) {
              if (patched) {
                const wrapper = Module.wrap(content);
                return vm.runInThisContext(wrapper, {
                  filename,
            Severity: Minor
            Found in lts/lib/internal/modules/cjs/loader.js - About 1 hr to fix

              Function _compile has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              Module.prototype._compile = function(content, filename) {
                let moduleURL;
                let redirects;
                if (manifest) {
                  moduleURL = pathToFileURL(filename);
              Severity: Minor
              Found in lts/lib/internal/modules/cjs/loader.js - About 1 hr to fix

                Function applyExports has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function applyExports(basePath, expansion) {
                  const mappingKey = `.${expansion}`;
                
                  let pkgExports = readPackageExports(basePath);
                  if (pkgExports === undefined || pkgExports === null)
                Severity: Minor
                Found in lts/lib/internal/modules/cjs/loader.js - About 1 hr to fix

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

                  Module._resolveLookupPaths = function(request, parent) {
                    if (NativeModule.canBeRequiredByUsers(request)) {
                      debug('looking for %j in []', request);
                      return null;
                    }
                  Severity: Minor
                  Found in lts/lib/internal/modules/cjs/loader.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 tryPackage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function tryPackage(requestPath, exts, isMain, originalPath) {
                    const pkg = readPackageMain(requestPath);
                  
                    if (!pkg) {
                      return tryExtensions(path.resolve(requestPath, 'index'), exts, isMain);
                  Severity: Minor
                  Found in lts/lib/internal/modules/cjs/loader.js - About 1 hr to fix

                    Function readPackage has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function readPackage(requestPath) {
                      const jsonPath = path.resolve(requestPath, 'package.json');
                    
                      const existing = packageJsonCache.get(jsonPath);
                      if (existing !== undefined) return existing;
                    Severity: Minor
                    Found in lts/lib/internal/modules/cjs/loader.js - About 1 hr to fix

                      Function load has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      Module.prototype.load = function(filename) {
                        debug('load %j for module %j', filename, this.id);
                      
                        assert(!this.loaded);
                        this.filename = filename;
                      Severity: Minor
                      Found in lts/lib/internal/modules/cjs/loader.js - About 1 hr to fix

                        Avoid deeply nested control flow statements.
                        Open

                                  if (preserveSymlinks) {
                                    filename = path.resolve(basePath);
                                  } else {
                                    filename = toRealPath(basePath);
                                  }
                        Severity: Major
                        Found in lts/lib/internal/modules/cjs/loader.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                    for (let j = 0; j < lookupPaths.length; j++) {
                                      if (!paths.includes(lookupPaths[j]))
                                        paths.push(lookupPaths[j]);
                                    }
                          Severity: Major
                          Found in lts/lib/internal/modules/cjs/loader.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                    if (nmChars[p] === code) {
                                      ++p;
                                    } else {
                                      p = -1;
                                    }
                            Severity: Major
                            Found in lts/lib/internal/modules/cjs/loader.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                      } else if (preserveSymlinksMain) {
                                        // For the main module, we use the preserveSymlinksMain flag instead
                                        // mainly for backward compatibility, as the preserveSymlinks flag
                                        // historically has not applied to the main module.  Most likely this
                                        // was intended to keep .bin/ binaries working, as following those
                              Severity: Major
                              Found in lts/lib/internal/modules/cjs/loader.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                      switch (p) {
                                        case 'node':
                                        case 'require':
                                          try {
                                            return resolveExportsTarget(baseUrl, target[p], subpath,
                                Severity: Major
                                Found in lts/lib/internal/modules/cjs/loader.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                          if (nmChars[p] === code) {
                                            ++p;
                                          } else {
                                            p = -1;
                                          }
                                  Severity: Major
                                  Found in lts/lib/internal/modules/cjs/loader.js - About 45 mins to fix

                                    Consider simplifying this complex logical expression.
                                    Open

                                      if (request.charAt(0) !== '.' ||
                                          (request.length > 1 &&
                                          request.charAt(1) !== '.' &&
                                          request.charAt(1) !== '/' &&
                                          (!isWindows || request.charAt(1) !== '\\'))) {
                                    Severity: Major
                                    Found in lts/lib/internal/modules/cjs/loader.js - About 40 mins to fix

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

                                      function trySelf(parentPath, request) {
                                        const { data: pkg, path: basePath } = readPackageScope(parentPath) || {};
                                        if (!pkg || pkg.exports === undefined) return false;
                                        if (typeof pkg.name !== 'string') return false;
                                      
                                      
                                      Severity: Minor
                                      Found in lts/lib/internal/modules/cjs/loader.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

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

                                      function isConditionalDotExportSugar(exports, basePath) {
                                        if (typeof exports === 'string')
                                          return true;
                                        if (ArrayIsArray(exports))
                                          return true;
                                      Severity: Minor
                                      Found in lts/lib/internal/modules/cjs/loader.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

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

                                      function createRequire(filename) {
                                        let filepath;
                                      
                                        if (filename instanceof URL ||
                                            (typeof filename === 'string' && !path.isAbsolute(filename))) {
                                      Severity: Minor
                                      Found in lts/lib/internal/modules/cjs/loader.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

                                              if (filename) return filename;
                                      Severity: Major
                                      Found in lts/lib/internal/modules/cjs/loader.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                          return false;
                                        Severity: Major
                                        Found in lts/lib/internal/modules/cjs/loader.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                return;
                                          Severity: Major
                                          Found in lts/lib/internal/modules/cjs/loader.js - About 30 mins to fix

                                            Function tryPackage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                            function tryPackage(requestPath, exts, isMain, originalPath) {
                                              const pkg = readPackageMain(requestPath);
                                            
                                              if (!pkg) {
                                                return tryExtensions(path.resolve(requestPath, 'index'), exts, isMain);
                                            Severity: Minor
                                            Found in lts/lib/internal/modules/cjs/loader.js - About 25 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 load has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                            Open

                                            Module.prototype.load = function(filename) {
                                              debug('load %j for module %j', filename, this.id);
                                            
                                              assert(!this.loaded);
                                              this.filename = filename;
                                            Severity: Minor
                                            Found in lts/lib/internal/modules/cjs/loader.js - About 25 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

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

                                            Module._findPath = function(request, paths, isMain) {
                                              const absoluteRequest = path.isAbsolute(request);
                                              if (absoluteRequest) {
                                                paths = [''];
                                              } else if (!paths || paths.length === 0) {
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 3 days to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 638..724

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

                                            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

                                            if (isWindows) {
                                              // 'from' is the __dirname of the module.
                                              Module._nodeModulePaths = function(from) {
                                                // Guarantee that 'from' is absolute.
                                                from = path.resolve(from);
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 3 days to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 729..806

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

                                            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

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

                                            Module.prototype._compile = function(content, filename) {
                                              let moduleURL;
                                              let redirects;
                                              if (manifest) {
                                                moduleURL = pathToFileURL(filename);
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 2 days to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 1205..1257

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

                                            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

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

                                            function applyExports(basePath, expansion) {
                                              const mappingKey = `.${expansion}`;
                                            
                                              let pkgExports = readPackageExports(basePath);
                                              if (pkgExports === undefined || pkgExports === null)
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 2 days to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 468..519

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

                                            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

                                            Module.prototype.load = function(filename) {
                                              debug('load %j for module %j', filename, this.id);
                                            
                                              assert(!this.loaded);
                                              this.filename = filename;
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 2 days to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 1088..1127

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

                                            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

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

                                              if (typeof options === 'object' && options !== null) {
                                                if (ArrayIsArray(options.paths)) {
                                                  const isRelative = request.startsWith('./') ||
                                                      request.startsWith('../') ||
                                                      ((isWindows && request.startsWith('.\\')) ||
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 1 day to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 998..1030

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

                                            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

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

                                            Module._resolveLookupPaths = function(request, parent) {
                                              if (NativeModule.canBeRequiredByUsers(request)) {
                                                debug('looking for %j in []', request);
                                                return null;
                                              }
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 1 day to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 808..845

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

                                            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 tryPackage(requestPath, exts, isMain, originalPath) {
                                              const pkg = readPackageMain(requestPath);
                                            
                                              if (!pkg) {
                                                return tryExtensions(path.resolve(requestPath, 'index'), exts, isMain);
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 1 day to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 318..353

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

                                            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

                                            Module._initPaths = function() {
                                              const homeDir = isWindows ? process.env.USERPROFILE : safeGetenv('HOME');
                                              const nodePath = isWindows ? process.env.NODE_PATH : safeGetenv('NODE_PATH');
                                            
                                              // process.execPath is $PREFIX/bin/node except on Windows where it is
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 1 day to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 1358..1385

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

                                            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 wrapSafe(filename, content, cjsModuleInstance) {
                                              if (patched) {
                                                const wrapper = Module.wrap(content);
                                                return vm.runInThisContext(wrapper, {
                                                  filename,
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 1 day to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 1152..1199

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

                                            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

                                            Module._extensions['.node'] = function(module, filename) {
                                              if (manifest) {
                                                const content = fs.readFileSync(filename);
                                                const moduleURL = pathToFileURL(filename);
                                                manifest.assertIntegrity(moduleURL, content);
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 6 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 1295..1309

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

                                            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 isConditionalDotExportSugar(exports, basePath) {
                                              if (typeof exports === 'string')
                                                return true;
                                              if (ArrayIsArray(exports))
                                                return true;
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 5 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 444..466

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

                                            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

                                            Module._preloadModules = function(requests) {
                                              if (!ArrayIsArray(requests))
                                                return;
                                            
                                              // Preloaded modules have a dummy parent module which is deemed to exist
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 5 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 1387..1404

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

                                            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

                                            Module._extensions['.json'] = function(module, filename) {
                                              const content = fs.readFileSync(filename, 'utf8');
                                            
                                              if (manifest) {
                                                const moduleURL = pathToFileURL(filename);
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 4 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 1277..1291

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

                                            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

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

                                            function readPackageScope(checkPath) {
                                              const rootSeparatorIndex = checkPath.indexOf(path.sep);
                                              let separatorIndex;
                                              while (
                                                (separatorIndex = checkPath.lastIndexOf(path.sep)) > rootSeparatorIndex
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 4 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 290..306

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

                                            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

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

                                            function findLongestRegisteredExtension(filename) {
                                              const name = path.basename(filename);
                                              let currentExtension;
                                              let index;
                                              let startIndex = 0;
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 4 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 393..405

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

                                            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

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

                                            function createRequire(filename) {
                                              let filepath;
                                            
                                              if (filename instanceof URL ||
                                                  (typeof filename === 'string' && !path.isAbsolute(filename))) {
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 4 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 1337..1354

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

                                            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

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

                                            function createRequireFromPath(filename) {
                                              // Allow a directory to be passed as the filename
                                              const trailingSlash =
                                                filename.endsWith('/') || (isWindows && filename.endsWith('\\'));
                                            
                                            
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 4 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 1311..1325

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

                                            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

                                                for (const p of keys) {
                                                  switch (p) {
                                                    case 'node':
                                                    case 'require':
                                                      try {
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 4 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 608..627

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

                                            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 Module(id = '', parent) {
                                              this.id = id;
                                              this.path = path.dirname(id);
                                              this.exports = {};
                                              this.parent = parent;
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 3 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 168..177

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

                                            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

                                                if (threw) {
                                                  delete Module._cache[filename];
                                                  if (parent !== undefined) {
                                                    delete relativeResolveCache[relResolveCacheIdentifier];
                                                    const children = parent && parent.children;
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 3 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 966..983

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

                                            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

                                            Similar blocks of code found in 3 locations. Consider refactoring.
                                            Open

                                            const {
                                              ArrayIsArray,
                                              Error,
                                              JSONParse,
                                              Map,
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 2 other locations - About 3 hrs to fix
                                            current/lib/internal/util/comparisons.js on lines 3..23
                                            lts/lib/internal/util/comparisons.js on lines 3..23

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

                                            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

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

                                            function isArrayIndex(p) {
                                              assert(typeof p === 'string');
                                              const n = Number(p);
                                              if (String(n) !== p)
                                                return false;
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 3 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 541..551

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

                                            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 stat(filename) {
                                              filename = path.toNamespacedPath(filename);
                                              if (statCache !== null) {
                                                const result = statCache.get(filename);
                                                if (result !== undefined) return result;
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 3 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 151..160

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

                                            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 resolveExports(nmPath, request) {
                                              // The implementation's behavior is meant to mirror resolution in ESM.
                                              const [, name, expansion = ''] =
                                                StringPrototypeMatch(request, EXPORTS_PATTERN) || [];
                                              if (!name) {
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 2 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 525..539

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

                                            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

                                            Module.prototype.require = function(id) {
                                              validateString(id, 'id');
                                              if (id === '') {
                                                throw new ERR_INVALID_ARG_VALUE('id', id,
                                                                                'must be a non-empty string');
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 2 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 1132..1144

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

                                            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

                                              try {
                                                // Intercept exceptions that occur during the first tick and rekey them
                                                // on error instance rather than module instance (which will immediately be
                                                // garbage collected).
                                                if (enableSourceMaps) {
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 2 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 950..984

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

                                            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

                                                if (StringPrototypeStartsWith(target, './')) {
                                                  resolvedTarget = new URL(target, baseUrl);
                                                  resolvedTargetPath = resolvedTarget.pathname;
                                                  if (!StringPrototypeStartsWith(resolvedTargetPath, pkgPathPath) ||
                                                      StringPrototypeIndexOf(resolvedTargetPath, '/node_modules/',
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 2 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 557..564

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

                                            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 tryExtensions(p, exts, isMain) {
                                              for (let i = 0; i < exts.length; i++) {
                                                const filename = tryFile(p + exts[i], isMain);
                                            
                                                if (filename) {
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 2 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 380..389

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

                                            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

                                              if (request === pkg.name) {
                                                expansion = '';
                                              } else if (StringPrototypeStartsWith(request, `${pkg.name}/`)) {
                                                expansion = StringPrototypeSlice(request, pkg.name.length);
                                              } else {
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 2 hrs to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 429..435

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

                                            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

                                                for (const targetValue of target) {
                                                  try {
                                                    return resolveExportsTarget(baseUrl, targetValue, subpath, mappingKey);
                                                  } catch (e) {
                                                    lastException = e;
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 1 hr to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 589..598

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

                                            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

                                            let wrapperProxy = new Proxy(wrapper, {
                                              set(target, property, value, receiver) {
                                                patched = true;
                                                return ReflectSet(target, property, value, receiver);
                                              },
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 1 hr to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 207..217

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

                                            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 tryFile(requestPath, isMain) {
                                              const rc = stat(requestPath);
                                              if (rc !== 0) return;
                                              if (preserveSymlinks && !isMain) {
                                                return path.resolve(requestPath);
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 1 hr to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 364..371

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

                                            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

                                            Module.syncBuiltinESMExports = function syncBuiltinESMExports() {
                                              for (const mod of NativeModule.map.values()) {
                                                if (mod.canBeRequiredByUsers) {
                                                  mod.syncExports();
                                                }
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 1 hr to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 1406..1412

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

                                            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

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

                                            function updateChildren(parent, child, scan) {
                                              const children = parent && parent.children;
                                              if (children && !(scan && children.includes(child)))
                                                children.push(child);
                                            }
                                            Severity: Major
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 1 hr to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 162..166

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

                                            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 {
                                              ERR_INVALID_ARG_VALUE,
                                              ERR_INVALID_OPT_VALUE,
                                              ERR_INVALID_PACKAGE_CONFIG,
                                              ERR_INVALID_PACKAGE_TARGET,
                                            Severity: Minor
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 50 mins to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 92..100

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

                                            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

                                              try {
                                                const parsed = JSONParse(json);
                                                const filtered = {
                                                  name: parsed.name,
                                                  main: parsed.main,
                                            Severity: Minor
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 40 mins to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 272..287

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

                                            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

                                              for (let cursor = parent;
                                                cursor;
                                                cursor = cursor.parent) {
                                                requireStack.push(cursor.filename || cursor.id);
                                              }
                                            Severity: Minor
                                            Found in lts/lib/internal/modules/cjs/loader.js and 1 other location - About 40 mins to fix
                                            current/lib/internal/modules/cjs/loader.js on lines 1070..1074

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

                                            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