HansHammel/watchmen

View on GitHub

Showing 1,086 of 1,086 total issues

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

  router.delete('/services/:id', requireAdmin, function (req, res) {
    var id = req.params.id;
    if (!id) {
      return res.status(404).json({error: 'ID parameter not found'});
    }
Severity: Major
Found in webserver/routes/api-service-route.js and 1 other location - About 1 day to fix
webserver/routes/api-service-route.js on lines 109..130

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

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

  router.post('/services/:id/reset', requireAdmin, function (req, res) {
    var id = req.params.id;
    if (!id) {
      return res.status(404).json({error: 'ID parameter not found'});
    }
Severity: Major
Found in webserver/routes/api-service-route.js and 1 other location - About 1 day to fix
webserver/routes/api-service-route.js on lines 47..68

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

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

      $scope.save = function () {

        $scope.service.pingServiceOptions = {};
        $scope.service.pingServiceOptions[$scope.service.pingServiceName] = $scope.selectedPingServiceOptions;

Severity: Major
Found in webserver/public/js/controllers/service-edit.js and 1 other location - About 6 hrs to fix
webserver/public/js/controllers/service-add.js on lines 33..47

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

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

      $scope.save = function () {

        $scope.service.pingServiceOptions = {};
        $scope.service.pingServiceOptions[$scope.service.pingServiceName] = $scope.selectedPingServiceOptions;

Severity: Major
Found in webserver/public/js/controllers/service-add.js and 1 other location - About 6 hrs to fix
webserver/public/js/controllers/service-edit.js on lines 47..61

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

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

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

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

      Sentinel.prototype._findAdded = function (databaseServices, runningServices) {
        var added = [];
        databaseServices.forEach(function (s) {
          if (!_.find(runningServices, function (rs) {
                return rs.id == s.id;
      Severity: Major
      Found in lib/sentinel.js and 1 other location - About 3 hrs to fix
      lib/sentinel.js on lines 44..54

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

      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

      Sentinel.prototype._findRemoved = function (databaseServices, runningServices) {
        var removed = [];
        runningServices.forEach(function (runningService) {
          if (!_.find(databaseServices, function (s) {
                return s.id == runningService.id;
      Severity: Major
      Found in lib/sentinel.js and 1 other location - About 3 hrs to fix
      lib/sentinel.js on lines 32..42

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

      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

      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

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

                  $scope.delete = function (id) {
                    if (confirm('Are you sure you want to delete this service and all its data?')) {
                      Service.delete({id: id}, function () {
                        reload(function () {
                        }, function () {
          Severity: Major
          Found in webserver/public/js/controllers/services-list.js and 1 other location - About 2 hrs to fix
          webserver/public/js/controllers/services-list.js on lines 98..107

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

          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

                  $scope.reset = function (id) {
                    if (confirm('Are you sure you want to reset this service\'s data?')) {
                      Service.reset({id: id}, function () {
                        reload(function () {
                        }, function () {
          Severity: Major
          Found in webserver/public/js/controllers/services-list.js and 1 other location - About 2 hrs to fix
          webserver/public/js/controllers/services-list.js on lines 87..96

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

          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

          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

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

                        charts.push(Charting.render({
                          threshold: data.service.warningThreshold,
                          latency: latencyLast24Hours.list,
                          outages: data.status.last24Hours.outages,
                          id: '#chart-last-24-hours',
            Severity: Major
            Found in webserver/public/js/controllers/service-details.js and 1 other location - About 1 hr to fix
            webserver/public/js/controllers/service-details.js on lines 74..81

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

            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

                        charts.push(Charting.render({
                          threshold: data.service.warningThreshold,
                          latency: latencyLastHour.list,
                          outages: data.status.lastHour.outages,
                          id: '#chart-last-hour',
            Severity: Major
            Found in webserver/public/js/controllers/service-details.js and 1 other location - About 1 hr to fix
            webserver/public/js/controllers/service-details.js on lines 86..93

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

            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

            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
                  Severity
                  Category
                  Status
                  Source
                  Language