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

export const fields: {[key: string]: IReactFieldComponentClass<IFieldProps>} = {
    type,
    headline,
    slugline,
    wordcount,
Severity: Major
Found in scripts/apps/search/components/fields/index.ts and 1 other location - About 7 hrs to fix
scripts/apps/authoring-react/article-widgets/metadata/metadata.tsx on lines 54..92

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

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

    const allFields = Object.keys(editor)
        .filter((key) => editor[key] != null) // field doesn't exist
        .filter((key) => {
            const isHeader = editor[key].section === 'header'
                    || ARTICLE_HEADER_FIELDS.has(key as keyof IArticle)
Severity: Major
Found in scripts/apps/authoring/preview/utils.ts and 1 other location - About 7 hrs to fix
scripts/apps/authoring/preview/utils.ts on lines 14..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 186.

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 Object.keys(editor)
        .filter((key) => editor[key] != null)
        .filter(
            (key) => {
                const isHeader = editor[key].section === 'header'
Severity: Major
Found in scripts/apps/authoring/preview/utils.ts and 1 other location - About 7 hrs to fix
scripts/apps/authoring/preview/utils.ts on lines 55..74

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

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

        const {
            flags,
            usageterms,
            pubstatus,
            expiry,
scripts/apps/search/components/fields/index.ts on lines 53..91

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

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

/* eslint-disable react/no-multi-comp */

import React from 'react';
import ReactPaginate from 'react-paginate';
import ObjectEditor from './ObjectEditor';
Severity: Minor
Found in scripts/apps/vocabularies/components/VocabularyItemsViewEdit.tsx - About 7 hrs to fix

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

        render() {
            const {gettext, gettextPlural} = superdeskApi.localization;
            const {numberToString} = superdeskApi.helpers;
    
            const items = this.getMenuItems();
    Severity: Major
    Found in scripts/extensions/sams/src/components/workspaceSubnav.tsx - About 7 hrs to fix

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

                      link: function(scope, elem) {
                          var img, cropData, selectionWidth, selectionHeight, jcropApi;
      
                          /**
                      * Test if crop data a equals to crop data b
      Severity: Major
      Found in scripts/core/upload/image-crop-directive.ts - About 7 hrs to fix

        Function DesksFactory has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
        Open

        export function DesksFactory($q, api, preferencesService, userList, notify,
            session, $filter, privileges, $rootScope) {
            let _cache = {};
        
            var _fetchAll = function(endpoint, parent?, page = 1, items = [], refresh = false) {
        Severity: Minor
        Found in scripts/apps/desks/services/DesksFactory.ts - About 7 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 getBulkActions has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
        Open

        export function getBulkActions(
            articles: Array<IArticle>,
            multiActions: IMultiActions,
            getSelectedItems: () => Array<IArticle>,
            unselectAll: () => void,
        Severity: Minor
        Found in scripts/apps/search/controllers/get-bulk-actions.tsx - About 7 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 link has 185 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                link: function(scope, elem) {
                    var orig = null;
        
                    elem.find('.stages-list').sortable({
                        cursor: 'move',
        Severity: Major
        Found in scripts/apps/desks/directives/DeskeditStages.ts - About 7 hrs to fix

          Function PackagesService has 184 lines of code (exceeds 25 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: Major
          Found in scripts/apps/packaging/services/PackagesService.ts - About 7 hrs to fix

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

                render() {
                    function getWidgetsFromExtensions(article: IArticle): Array<IArticleSideWidget> {
                        return Object.values(extensions)
                            .flatMap((extension) => extension.activationResult?.contributions?.authoringSideWidgets ?? [])
                            .filter((widget) => widget.isAllowed?.(article) ?? true)
            Severity: Major
            Found in scripts/apps/authoring-react/authoring-integration-wrapper.tsx - About 7 hrs to fix

              Function WidgetsManagerCtrl has 184 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function WidgetsManagerCtrl(
                  $scope: IScope,
                  $routeParams,
                  authoringWidgets: Array<IWidget>,
                  archiveService,
              Severity: Major
              Found in scripts/apps/authoring/widgets/widgets.ts - About 7 hrs to fix

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

                                <Row>
                                    <LineInput readOnly={readOnly} required={isRequired} invalid={showMinFieldsWarning}>
                                        <Label text={getMinRequiredFieldLabel('contact_phone')} />
                                        {showMinFieldsWarning && (
                                            <div className="sd-line-input__message">
                Severity: Major
                Found in scripts/apps/contacts/components/Form/ProfileDetail.tsx and 1 other location - About 7 hrs to fix
                scripts/apps/contacts/components/Form/ProfileDetail.tsx on lines 414..432

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

                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

                    it('should get suggestion of first item in array when triggered',
                        inject((suggest, autosave, $q, api, $rootScope) => {
                            const item = testItems[0];
                
                            spyOn(autosave, 'save').and.returnValue($q.when(testItems));
                Severity: Major
                Found in scripts/apps/authoring/suggest/suggest.spec.ts and 1 other location - About 7 hrs to fix
                scripts/apps/authoring/suggest/suggest.spec.ts on lines 65..78

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

                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

                                    <Row>
                                        <LineInput readOnly={readOnly} required={isRequired} invalid={showMinFieldsWarning}>
                                            <Label text={getMinRequiredFieldLabel('mobile')} />
                                            {showMinFieldsWarning && (
                                                <div className="sd-line-input__message">
                Severity: Major
                Found in scripts/apps/contacts/components/Form/ProfileDetail.tsx and 1 other location - About 7 hrs to fix
                scripts/apps/contacts/components/Form/ProfileDetail.tsx on lines 392..410

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

                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

                    it('should get suggestions when triggered', inject((suggest, autosave, $q, api, $rootScope) => {
                        const item = testItems[0];
                
                        spyOn(autosave, 'save').and.returnValue($q.when(item));
                        spyOn(api, 'get').and.returnValue($q.reject());
                Severity: Major
                Found in scripts/apps/authoring/suggest/suggest.spec.ts and 1 other location - About 7 hrs to fix
                scripts/apps/authoring/suggest/suggest.spec.ts on lines 80..95

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

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

                import _, {noop} from 'lodash';
                import React from 'react';
                import classNames from 'classnames';
                import {Item} from './index';
                import {isCheckAllowed, closeActionsMenu, bindMarkItemShortcut} from '../helpers';
                Severity: Minor
                Found in scripts/apps/search/components/ItemList.tsx - About 7 hrs to fix

                  Function VocabularyConfigController has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function VocabularyConfigController($scope: IScope, $route, $routeParams, vocabularies, $rootScope,
                      api, notify, modal, session) {
                      $scope.loading = true;
                      $scope.mediaTypes = getMediaTypes();
                  
                  
                  Severity: Minor
                  Found in scripts/apps/vocabularies/controllers/VocabularyConfigController.ts - About 7 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 UploadController has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function UploadController(
                      $scope,
                      $q,
                      upload,
                      api,
                  Severity: Minor
                  Found in scripts/apps/archive/controllers/UploadController.ts - About 7 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