superdesk/superdesk-client-core

View on GitHub

Showing 3,654 of 3,654 total issues

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

        const onSpikeMiddlewares
            : Array<IExtensionActivationResult['contributions']['entities']['article']['onSpike']>
            = flatMap(
                Object.values(extensions).map(({activationResult}) => activationResult),
                (activationResult) =>
Severity: Major
Found in scripts/apps/archive/index.tsx and 2 other locations - About 6 hrs to fix
scripts/apps/search/controllers/get-multi-actions.tsx on lines 171..182
scripts/apps/monitoring/MultiActionBarReact.tsx on lines 29..40

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

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

        const onSpikeMultipleMiddlewares
            : Array<IExtensionActivationResult['contributions']['entities']['article']['onSpikeMultiple']>
            = flatMap(
                Object.values(extensions).map(({activationResult}) => activationResult),
                (activationResult) =>
Severity: Major
Found in scripts/apps/search/controllers/get-multi-actions.tsx and 2 other locations - About 6 hrs to fix
scripts/apps/archive/index.tsx on lines 476..487
scripts/apps/monitoring/MultiActionBarReact.tsx on lines 29..40

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

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

File AggregateCtrl.ts has 445 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {each, forEach, isNil, partition, keyBy} from 'lodash';
import {gettext, getItemTypes} from 'core/utils';
import {SCHEDULED_OUTPUT, DESK_OUTPUT} from 'apps/desks/constants';
import {appConfig} from 'appConfig';
import {IMonitoringFilter, IStage, IDesk, IMonitoringGroup} from 'superdesk-api';
Severity: Minor
Found in scripts/apps/monitoring/controllers/AggregateCtrl.ts - About 6 hrs to fix

    Function VocabularyEditController has 166 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function VocabularyEditController(
        $scope: IScope, notify, api, metadata, cvSchema, relationsService, $timeout,
    ) {
        let componentRef: VocabularyItemsViewEdit = null;
    
    
    Severity: Major
    Found in scripts/apps/vocabularies/controllers/VocabularyEditController.tsx - About 6 hrs to fix

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

                              } else if (item.operation === 'duplicate') {
                                  return (
                                      <BaseHistoryItem items={historyItems} current={i} key={i}>
                                          <div>
                                              <strong>{gettext('Duplicate created by')}</strong>
      scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 142..548
      scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 192..548

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

      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 link has 165 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

                      link: function(originalScope, element, attrs, modelCtrl) {
                          var exp = attrs.options,
                              parsedResult = optionParser.parse(exp),
                              isMultiple = !!attrs.multiple,
                              required = false,
      Severity: Major
      Found in scripts/core/directives/SelectDirective.ts - About 6 hrs to fix

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

                                } else if (item.operation === 'duplicated_from') {
                                    return (
                                        <BaseHistoryItem items={historyItems} current={i} key={i}>
                                            <div>
                                                <strong>{gettext('Duplicated by')}</strong>
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 167..548
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 192..548

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

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

                                } else if (item.operation === 'translate') {
                                    return (
                                        <BaseHistoryItem items={historyItems} current={i} key={i}>
                                            <div>
                                                <strong>{gettext('Translated by')}</strong>
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 142..548
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 167..548

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

        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 SuperdeskProvider has 164 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function SuperdeskProvider($routeProvider, _) {
            var widgets = {};
            var activities: any = {};
            var permissions = {};
            var panes = {};
        Severity: Major
        Found in scripts/core/activity/activity.ts - About 6 hrs to fix

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

                  return this.contacts.query(this.criteria).then((items) => {
                      this.scope.$applyAsync(() => {
                          this.render(items, null, data && data.force);
                      });
                  }, (error) => {
          scripts/apps/content-api/directives/ContentAPISearchResultsDirective.ts on lines 72..86

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

          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

                                          <FormItem>
                                              <Select
                                                  label={gettext('Size From:')}
                                                  value={numberToString(this.state.localSearchParams.sizeFrom)}
                                                  onChange={this.onChange.sizeFrom}
          scripts/extensions/sams/src/components/assets/assetFilterPanel.tsx on lines 332..345

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

          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

                                          <FormItem>
                                              <Select
                                                  label={gettext('Size To:')}
                                                  value={numberToString(this.state.localSearchParams.sizeTo)}
                                                  onChange={this.onChange.sizeTo}
          scripts/extensions/sams/src/components/assets/assetFilterPanel.tsx on lines 318..331

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

          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

                  return this.contentApiSearch.query(this.criteria).then((items) => {
                      this.scope.$applyAsync(() => {
                          this.render(items, null, data && data.force);
                      });
                  }, (error) => {
          scripts/apps/contacts/directives/ContactsSearchResultsDirective.ts on lines 75..89

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

          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

              constructor(props) {
                  super(props);
          
                  this.toggle = this.toggle.bind(this);
                  this.getHighlightStatuses = this.getHighlightStatuses.bind(this);
          Severity: Major
          Found in scripts/apps/search/components/HighlightsInfo.tsx and 1 other location - About 6 hrs to fix
          scripts/apps/search/components/HighlightsList.tsx on lines 22..33

          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

                          $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

                              canUpload && (
                                  <input
                                      type="file"
                                      style={{display: 'none'}}
                                      ref={this.input}
          Severity: Major
          Found in scripts/core/ui/components/drop-zone-3.tsx and 1 other location - About 6 hrs to fix
          scripts/apps/vocabularies/components/drop-zone.tsx on lines 81..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 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

                          {this.props.onFileSelect != null && (
                              <input
                                  type="file"
                                  style={{display: 'none'}}
                                  ref={this.input}
          Severity: Major
          Found in scripts/apps/vocabularies/components/drop-zone.tsx and 1 other location - About 6 hrs to fix
          scripts/core/ui/components/drop-zone-3.tsx on lines 134..149

          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

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

          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

              constructor(props) {
                  super(props);
          
                  this.removeHighlight = this.removeHighlight.bind(this);
                  this.stopTimeout = this.stopTimeout.bind(this);
          Severity: Major
          Found in scripts/apps/search/components/HighlightsList.tsx and 1 other location - About 6 hrs to fix
          scripts/apps/search/components/HighlightsInfo.tsx on lines 24..35

          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

          Function DictionaryEditController has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
          Open

          export function DictionaryEditController($scope, dictionaries, upload, notify,
              modal, $rootScope, $q) {
              function onSuccess(result) {
                  if ($scope.isAbbreviations()) {
                      $rootScope.$broadcast('abbreviations:updated', result.content);
          Severity: Minor
          Found in scripts/apps/dictionaries/controllers/DictionaryEditController.ts - About 6 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

          Severity
          Category
          Status
          Source
          Language