lib/timers.js

Summary

Maintainability
D
2 days
Test Coverage

File timers.js has 367 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/timers.js - About 4 hrs to fix

    Function listOnTimeout has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    function listOnTimeout() {
      var msecs = this.msecs;
      var list = this;
    
      debug('timeout callback %d', msecs);
    Severity: Minor
    Found in lib/timers.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 processImmediate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    function processImmediate() {
      var queue = immediateQueue;
      var domain, immediate;
    
      immediateQueue = {};
    Severity: Minor
    Found in lib/timers.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 listOnTimeout has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function listOnTimeout() {
      var msecs = this.msecs;
      var list = this;
    
      debug('timeout callback %d', msecs);
    Severity: Minor
    Found in lib/timers.js - About 1 hr to fix

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

      function unrefTimeout() {
        var now = Timer.now();
      
        debug('unrefTimer fired');
      
      
      Severity: Minor
      Found in lib/timers.js - About 1 hr to fix

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

        function unrefTimeout() {
          var now = Timer.now();
        
          debug('unrefTimer fired');
        
        
        Severity: Minor
        Found in lib/timers.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 processImmediate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function processImmediate() {
          var queue = immediateQueue;
          var domain, immediate;
        
          immediateQueue = {};
        Severity: Minor
        Found in lib/timers.js - About 1 hr to fix

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

          exports.setInterval = function(callback, repeat) {
            repeat *= 1; // coalesce to number or NaN
          
            if (!(repeat >= 1 && repeat <= TIMEOUT_MAX)) {
              repeat = 1; // schedule on next tick, follows browser behaviour
          Severity: Minor
          Found in lib/timers.js - About 45 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

          function _makeTimerTimeout(timer) {
            var domain = timer.domain;
            var msecs = timer._idleTimeout;
          
            // Timer has been unenrolled by another timer that fired at the same time,
          Severity: Minor
          Found in lib/timers.js - About 45 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

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

          Timeout.prototype.unref = function() {
            if (!this._handle) {
              var now = Timer.now();
              if (!this._idleStart) this._idleStart = now;
              var delay = this._idleStart + this._idleTimeout - now;
          Severity: Minor
          Found in lib/timers.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

          There are no issues that match your filters.

          Category
          Status