lib/module.js

Summary

Maintainability
D
1 day
Test Coverage

File module.js has 335 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: Minor
Found in lib/module.js - About 4 hrs to fix

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

    Module.prototype._compile = function(content, filename) {
      var self = this;
      // remove shebang
      content = content.replace(/^\#\!.*/, '');
    
    
    Severity: Major
    Found in lib/module.js - About 2 hrs to fix

      Function _compile has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      Module.prototype._compile = function(content, filename) {
        var self = this;
        // remove shebang
        content = content.replace(/^\#\!.*/, '');
      
      
      Severity: Minor
      Found in lib/module.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 _findPath has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      Module._findPath = function(request, paths) {
        var exts = Object.keys(Module._extensions);
      
        if (request.charAt(0) === '/') {
          paths = [''];
      Severity: Minor
      Found in lib/module.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 _resolveLookupPaths has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      Module._resolveLookupPaths = function(request, parent) {
        if (NativeModule.exists(request)) {
          return [request, []];
        }
      
      
      Severity: Minor
      Found in lib/module.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 _load has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      Module._load = function(request, parent, isMain) {
        if (parent) {
          debug('Module._load REQUEST  ' + (request) + ' parent: ' + parent.id);
        }
      
      
      Severity: Minor
      Found in lib/module.js - About 1 hr to fix

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

        Module._findPath = function(request, paths) {
          var exts = Object.keys(Module._extensions);
        
          if (request.charAt(0) === '/') {
            paths = [''];
        Severity: Minor
        Found in lib/module.js - About 1 hr to fix

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

          Module._resolveLookupPaths = function(request, parent) {
            if (NativeModule.exists(request)) {
              return [request, []];
            }
          
          
          Severity: Minor
          Found in lib/module.js - About 1 hr to fix

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

            Module._load = function(request, parent, isMain) {
              if (parent) {
                debug('Module._load REQUEST  ' + (request) + ' parent: ' + parent.id);
              }
            
            
            Severity: Minor
            Found in lib/module.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

            There are no issues that match your filters.

            Category
            Status