superdesk/superdesk-client-core

View on GitHub
scripts/apps/monitoring/directives/WidgetGroup.ts

Summary

Maintainability
F
6 days
Test Coverage

Function WidgetGroup has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
Open

export function WidgetGroup(search, api, superdesk, desks, cards, $timeout, $q,
    $location, $anchorScroll, activityService: IActivityService, $rootScope, datetime, metadata) {
    const services = {
        $anchorScroll: $anchorScroll,
        $location: $location,
Severity: Minor
Found in scripts/apps/monitoring/directives/WidgetGroup.ts - About 1 day 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 WidgetGroup has 341 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function WidgetGroup(search, api, superdesk, desks, cards, $timeout, $q,
    $location, $anchorScroll, activityService: IActivityService, $rootScope, datetime, metadata) {
    const services = {
        $anchorScroll: $anchorScroll,
        $location: $location,
Severity: Major
Found in scripts/apps/monitoring/directives/WidgetGroup.ts - About 1 day to fix

    Function link has 312 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            link: function(scope, elem) {
                var criteria;
    
                scope.page = 1;
                scope.fetching = false;
    Severity: Major
    Found in scripts/apps/monitoring/directives/WidgetGroup.ts - About 1 day to fix

      File WidgetGroup.ts has 364 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import React from 'react';
      import ReactDOM from 'react-dom';
      import _ from 'lodash';
      
      import {WidgetItemList as WidgetItemListComponent} from 'apps/search/components';
      Severity: Minor
      Found in scripts/apps/monitoring/directives/WidgetGroup.ts - About 4 hrs to fix

        Function WidgetGroup has 13 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        export function WidgetGroup(search, api, superdesk, desks, cards, $timeout, $q,
            $location, $anchorScroll, activityService: IActivityService, $rootScope, datetime, metadata) {
        Severity: Major
        Found in scripts/apps/monitoring/directives/WidgetGroup.ts - About 1 hr to fix

          Function queryItems has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                      function queryItems(queryString?, params?) {
                          if (!scope.fetching) {
                              // page reload disabled when the user scrolls
                              if (container.scrollTop > 20) {
                                  return;
          Severity: Minor
          Found in scripts/apps/monitoring/directives/WidgetGroup.ts - About 1 hr to fix

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

                        scope.move = function(diff, event) {
                            if (!_.isNil(scope.selected) && $rootScope.config.features.customMonitoringWidget && scope.itemIds) {
                                var itemId = scope.generateTrackByIdentifier(scope.selected);
                                var index = scope.itemIds.findIndex((x) => x === itemId);
            
            
            Severity: Minor
            Found in scripts/apps/monitoring/directives/WidgetGroup.ts - About 1 hr to fix

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

                  const services = {
                      $anchorScroll: $anchorScroll,
                      $location: $location,
                      $q: $q,
                      $rootScope: $rootScope,
              Severity: Major
              Found in scripts/apps/monitoring/directives/WidgetGroup.ts and 1 other location - About 1 hr to fix
              scripts/api/index.ts on lines 20..34

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

              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: {
                          stage: '=',
                          total: '=',
                          canEdit: '=',
                          showEmpty: '=?',
              Severity: Minor
              Found in scripts/apps/monitoring/directives/WidgetGroup.ts and 1 other location - About 35 mins to fix
              scripts/core/upload/sdImageModify.ts on lines 5..14

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

              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

                                  if (e.keyCode) {
                                      code = e.keyCode;
                                  } else if (e.which) {
                                      code = e.which;
                                  }
              Severity: Minor
              Found in scripts/apps/monitoring/directives/WidgetGroup.ts and 1 other location - About 30 mins to fix
              scripts/core/keyboard/keyboard.ts on lines 248..252

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

              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

                                  var nextIndex = _.max([0, _.min([scope.itemIds.length - 1, index + diff])]);
              Severity: Minor
              Found in scripts/apps/monitoring/directives/WidgetGroup.ts and 1 other location - About 30 mins to fix
              scripts/core/list/list.ts on lines 76..76

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

              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

              There are no issues that match your filters.

              Category
              Status