HansHammel/watchmen

View on GitHub

Showing 25 of 1,086 total issues

Function addSorting has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

var addSorting = (function () {
    "use strict";
    var cols,
        currentSort = {
            index: 0,
Severity: Minor
Found in coverage/lcov-report/sorter.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 addSorting has 127 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var addSorting = (function () {
    "use strict";
    var cols,
        currentSort = {
            index: 0,
Severity: Major
Found in coverage/lcov-report/sorter.js - About 5 hrs to fix

    Function getRoutes has 114 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports.getRoutes = function (storage) {
    
      if (!storage) {
        throw new Error('storage needed');
      }
    Severity: Major
    Found in webserver/routes/api-service-route.js - About 4 hrs to fix

      Function ping has 80 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      WatchMen.prototype.ping = function (params, callback) {
      
        var self = this;
        var storage = self.storage;
        var service = params.service;
      Severity: Major
      Found in lib/watchmen.js - About 3 hrs to fix

        Function run has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function run(programOptions, callback) {
        
          var pingInterval = programOptions.pingInterval ||  DEFAULT_PING_INTERVAL;
          var numberDaysBack = programOptions.numberDaysBack ||  DEFAULT_NUMBER_DAYS_BACK;
          var numberPingsBack = numberDaysBack * 1000 * 60 * 60 * 24 / pingInterval;
        Severity: Major
        Found in scripts/data-load/populate-dummy-data.js - About 2 hrs to fix

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

          exports = module.exports = (function () {
          
            function isServiceRestrictedToEmail(service, email) {
              if (!service) {
                return false;
          Severity: Minor
          Found in lib/service-access-filter.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 getService has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          Reporter.prototype.getService = function(serviceId, callback){
            var storage = this.storage;
          
            debug('loading service');
          
          
          Severity: Major
          Found in lib/reporter.js - About 2 hrs to fix

            Function exports has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports = (function (){
            
              function md5(str) {
                var hash = crypto.createHash('md5');
                hash.update(str.toLowerCase().trim());
            Severity: Minor
            Found in webserver/routes/web-auth-route.js - About 1 hr to fix

              Function generateLatencyChart has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function generateLatencyChart (options) {
              
                  return c3.generate({
                    size: options.size,
                    bindto: options.id,
              Severity: Minor
              Found in webserver/public/js/charting/charting.js - About 1 hr to fix

                Function exports has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                exports = module.exports = (function(){
                
                  function validateOptionalInt(service, errors, field, options) {
                    if (service[field]){
                      validateInt(service, errors, field, options);
                Severity: Minor
                Found in lib/service-validator.js - About 1 hr to fix

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

                  module.exports.getRoutes = function (storage){
                  
                    if (!storage) {
                      throw new Error('storage needed');
                    }
                  Severity: Minor
                  Found in webserver/routes/api-report-route.js - About 1 hr to fix

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

                    exports = module.exports = (function () {
                    
                      function isServiceRestrictedToEmail(service, email) {
                        if (!service) {
                          return false;
                    Severity: Minor
                    Found in lib/service-access-filter.js - About 1 hr to fix

                      Function render has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        Charting.render = function (options) {
                      
                          var latencyData = parseArrayObjectsForCharting(options.latency, 't', 'l');
                      
                          var latencySerie = latencyData.data;
                      Severity: Minor
                      Found in webserver/public/js/charting/charting.js - About 1 hr to fix

                        Function getLatencySince has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                        StorageRedis.prototype.getLatencySince = function (service, timestamp, aggregatedBy, callback) {
                          this.redis.zrevrangebyscore(service.id + ':' + LATENCY_KEY_SUFIX, '+inf', timestamp || '-inf', 'withscores', function (err, data) {
                            if (err) {
                              return callback(err);
                            }
                        Severity: Minor
                        Found in lib/storage/providers/redis.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 exports has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                        exports = module.exports = (function(){
                        
                          function validateOptionalInt(service, errors, field, options) {
                            if (service[field]){
                              validateInt(service, errors, field, options);
                        Severity: Minor
                        Found in lib/service-validator.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 getGeneralServiceInfo has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function getGeneralServiceInfo(service, storage, callback) {
                        
                          storage.getCurrentOutage(service, function(err, currentOutage){
                            if (err) {
                              return callback(err);
                        Severity: Minor
                        Found in lib/reporter.js - About 1 hr to fix

                          Function configureApp has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              configureApp : function (app){
                          
                                passport.use(new GoogleStrategy({
                                    clientID: config.auth.GOOGLE_CLIENT_ID,
                                    clientSecret: config.auth.GOOGLE_CLIENT_SECRET,
                          Severity: Minor
                          Found in webserver/routes/web-auth-route.js - About 1 hr to fix

                            Function getUptime has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            function getUptime (service, outages, currentOutage, since) {
                            
                              var totalDownTime = 0;
                              var now = +new Date();
                              
                            Severity: Minor
                            Found in lib/reporter.js - About 1 hr to fix

                              Function exports has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              exports = module.exports = function(storage){
                                if (!storage) {
                                  throw new Error('storage is required');
                                }
                              
                              
                              Severity: Minor
                              Found in webserver/app.js - About 1 hr to fix

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

                                function parseLatencyDataFromZset(zset) {
                                  var list = [];
                                  var currentObj;
                                  var accLatency = 0;
                                  for (var i = 0; i < zset.length; i++) {
                                Severity: Minor
                                Found in lib/storage/providers/redis.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

                                Severity
                                Category
                                Status
                                Source
                                Language