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

        this.setType = function(ingestType) {
            element(by.id('subType')).all(by.tagName('option'))
                .filter((elem, index) => elem.getText().then((label) => label.toLowerCase().indexOf(ingestType) > -1))
                .then((options) => {
                    options[0].click();
Severity: Major
Found in e2e/client/specs/helpers/subscribers.ts and 1 other location - About 4 hrs to fix
e2e/client/specs/helpers/subscribers.ts on lines 56..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 129.

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

import React from 'react';
import {flatMap, noop} from 'lodash';
import {isWidgetVisibleForContentProfile} from 'apps/workspace/content/components/WidgetsConfig';
import {gettext} from 'core/utils';
import {isKilled} from 'apps/archive/utils';
Severity: Minor
Found in scripts/apps/authoring/widgets/widgets.ts - About 4 hrs to fix

    Function ItemActionsMenu has 117 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function ItemActionsMenu(
        superdesk,
        activityService: IActivityService,
        workflowService,
        archiveService,
    Severity: Major
    Found in scripts/apps/monitoring/directives/ItemActionsMenu.ts - About 4 hrs to fix

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

          render() {
              const {state} = this;
      
              if (state.loading === true) {
                  return null;
      Severity: Major
      Found in scripts/core/ui/components/content-create-dropdown/initial-view.tsx - About 4 hrs to fix

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

            <LineInput {...props} invalid={invalid} readOnly={readOnly}>
                <Label text={label} />
                <Input
                    field={field}
                    value={value}
        Severity: Major
        Found in scripts/core/ui/components/Form/TextInput.tsx and 1 other location - About 4 hrs to fix
        scripts/core/ui/components/Form/TextAreaInput.tsx on lines 28..45

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

        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

                                } else if (item.operation === 'move') {
                                    return (
                                        <BaseHistoryItem items={historyItems} current={i} key={i}>
                                            <div>
                                                <strong>{gettext('Moved by')}</strong>
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 217..548
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 233..548
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 265..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 128.

        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

                                } else if (item.operation === 'unspike') {
                                    return (
                                        <BaseHistoryItem items={historyItems} current={i} key={i}>
                                            <div>
                                                <strong>{gettext('Unspiked by')}</strong>
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 217..548
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 249..548
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 265..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 128.

        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

                                } else if (item.operation === 'spike') {
                                    return (
                                        <BaseHistoryItem items={historyItems} current={i} key={i}>
                                            <div>
                                                <strong>{gettext('Spiked by')}</strong>
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 233..548
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 249..548
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 265..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 128.

        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

            <LineInput {...props} readOnly={readOnly}>
                <Label text={label} />
                <TextArea
                    field={field}
                    value={value}
        Severity: Major
        Found in scripts/core/ui/components/Form/TextAreaInput.tsx and 1 other location - About 4 hrs to fix
        scripts/core/ui/components/Form/TextInput.tsx on lines 27..44

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

        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

                                } else if (item.operation === 'fetch') {
                                    return (
                                        <BaseHistoryItem items={historyItems} current={i} key={i}>
                                            <div>
                                                <strong>{gettext('Fetched by')}</strong>
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 217..548
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 233..548
        scripts/apps/authoring-react/article-widgets/versions-and-item-history/history-tab.tsx on lines 249..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 128.

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

            render() {
                const {
                    profile1,
                    profile2,
                    fieldsData1,
        Severity: Major
        Found in scripts/apps/authoring-react/compare-articles/view-difference.tsx - About 4 hrs to fix

          Function superdeskFactory has 116 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  function superdeskFactory($q, $rootScope, activityService, activityChooser, betaService,
                      features, privileges, $injector) {
                      /**
                       * Render main menu depending on registered acitivites
                       */
          Severity: Major
          Found in scripts/core/activity/activity.ts - About 4 hrs to fix

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

                render() {
                    const {filters} = this.props;
            
                    return (
                        <Spacer h gap="4" justifyContent="start" noWrap style={{flexWrap: 'wrap'}}>

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

                  constructor(props) {
                      super(props);
                      this.state = {isOpen: this.props.isOpen};
                      this.scrollInView = this.scrollInView.bind(this);
                      this.toggle = this.toggle.bind(this);
              Severity: Major
              Found in scripts/apps/contacts/components/Form/ToggleBox.tsx and 1 other location - About 4 hrs to fix
              scripts/core/ui/components/ToggleBox/index.tsx on lines 21..28

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

              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

                  constructor(props) {
                      super(props);
                      this.state = {isOpen: this.props.isOpen};
                      this.scrollInView = this.scrollInView.bind(this);
                      this.toggle = this.toggle.bind(this);
              Severity: Major
              Found in scripts/core/ui/components/ToggleBox/index.tsx and 1 other location - About 4 hrs to fix
              scripts/apps/contacts/components/Form/ToggleBox.tsx on lines 15..22

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

              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 (isUserSubscription(subscriptionInCreateOrEditMode)) {
                                  const userAlreadySubscribed = user_subscriptions.some(
                                      (subscription) => subscription.user === subscriptionInCreateOrEditMode.user,
                                  );
              
              
              scripts/apps/search/directives/SavedSearchManageSubscribers.ts on lines 170..190

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

              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 (isDeskSubscription(subscriptionInCreateOrEditMode)) {
                                  const deskAlreadySubscribed = desk_subscriptions.some(
                                      (subscription) => subscription.desk === subscriptionInCreateOrEditMode.desk,
                                  );
              
              
              scripts/apps/search/directives/SavedSearchManageSubscribers.ts on lines 146..166

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

              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 getTagsListComponent has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
              Open

              export function getTagsListComponent(superdesk: ISuperdesk): React.ComponentType<IProps> {
                  const {gettext} = superdesk.localization;
                  const {arrayToTree, treeToArray} = superdesk.utilities;
              
                  return class TagList extends React.PureComponent<IProps> {
              Severity: Minor
              Found in scripts/extensions/auto-tagging-widget/src/tag-list.tsx - About 4 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 PackagesService has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
              Open

              export function PackagesService(api, $q, archiveService, lock, autosave, authoring,
                  authoringWorkspace: AuthoringWorkspaceService, desks, $rootScope) {
                  var self = this;
              
                  this.groupList = ['main', 'story', 'sidebars', 'fact box'];
              Severity: Minor
              Found in scripts/apps/packaging/services/PackagesService.ts - About 4 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 constructor has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
              Open

                  constructor() {
                      this.lock = element(by.css('[ng-click="lock()"]'));
                      this.correct_button = element(by.buttonText('correct'));
                      this.kill_button = element(by.buttonText('kill'));
                      this.close_button = element(by.buttonText('Close'));
              Severity: Minor
              Found in e2e/client/specs/helpers/authoring.ts - About 4 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