lib/repl.js

Summary

Maintainability
F
1 wk
Test Coverage

Function complete has a Cognitive Complexity of 116 (exceeds 5 allowed). Consider refactoring.
Open

REPLServer.prototype.complete = function(line, callback) {
  // There may be local variables to evaluate, try a nested REPL
  if (!util.isUndefined(this.bufferedCommand) && this.bufferedCommand.length) {
    // Get a new array of inputed lines
    var tmp = this.lines.slice();
Severity: Minor
Found in lib/repl.js - About 2 days 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

File repl.js has 671 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 lib/repl.js - About 1 day to fix

    Function complete has 200 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    REPLServer.prototype.complete = function(line, callback) {
      // There may be local variables to evaluate, try a nested REPL
      if (!util.isUndefined(this.bufferedCommand) && this.bufferedCommand.length) {
        // Get a new array of inputed lines
        var tmp = this.lines.slice();
    Severity: Major
    Found in lib/repl.js - About 1 day to fix

      Function REPLServer has 188 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function REPLServer(prompt, stream, eval_, useGlobal, ignoreUndefined) {
        if (!(this instanceof REPLServer)) {
          return new REPLServer(prompt, stream, eval_, useGlobal, ignoreUndefined);
        }
      
      
      Severity: Major
      Found in lib/repl.js - About 7 hrs to fix

        Function REPLServer has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

        function REPLServer(prompt, stream, eval_, useGlobal, ignoreUndefined) {
          if (!(this instanceof REPLServer)) {
            return new REPLServer(prompt, stream, eval_, useGlobal, ignoreUndefined);
          }
        
        
        Severity: Minor
        Found in lib/repl.js - About 5 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 memory has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        REPLServer.prototype.memory = function memory(cmd) {
          var self = this;
        
          self.lines = self.lines || [];
          self.lines.level = self.lines.level || [];
        Severity: Minor
        Found in lib/repl.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 defineDefaultCommands has 75 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function defineDefaultCommands(repl) {
          // TODO remove me after 0.3.x
          repl.defineCommand('break', {
            help: 'Sometimes you get stuck, this gets you out',
            action: function() {
        Severity: Major
        Found in lib/repl.js - About 3 hrs to fix

          Function memory has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          REPLServer.prototype.memory = function memory(cmd) {
            var self = this;
          
            self.lines = self.lines || [];
            self.lines.level = self.lines.level || [];
          Severity: Minor
          Found in lib/repl.js - About 1 hr to fix

            Function completionGroupsLoaded has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function completionGroupsLoaded(err) {
                if (err) throw err;
            
                // Filter, sort (within each group), uniq and merge the completion groups.
                if (completionGroups.length && filter) {
            Severity: Minor
            Found in lib/repl.js - About 1 hr to fix

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

              function defineDefaultCommands(repl) {
                // TODO remove me after 0.3.x
                repl.defineCommand('break', {
                  help: 'Sometimes you get stuck, this gets you out',
                  action: function() {
              Severity: Minor
              Found in lib/repl.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 defaultEval has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function defaultEval(code, context, file, cb) {
                  var err, result;
                  // first, create the Script object to check the syntax
                  try {
                    var script = vm.createScript(code, {
              Severity: Minor
              Found in lib/repl.js - About 1 hr to fix

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

                REPLServer.prototype.createContext = function() {
                  var context;
                  if (this.useGlobal) {
                    context = global;
                  } else {
                Severity: Minor
                Found in lib/repl.js - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                              if (tmp < 0) {
                                //more to go, recurse
                                depth += curr.depth;
                                workIt();
                              } else if (tmp > 0) {
                  Severity: Major
                  Found in lib/repl.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                          if (line.length === 0) {
                            filter = '';
                            expr = '';
                          } else if (line[line.length - 1] === '.') {
                            filter = '';
                    Severity: Major
                    Found in lib/repl.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                            if (!expr) {
                              // If context is instance of vm.ScriptContext
                              // Get global vars synchronously
                              if (this.useGlobal ||
                                  this.context.constructor &&
                      Severity: Major
                      Found in lib/repl.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                if (base.match(/-\d+\.\d+(\.\d+)?/) || name === '.npm') {
                                  // Exclude versioned names that 'npm' installs.
                                  continue;
                                }
                        Severity: Major
                        Found in lib/repl.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                  if (exts.indexOf(ext) !== -1) {
                                    if (!subdir || base !== 'index') {
                                      group.push(subdir + base);
                                    }
                                  } else {
                          Severity: Major
                          Found in lib/repl.js - About 45 mins to fix

                            Function start has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            exports.start = function(prompt, source, eval_, useGlobal, ignoreUndefined) {
                            Severity: Minor
                            Found in lib/repl.js - About 35 mins to fix

                              Function REPLServer has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              function REPLServer(prompt, stream, eval_, useGlobal, ignoreUndefined) {
                              Severity: Minor
                              Found in lib/repl.js - About 35 mins to fix

                                There are no issues that match your filters.

                                Category
                                Status