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

            {
                Array.isArray(fieldsLeft) === true && fieldsLeft.length > 0 ? (
                    <div className="sd-grid-item__footer-block sd-grid-item__footer-block--multi-l">
                        <PhotoDeskFields
                            fieldsConfig={fieldsLeft}
Severity: Major
Found in scripts/apps/search/components/PhotoDeskFooter.tsx and 1 other location - About 2 hrs to fix
scripts/apps/search/components/PhotoDeskFooter.tsx on lines 36..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 81.

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

                                    <SimpleListItem justify="space-between">
                                        <Switch value={this.state.value1} label={{content: 'My label'}} onChange={(value) => this.setState(() => ({value1: value}))} />
                                    </SimpleListItem>
Severity: Major
Found in scripts/apps/authoring-react/ui-framework-authoring-test.tsx and 1 other location - About 2 hrs to fix
scripts/apps/authoring-react/ui-framework-authoring-test.tsx on lines 366..368

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

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

    componentDidMount() {
        getActionsBulkFromExtensions(this.props.articles).then((actionsBulkFromExtensions) => {
            this.setState({
                actions: sortByDisplayPriority(
                    this.props.getCoreActions(this.props.articles).concat(actionsBulkFromExtensions),
Severity: Major
Found in scripts/apps/monitoring/MultiActionBarReact.tsx and 1 other location - About 2 hrs to fix
scripts/apps/monitoring/MultiActionBarReact.tsx on lines 73..81

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

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 (prevProps !== this.props) {
            getActionsBulkFromExtensions(this.props.articles).then((actionsBulkFromExtensions) => {
                this.setState({
                    actions: sortByDisplayPriority(
                        this.props.getCoreActions(this.props.articles).concat(actionsBulkFromExtensions),
Severity: Major
Found in scripts/apps/monitoring/MultiActionBarReact.tsx and 1 other location - About 2 hrs to fix
scripts/apps/monitoring/MultiActionBarReact.tsx on lines 62..70

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

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

    render() {
        return (
            <WithShow show={this.state.show}>
                {(form, save) => (
                    <Modal
Severity: Major
Found in scripts/extensions/broadcasting/src/shows/create-show-modal.tsx - About 2 hrs to fix

    Function getRundownItemCreationAuthoringStorage has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function getRundownItemCreationAuthoringStorage(
        rundownId: IRundown['_id'],
        initialData: Partial<IRundownItem>,
        onSave: (item: IRundownItem) => Promise<IRundownItem>,
    ): IAuthoringStorage<IRundownItem> {

      Function handleDragDrop has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private handleDragDrop(event): void {
              const superdeskType = getSuperdeskType(event);
              const {config} = this.props;
      
              if (superdeskType == null) {
      Severity: Major
      Found in scripts/apps/authoring-react/fields/media/editor.tsx - About 2 hrs to fix

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

                link: function(scope) {
                    var _orig = null;
        
                    scope.editRuleset = null;
        
        
        Severity: Major
        Found in scripts/apps/ingest/directives/IngestRulesContent.ts - About 2 hrs to fix

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

              render() {
                  const {closeModal} = this.props;
          
                  const subscribers = this.props.subscribers.filter(
                      ({destinations}) => (destinations ?? []).some((dest) => publishPreviewEnabled(dest)),
          Severity: Major
          Found in scripts/apps/publish-preview/previewModal.tsx - About 2 hrs to fix

            Function fetchRelatableItems has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                this.fetchRelatableItems = (keyword, sluglineMatch, item, modificationDateAfter) => {
                    let filter: Array<any> = [
                        {not: {term: {state: 'spiked'}}},
                        {not: {term: {event_id: item.event_id}}},
                        {not: {term: {type: 'composite'}}},
            Severity: Major
            Found in scripts/apps/archive/services/FamilyService.ts - About 2 hrs to fix

              Function MediaPreview has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function MediaPreview(api, $rootScope, desks, superdesk, content, storage) {
                  return {
                      template: require('../views/preview.html'),
                      link: function(scope, elem) {
                          const PREVIEW_HEADER_STATE = 'item_preview:header_state';
              Severity: Major
              Found in scripts/apps/archive/directives/MediaPreview.ts - About 2 hrs to fix

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

                        render() {
                            if (this.state.highlightsForDesk == null) {
                                return null;
                            }
                
                

                  Function MediaMetadataEditorDirective has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export default function MediaMetadataEditorDirective(metadata, features, session) {
                      return {
                          scope: {
                              item: '=',
                              validator: '=',
                  Severity: Major
                  Found in scripts/apps/authoring/media/MediaMetadataEditorDirective.ts - About 2 hrs to fix

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

                        render() {
                            const {attachment, readOnly, editAttachment, removeAttachment, noBackground} = this.props;
                    
                            return (
                                <Item shadow={1} noBg={noBackground === true}>
                    Severity: Major
                    Found in scripts/apps/authoring/attachments/AttachmentsListItem.tsx - About 2 hrs to fix

                      Function SavedSearchEditOwnSubscription has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function SavedSearchEditOwnSubscription(asset, session, api) {
                          return {
                              scope: {
                                  savedSearch: '=',
                                  cancelEditingSubscription: '=',
                      Severity: Major
                      Found in scripts/apps/search/directives/SavedSearchEditOwnSubscription.ts - About 2 hrs to fix

                        Function MonitoringState has 57 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        export function MonitoringState($q, $rootScope, ingestSources, desks, highlightsService, content, metadata) {
                            this.init = init;
                            this.state = {};
                            this.setState = setState;
                            this.moveActiveGroup = moveActiveGroup;
                        Severity: Major
                        Found in scripts/apps/search/services/MonitoringState.ts - About 2 hrs to fix

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

                              render() {
                                  const {
                                      field,
                                      value,
                                      checkedValue,
                          Severity: Major
                          Found in scripts/core/ui/components/Form/Checkbox.tsx - About 2 hrs to fix

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

                                render() {
                                    const items: Array<{id: string; label: string}> = this.props.formField.component_parameters.items;
                            
                                    if (this.props.previewOutput) {
                                        if (this.props.value == null) {

                              Function PackageItemsEdit has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                              Open

                              export function PackageItemsEdit(packages: IPackagesService, notify, $rootScope) {
                                  return {
                                      scope: false,
                                      require: 'ngModel',
                                      templateUrl: 'scripts/apps/packaging/views/sd-package-items-edit.html',
                              Severity: Minor
                              Found in scripts/apps/packaging/directives/PackageItemsEdit.ts - About 2 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 a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  render() {
                                      const {currentPage} = this.state;
                                      const {mediaItems, maxItemsAllowed, readOnly, showPictureCrops, showTitleInput} = this.props;
                                      const onChange = this.props.onChange ?? noop;
                              
                              

                              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