superdesk/superdesk-client-core

View on GitHub

Showing 3,654 of 3,654 total issues

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

                            if (item.update.operation === 'deschedule') {
                                return (
                                    <BaseHistoryItem items={historyItems} current={i} key={i}>
                                        <div>
                                            <strong>{gettext('Descheduled by')}</strong>
scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 125..141

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

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 (isLogicalOperator(q)) {
        const r = {};

        if (q['$and'] != null) {
            r['and'] = q['$and'].map((_q) => toElasticFilter(_q));
Severity: Major
Found in scripts/core/query-formatting.ts and 1 other location - About 3 hrs to fix
scripts/core/query-formatting.ts on lines 55..101

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

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

                            } else {
                                return (
                                    <BaseHistoryItem items={historyItems} current={i} key={i}>
                                        <div>
                                            <strong>{gettext('Updated by')}</strong>
scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 109..125

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

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

                            <DatePickerISO
                                label={gettext('Airtime date to')}
                                dateFormat={superdesk.instance.config.view.dateformat}
                                value={filters.airtime_date?.lte ?? ''}
                                onChange={(val) => {
scripts/extensions/broadcasting/src/rundowns/components/filtering-inputs.tsx on lines 74..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 107.

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

                            <DatePickerISO
                                label={gettext('Airtime date from')}
                                dateFormat={superdesk.instance.config.view.dateformat}
                                value={filters.airtime_date?.gte ?? ''}
                                onChange={(val) => {
scripts/extensions/broadcasting/src/rundowns/components/filtering-inputs.tsx on lines 88..100

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

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 (isLogicalOperator(q)) {
        const r = {};

        if (q['$and'] != null) {
            r['$and'] = q['$and'].map((_q) => toPyEveFilter(_q));
Severity: Major
Found in scripts/core/query-formatting.ts and 1 other location - About 3 hrs to fix
scripts/core/query-formatting.ts on lines 8..51

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

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 TemplatesDirective.ts has 316 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import notifySaveError from '../helpers';
import {gettext} from 'core/utils';
import {getTemplateFilters} from '../constants';
import {dataApi} from 'core/helpers/CrudManager';
import {IArticle} from 'superdesk-api';
Severity: Minor
Found in scripts/apps/templates/directives/TemplatesDirective.ts - About 3 hrs to fix

    Function DeskeditBasic has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    export function DeskeditBasic(desks, WizardHandler, metadata, $filter, notify) {
        return {
            link: function(scope) {
                scope.limits = limits;
                scope.deskTypes = [];
    Severity: Minor
    Found in scripts/apps/desks/directives/DeskeditBasic.ts - About 3 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 ActivityService has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

            function ActivityService($location, $injector, $q, modal, _) {
                var activityStack = [];
    
                this.activityStack = activityStack;
    
    
    Severity: Minor
    Found in scripts/core/activity/activity.ts - About 3 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 render has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        render() {
            const {item, page, index, inEditMode, getId} = this.props.wrapper;
            const {
                sortingInProgress,
                setIndexForNewItem,

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

          render() {
              const shortcuts = this.props.config?.shortcuts ?? [];
      
              return (
                  <div>
      Severity: Major
      Found in scripts/apps/authoring-react/fields/date/config.tsx - About 3 hrs to fix

        Function ConfirmDirtyService has 89 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function ConfirmDirtyService($window, $q, $filter, api, modal, $interpolate, $modal) {
            /**
             * Will ask for user confirmation for user confirmation if there are some changes which are not saved.
             * - Detecting changes via $scope.dirty - it's up to the controller to set it.
             */
        Severity: Major
        Found in scripts/apps/authoring/authoring/services/ConfirmDirtyService.ts - About 3 hrs to fix

          Function GET_GROUPS has 89 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const GET_GROUPS = (userId, services: any): Array<IGroup> => {
              return [
                  {
                      id: 'locked',
                      label: gettext('Locked by this user'),

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

                    link: function(scope, elem) {
                        var ENTER = 13;
                        var ESC = 27;
            
                        scope.meta = {};
            Severity: Major
            Found in scripts/apps/search/directives/ItemGlobalSearch.ts - About 3 hrs to fix

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

                              <PanelContent markupV2={markupV2}>
                                  <ToggleBox title={gettext('Destination')} initiallyOpen>
                                      <DestinationSelect
                                          value={this.state.selectedDestination}
                                          onChange={(value) => {
              scripts/core/interactive-article-actions-panel/actions/unspike-tab.tsx on lines 54..66

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

              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

                              <PanelContent markupV2={markupV2}>
                                  <ToggleBox title={gettext('Destination')} initiallyOpen>
                                      <DestinationSelect
                                          value={this.state.selectedDestination}
                                          onChange={(value) => {
              scripts/core/interactive-article-actions-panel/actions/fetch-to-tab.tsx on lines 76..88

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

              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

                      } else {
                          this.scope.deskMarking = false;
                          this.scope.service = this.highlightsService;
                          this.scope.fetchFunction = 'get';
                          this.scope.idField = '_id';
              Severity: Major
              Found in scripts/apps/archive/directives/MarkedItemTitle.ts and 1 other location - About 3 hrs to fix
              scripts/apps/archive/directives/MarkedItemTitle.ts on lines 35..41

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

              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 (this.scope.markField === 'marked_desks') {
                          this.scope.deskMarking = true;
                          this.scope.service = this.desks;
                          this.scope.fetchFunction = 'fetchDesks';
                          this.scope.idField = 'desk_id';
              Severity: Major
              Found in scripts/apps/archive/directives/MarkedItemTitle.ts and 1 other location - About 3 hrs to fix
              scripts/apps/archive/directives/MarkedItemTitle.ts on lines 41..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 106.

              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 SelectFieldPopup.tsx has 314 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import React from 'react';
              import PropTypes from 'prop-types';
              import {SearchBar} from '../../';
              import {differenceBy, get} from 'lodash';
              import {scrollListItemIfNeeded, onEventCapture} from '../../utils';

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

                    render() {
                        const sourceManualEntry: IDropdownConfig['source'] = 'manual-entry';
                        const sourceVocabulary: IDropdownConfig['source'] = 'vocabulary';
                
                        const config = (() => {
                Severity: Major
                Found in scripts/apps/authoring-react/fields/dropdown/config-main.tsx - About 3 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language