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

                                <Form.FormGroup inlineLabel={true}>
                                    <Form.FormItem>
                                        <Input
                                            type="text"
                                            label="Slugline"
Severity: Major
Found in scripts/apps/authoring-react/ui-framework-authoring-test.tsx and 1 other location - About 3 hrs to fix
scripts/apps/authoring-react/ui-framework-authoring-test.tsx on lines 194..208

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

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

                                <Button
                                    text={gettext('Replace')}
                                    onClick={() => {
                                        dispatchEditorEvent('find_and_replace__replace', {
                                            editorId,
scripts/apps/authoring-react/article-widgets/find-and-replace.tsx on lines 142..156

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

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

                                <Button
                                    text={gettext('Replace all')}
                                    onClick={() => {
                                        dispatchEditorEvent('find_and_replace__replace', {
                                            editorId,
scripts/apps/authoring-react/article-widgets/find-and-replace.tsx on lines 126..140

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

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: IProps) {
        super(props);
        this.onItemClick = this.onItemClick.bind(this);
        this.onItemDoubleClick = this.onItemDoubleClick.bind(this);
        this.onPreviewSelect = this.onPreviewSelect.bind(this);
scripts/extensions/sams/src/components/assets/assetPreviewPanel.tsx on lines 68..75

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

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

                                <Form.FormGroup inlineLabel={true}>
                                    <Form.FormItem>
                                        <Input
                                            type="text"
                                            label="Genre"
Severity: Major
Found in scripts/apps/authoring-react/ui-framework-authoring-test.tsx and 1 other location - About 3 hrs to fix
scripts/apps/authoring-react/ui-framework-authoring-test.tsx on lines 179..193

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

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: IProps) {
        super(props);

        this.onEditAsset = this.onEditAsset.bind(this);
        this.onDownloadSingleAssetCompressedBinary = this.onDownloadSingleAssetCompressedBinary.bind(this);
scripts/extensions/sams/src/components/assets/assetListItem.tsx on lines 34..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 114.

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

export function getFieldContainer(
    useHeaderLayout: boolean,
    canBeToggled: boolean,
    field: IAuthoringFieldV2,
    toggledOn: boolean,

    Function componentDidMount has 98 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        componentDidMount() {
            this.initializeEditor();
    
            /**
             *
    Severity: Major
    Found in scripts/apps/authoring-react/fields/editor3/editor.tsx - About 3 hrs to fix

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

          render() {
              const config: IMediaConfig = this.props.config ?? {
                  allowPicture: true,
                  allowAudio: true,
                  allowVideo: true,
      Severity: Major
      Found in scripts/apps/authoring-react/fields/media/config.tsx - About 3 hrs to fix

        Function MacrosController has 98 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function MacrosController($scope, macros, desks, autosave, $rootScope, storage, editorResolver) {
            let expandedGroup = storage.getItem('expandedGroup') || [];
        
            $scope.loading = true;
        
        
        Severity: Major
        Found in scripts/apps/authoring/macros/macros.ts - About 3 hrs to fix

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

                      link: function(scope, element, attrs, vm) {
                      // init directive element style
                          element.css({
                              position: 'relative',
                              display: 'block',
          Severity: Major
          Found in scripts/core/upload/image-crop-directive.ts - About 3 hrs to fix

            Function mergeTranslationsFromExtensions has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            Open

            function mergeTranslationsFromExtensions(clientDir) {
                const translationsJsonTemp = path.join(clientDir, 'translations-json-temp');
                const mainTranslationsDir = path.join(clientDir, 'dist/languages');
            
                const existingTranslationFiles = new Set(
            Severity: Minor
            Found in build-tools/src/extensions/translations.js - 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 MetadataService has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
            Open

            export function MetadataService(api, subscribersService, vocabularies, $rootScope, session, $filter) {
                var service = {
                    values: {},
                    helper_text: {},
                    popup_width: {},
            Severity: Minor
            Found in scripts/apps/authoring/metadata/metadata.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

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

                    return api.save('archive_rewrite', {}, updates, item)
                        .then((newItem: IArticle) => {
                            const onRewriteAfterMiddlewares = getOnRewriteAfterMiddlewares();
            
                            return onRewriteAfterMiddlewares.reduce(
            scripts/apps/archive/related-item-widget/relatedItem.ts on lines 179..196

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

            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.loaded = this.fetchMetadataValues()
                                .then(angular.bind(this, this.fetchSubjectcodes))
                                .then(angular.bind(this, this.fetchAuthors))
                                .then(angular.bind(this, this.fetchSubscribers))
                                .then(angular.bind(this, this.fetchCities))
            Severity: Major
            Found in scripts/apps/authoring/metadata/metadata.ts and 1 other location - About 3 hrs to fix
            scripts/apps/desks/services/DesksFactory.ts on lines 322..327

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

            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

                            api.save('archive_rewrite', {},
                                {update: angular.extend({}, $scope.origItem, $scope.item)},
                                item)
                                .then((newItem) => {
                                    notify.success(gettext('Story is associated as update.'));
            Severity: Major
            Found in scripts/apps/archive/related-item-widget/relatedItem.ts and 1 other location - About 3 hrs to fix
            scripts/apps/authoring/authoring/services/AuthoringService.ts on lines 237..262

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

            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.loading = this.fetchUsers()
                                .then(angular.bind(this, this.fetchDesks))
                                .then(angular.bind(this, this.generateDeskMembers))
                                .then(angular.bind(this, this.fetchStages))
                                .then(angular.bind(this, this.generateDeskStages))
            Severity: Major
            Found in scripts/apps/desks/services/DesksFactory.ts and 1 other location - About 3 hrs to fix
            scripts/apps/authoring/metadata/metadata.ts on lines 1354..1359

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

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

            import React from 'react';
            import gettextjs from 'gettext.js';
            import {appConfig, getUserInterfaceLanguage} from 'appConfig';
            import {IVocabularyItem, IArticle, IBaseRestApiResponse, ILockInfo, IListViewFieldWithOptions} from 'superdesk-api';
            import {assertNever} from './helpers/typescript-helpers';
            Severity: Minor
            Found in scripts/core/utils.tsx - About 3 hrs to fix

              Function UploadConfig has 97 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function UploadConfig(updateVocabulary) {
                  return class UploadConfigModal extends React.PureComponent<IProps, IState> {
                      constructor(props: IProps) {
                          super(props);
              
              
              Severity: Major
              Found in scripts/apps/vocabularies/components/UploadConfigModal.tsx - About 3 hrs to fix

                Function getSelectSingleValue has 97 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function getSelectSingleValue(
                    getItems: (props: IProps) => Promise<ISelectSingleValueItems>,
                    itemsUnavailableMessage?: string,
                    getDependentFields?: (props: IProps) => Array<string>,
                ) {
                  Severity
                  Category
                  Status
                  Source
                  Language