superdesk/superdesk-client-core

View on GitHub

Showing 3,654 of 3,654 total issues

Function AuthoringEmbeddedDirective has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

export function AuthoringEmbeddedDirective(api, notify, $filter) {
    return {
        template: authoringReactViewEnabled
            ? (
                '<div>' +

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

export function ProductsConfigController($scope: IScope, notify, api, products, modal,
    subscribersService, metadata, $filter) {
    $scope.testLookup = {};
    $scope.productLookup = {};
    $scope.loading = false;
Severity: Minor
Found in scripts/apps/products/controllers/ProductsConfigController.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 19 (exceeds 5 allowed). Consider refactoring.
Open

    render() {
        const {setLocked, showTitle, readOnly} = this.props;
        const data = this.data();
        const rendition = data.renditions.baseImage || data.renditions.viewImage || data.renditions.original;
        const alt = data.alt_text || data.description_text || data.caption;
Severity: Minor
Found in scripts/core/editor3/components/media/MediaBlock.tsx - 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 applyChangeSuggestion has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

const applyChangeSuggestion = (editorState, accepted) => {
    const suggestionTypes = [...changeSuggestionsTypes, ...paragraphSuggestionTypes];
    let selection = editorState.getSelection();
    let content = editorState.getCurrentContent();
    let lastBlock = content.getBlockForKey(selection.getEndKey());
Severity: Minor
Found in scripts/core/editor3/reducers/suggestions.tsx - 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

File select2.tsx has 274 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable indent */

import * as React from 'react';
import * as Autocomplete from 'react-autocomplete';
import {noop, throttle} from 'lodash';
Severity: Minor
Found in scripts/core/ui/components/select2.tsx - About 2 hrs to fix

    File desks.ts has 274 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* eslint-disable newline-per-chained-call */
    
    import {element, by, browser, protractor} from 'protractor';
    import {el, ECE} from '@superdesk/end-to-end-testing-helpers';
    import {nav, click} from './utils';
    Severity: Minor
    Found in e2e/client/specs/helpers/desks.ts - About 2 hrs to fix

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

          render() {
              const {radius, circumference, dashOffset} = this.computeSVGAttributes();
              let status = '';
      
              if (this.props.error === true) {
      Severity: Major
      Found in scripts/extensions/sams/src/ui/grid/GridItemProgressCircle.tsx - About 2 hrs to fix

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

                link: function(scope) {
                    scope.workspaces = workspaces;
                    scope.wsList = null;
                    scope.edited = null;
        
        
        Severity: Major
        Found in scripts/apps/workspace/directives/WorkspaceDropdownDirective.ts - About 2 hrs to fix

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

              render() {
                  const {getClass} = this.props.superdesk.utilities.CSS;
                  const {gettext} = this.props.superdesk.localization;
          
                  return (
          Severity: Major
          Found in scripts/extensions/videoEditor/src/VideoEditorThumbnail.tsx - About 2 hrs to fix

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

                render() {
                    const Container = this.props.container;
                    const urls = this.props.value ?? [];
                    const {readOnly} = this.props;
            
            
            Severity: Major
            Found in scripts/apps/authoring-react/fields/urls/editor.tsx - About 2 hrs to fix

              Function filterQueryByCardType has 64 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function filterQueryByCardType(query, queryParam, card: ICard) {
                      let deskId;
                      const extensionSection = getExtensionSections();
                      const section = extensionSection.find((response) => response.id === card.type);
              
              
              Severity: Major
              Found in scripts/apps/monitoring/services/CardsService.ts - About 2 hrs to fix

                Function DeskeditPeople has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function DeskeditPeople(WizardHandler, desks, notify) {
                    return {
                        link: function(scope) {
                            scope.$watch('step.current', (step, previous) => {
                                if (step === 'people') {
                Severity: Major
                Found in scripts/apps/desks/directives/DeskeditPeople.ts - About 2 hrs to fix

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

                      render() {
                          const {value, field, remove, onChange, readOnly, usages} = this.props;
                  
                          return (
                              <Row flex={true}>
                  Severity: Major
                  Found in scripts/apps/contacts/components/Form/ContactNumberInput.tsx - About 2 hrs to fix

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

                        render() {
                            const {field, language} = this.props;
                    
                            return (
                                <div>
                    Severity: Major
                    Found in scripts/apps/authoring/preview/previewFieldByType.tsx - About 2 hrs to fix

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

                              link: function(scope, element) {
                                  var inputElem = element.find('input')[0];
                      
                                  scope.adding = false;
                                  scope.refreshing = false;
                      Severity: Major
                      Found in scripts/apps/authoring/metadata/metadata.ts - About 2 hrs to fix

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

                            render() {
                                const {article, backgroundColor} = this.props;
                        
                                return (
                                    <div style={{backgroundColor: backgroundColor}}>
                        Severity: Major
                        Found in scripts/core/ui/components/article-item-concise.tsx - About 2 hrs to fix

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

                              render() {
                                  const currentSortOption = this.props.sortOptions.find(
                                      (option) => option.field === this.props.selected.field,
                                  );
                          
                          
                          Severity: Major
                          Found in scripts/core/ui/components/SortBar/index.tsx - About 2 hrs to fix

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

                                            link: function(scope, element, attrs) {
                                                scope.items = null;
                                                scope.processedItems = null;
                                                scope.selected = null;
                                                var oldSearch = null;
                            Severity: Major
                            Found in scripts/core/itemList/itemList.ts - About 2 hrs to fix

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

                                      constructor(props: IProps) {
                                          super(props);
                              
                                          this.state = {
                                              selectedHighlights: [],
                              scripts/apps/vocabularies/components/UploadConfigModal.tsx on lines 22..31
                              scripts/extensions/sams/src/components/common/DesksSelectInput.tsx on lines 34..41

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

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

                                  constructor(props: IProps) {
                                      super(props);
                              
                                      this.state = {desks: []};
                              
                              
                              scripts/apps/highlights/components/SetHighlightsForMultipleArticlesModal.tsx on lines 21..30
                              scripts/apps/vocabularies/components/UploadConfigModal.tsx on lines 22..31

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

                              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

                              Severity
                              Category
                              Status
                              Source
                              Language