superdesk/superdesk-client-core

View on GitHub
scripts/apps/ingest/directives/IngestSourcesContent.ts

Summary

Maintainability
F
1 wk
Test Coverage

Function IngestSourcesContent has 520 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function IngestSourcesContent(ingestSources, api, $location,
    modal, $filter, privileges) {
    return {
        templateUrl: 'scripts/apps/ingest/views/settings/ingest-sources-content.html',
        link: function($scope) {
Severity: Major
Found in scripts/apps/ingest/directives/IngestSourcesContent.ts - About 2 days to fix

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

            link: function($scope) {
                $scope.waitForDirectiveReady = function() {
                    return Promise.all([
                        ingestSources.fetchAllFeedingServicesAllowed(),
                    ]);
    Severity: Major
    Found in scripts/apps/ingest/directives/IngestSourcesContent.ts - About 2 days to fix

      File IngestSourcesContent.ts has 572 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import _, {throttle} from 'lodash';
      import {cloneDeep} from 'lodash';
      import {gettext} from 'core/utils';
      import {appConfig} from 'appConfig';
      import {IBaseRestApiResponse} from 'superdesk-api';
      Severity: Major
      Found in scripts/apps/ingest/directives/IngestSourcesContent.ts - About 1 day to fix

        Function save has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                        $scope.save = function() {
                            _.forEach($scope.currentFeedingService.fields, (field) => {
                                if (field.type !== 'mapping') {
                                    return;
                                }
        Severity: Major
        Found in scripts/apps/ingest/directives/IngestSourcesContent.ts - About 2 hrs to fix

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

                          $scope.gotoIngest = function(provider) {
                              const contentTypes = provider.content_types;
                              const length = provider.content_types.includes('preformatted') || (
                                  contentTypes.includes('planning') && contentTypes.includes('event')) ? 2 : 1;
          
          
          Severity: Minor
          Found in scripts/apps/ingest/directives/IngestSourcesContent.ts - About 1 hr to fix

            Function initTupleFields has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                            function initTupleFields() {
                                $scope.fieldAliases = {};
                                $scope.fieldsNotSelected = {};
                                $scope.currentFeedingService = $scope.provider ? _.find($scope.feedingServices,
                                    {feeding_service: $scope.provider.feeding_service}) : null;
            Severity: Minor
            Found in scripts/apps/ingest/directives/IngestSourcesContent.ts - About 1 hr to fix

              Function fetchProviders has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                              function fetchProviders() {
                                  var criteria = criteria || {};
              
                                  criteria.max_results = $location.search().max_results || 200;
                                  criteria.page = $scope.searchPage || $location.search().page || 1;
              Severity: Minor
              Found in scripts/apps/ingest/directives/IngestSourcesContent.ts - About 1 hr to fix

                Function IngestSourcesContent has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                export function IngestSourcesContent(ingestSources, api, $location,
                    modal, $filter, privileges) {
                Severity: Minor
                Found in scripts/apps/ingest/directives/IngestSourcesContent.ts - About 45 mins to fix

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

                                  $scope.remove = function(provider) {
                                      modal.confirm(gettext('Are you sure you want to delete Ingest Source?')).then(
                                          function removeIngestProviderChannel() {
                                              api.ingestProviders.remove(provider)
                                                  .then(
                  Severity: Major
                  Found in scripts/apps/ingest/directives/IngestSourcesContent.ts and 1 other location - About 6 hrs to fix
                  scripts/apps/search-providers/directive.ts on lines 86..105

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

                  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

                                  eventListenersToRemoveBeforeUnmounting.push(
                                      addWebsocketEventListener('resource:created', (event) => {
                                          const {resource} = event.extra;
                                          const itemBeingEditedOrCreated = $scope.provider != null && $scope.provider !== false;
                  
                  
                  Severity: Major
                  Found in scripts/apps/ingest/directives/IngestSourcesContent.ts and 1 other location - About 2 hrs to fix
                  scripts/apps/ingest/directives/IngestSourcesContent.ts on lines 773..785

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

                  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

                                  eventListenersToRemoveBeforeUnmounting.push(
                                      addWebsocketEventListener('resource:deleted', (event) => {
                                          const {resource} = event.extra;
                                          const itemBeingEditedOrCreated = $scope.provider != null && $scope.provider !== false;
                  
                  
                  Severity: Major
                  Found in scripts/apps/ingest/directives/IngestSourcesContent.ts and 1 other location - About 2 hrs to fix
                  scripts/apps/ingest/directives/IngestSourcesContent.ts on lines 759..771

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

                  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.fileTypes = [
                                      {
                                          type: 'text',
                                          icon: 'icon-text',
                                      },
                  Severity: Major
                  Found in scripts/apps/ingest/directives/IngestSourcesContent.ts and 1 other location - About 1 hr to fix
                  scripts/apps/authoring/authoring/services/AuthoringThemesService.ts on lines 37..62

                  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

                                  $scope.statusFilters = [
                                      {label: gettext('Active'), id: 'active'},
                                      {label: gettext('All'), id: 'all'},
                                      {label: gettext('Closed'), id: 'closed'},
                                  ];
                  Severity: Major
                  Found in scripts/apps/ingest/directives/IngestSourcesContent.ts and 1 other location - About 1 hr to fix
                  scripts/apps/publish/directives/SubscribersDirective.ts on lines 61..65

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

                  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 4 locations. Consider refactoring.
                  Open

                                  api('rule_sets').query({max_results: 200})
                                      .then((result) => {
                                          $scope.rulesets = $filter('sortByName')(result._items);
                                      });
                  Severity: Major
                  Found in scripts/apps/ingest/directives/IngestSourcesContent.ts and 3 other locations - About 1 hr to fix
                  scripts/apps/ingest/directives/IngestRoutingContent.ts on lines 248..251
                  scripts/apps/ingest/directives/IngestRulesContent.ts on lines 13..16
                  scripts/apps/ingest/directives/IngestSourcesContent.ts on lines 221..224

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

                  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 4 locations. Consider refactoring.
                  Open

                                  api('routing_schemes').query({max_results: 200})
                                      .then((result) => {
                                          $scope.routingScheme = $filter('sortByName')(result._items);
                                      });
                  Severity: Major
                  Found in scripts/apps/ingest/directives/IngestSourcesContent.ts and 3 other locations - About 1 hr to fix
                  scripts/apps/ingest/directives/IngestRoutingContent.ts on lines 248..251
                  scripts/apps/ingest/directives/IngestRulesContent.ts on lines 13..16
                  scripts/apps/ingest/directives/IngestSourcesContent.ts on lines 216..219

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

                  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.fieldsNotSelected[field.id] = field.first_field_options.values.filter(
                                          (fieldName) => !(fieldName in selectedFields),
                                      );
                  Severity: Minor
                  Found in scripts/apps/ingest/directives/IngestSourcesContent.ts and 1 other location - About 30 mins to fix
                  scripts/apps/ingest/directives/IngestSourcesContent.ts on lines 399..401

                  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

                                              $scope.fieldsNotSelected[field.id] = field.first_field_options.values.filter(
                                                  (fieldName) => !(fieldName in aliasObj),
                                              );
                  Severity: Minor
                  Found in scripts/apps/ingest/directives/IngestSourcesContent.ts and 1 other location - About 30 mins to fix
                  scripts/apps/ingest/directives/IngestSourcesContent.ts on lines 474..476

                  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