superdesk/superdesk-client-core

View on GitHub
scripts/core/with-resources.tsx

Summary

Maintainability
D
2 days
Test Coverage

Function constructor has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    constructor(props: ILiveResourcesProps & {onInitialized(): void}) {
        super(props);

        this.state = {};

Severity: Minor
Found in scripts/core/with-resources.tsx - About 2 hrs to fix

    Function handleContentChanges has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        handleContentChanges(_changes: Array<IResourceChange>) {
            const state = this.state;
            const dataInitialized = state.data != null;
    
            if (this.updatingRequestInProgress || dataInitialized !== true) {
    Severity: Minor
    Found in scripts/core/with-resources.tsx - About 1 hr to fix

      Function fetchItems has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          fetchItems(): Promise<void> {
              const {resources} = this.props;
      
              function toPair(resource: string, res: unknown): [string, unknown] {
                  return [resource, res];
      Severity: Minor
      Found in scripts/core/with-resources.tsx - About 1 hr to fix

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

                this.eventListenersToRemoveBeforeUnmounting.push(
                    addWebsocketEventListener(
                        'resource:created',
                        (event) => {
                            const {resource, _id} = event.extra;
        Severity: Major
        Found in scripts/core/with-resources.tsx and 1 other location - About 4 hrs to fix
        scripts/core/with-resources.tsx on lines 79..90

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

        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

            render() {
                const key = JSON.stringify(omit(this.props, 'children'));
        
                return (
                    <div>
        Severity: Major
        Found in scripts/core/with-resources.tsx and 1 other location - About 4 hrs to fix
        scripts/core/with-live-query.tsx on lines 180..198

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

        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.eventListenersToRemoveBeforeUnmounting.push(
                    addWebsocketEventListener(
                        'resource:deleted',
                        (event) => {
                            const {resource, _id} = event.extra;
        Severity: Major
        Found in scripts/core/with-resources.tsx and 1 other location - About 4 hrs to fix
        scripts/core/with-resources.tsx on lines 48..59

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

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

            constructor(props: ILiveResourcesProps) {
                super(props);
        
                this.setLoaded = this.setLoaded.bind(this);
            }
        Severity: Major
        Found in scripts/core/with-resources.tsx and 16 other locations - About 30 mins to fix
        scripts/apps/authoring-react/fields/date/config.tsx on lines 9..13
        scripts/apps/authoring-react/fields/media/media-carousel/image.tsx on lines 24..28
        scripts/apps/authoring-react/fields/urls/editor.tsx on lines 16..20
        scripts/apps/authoring-react/with-keybindings.tsx on lines 9..13
        scripts/apps/desks/components/MarkBtn.tsx on lines 11..15
        scripts/apps/search/components/SelectBox.tsx on lines 45..49
        scripts/apps/search/components/SmoothLoader.tsx on lines 16..20
        scripts/apps/search/components/SmoothLoaderOuter.tsx on lines 16..20
        scripts/core/helpers/with-popover.tsx on lines 17..21
        scripts/core/interactive-article-actions-panel/actions/send-correction-tab.tsx on lines 19..23
        scripts/extensions/broadcasting/src/authoring-fields/subitems/subitems-view-edit.tsx on lines 29..33
        scripts/extensions/sams/src/components/assets/assetTypeFilterButtons.tsx on lines 37..41
        scripts/extensions/sams/src/components/sets/manageSetsModal.tsx on lines 54..58
        scripts/extensions/sams/src/ui/grid/GridItem.tsx on lines 16..20
        scripts/extensions/sams/src/ui/list/ListItem.tsx on lines 25..29
        scripts/extensions/sams/src/ui/modal/Modal.tsx on lines 17..21

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

        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.handleContentChangesThrottled = throttleAndCombineArray(
                    (changes: Array<IResourceChange>) => {
                        this.handleContentChanges(changes);
                    },
                    1000,
        Severity: Minor
        Found in scripts/core/with-resources.tsx and 1 other location - About 30 mins to fix
        scripts/core/with-live-query.tsx on lines 34..39

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

        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

        There are no issues that match your filters.

        Category
        Status