superdesk/superdesk-client-core

View on GitHub

Showing 3,654 of 3,654 total issues

Function DeskConfigController has 105 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function DeskConfigController($scope, $controller, notify, desks, modal) {
    // expecting $scope.desks to be defined

    $scope.modalActive = false;
    $scope.numberOfUsers = 3;
Severity: Major
Found in scripts/apps/desks/controllers/DeskConfigController.ts - About 4 hrs to fix

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

        render() {
            if (this.state.loaded !== true) {
                return null;
            }
    
    
    Severity: Major
    Found in scripts/core/editor3/components/annotations/AnnotationInput.tsx - About 4 hrs to fix

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

              this.remove = function(name) {
                  this.getRow(name).then((rows) => {
                      rows[0].click();
                      rows[0].element(by.className('icon-trash')).click();
                      browser.sleep(500);
      Severity: Major
      Found in e2e/client/specs/helpers/highlights.ts and 1 other location - About 4 hrs to fix
      e2e/client/specs/helpers/dictionaries.ts on lines 64..71

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

      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

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

              this.remove = function(name) {
                  this.getRow(name).then((rows) => {
                      rows[0].click();
                      rows[0].element(by.className('icon-trash')).click();
                      browser.sleep(500);
      Severity: Major
      Found in e2e/client/specs/helpers/dictionaries.ts and 1 other location - About 4 hrs to fix
      e2e/client/specs/helpers/highlights.ts on lines 81..88

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

      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 image-crop-directive.ts has 341 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import {gettext} from 'core/utils';
      
      export default angular.module('superdesk.core.upload.imagecrop', [
          'superdesk.core.translate',
      ])
      Severity: Minor
      Found in scripts/core/upload/image-crop-directive.ts - About 4 hrs to fix

        File actions.ts has 340 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        // Types
        import {IRestApiResponse} from 'superdesk-api';
        import {ASSET_LIST_STYLE, IAssetItem, IAssetSearchParams, LIST_ACTION} from '../../interfaces';
        import {IThunkAction} from '../types';
        import {
        Severity: Minor
        Found in scripts/extensions/sams/src/store/assets/actions.ts - About 4 hrs to fix

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

          const Header: React.StatelessComponent<any> = (
              {text, onClose, children, className, noBorder, noPadding, centerText},
          ) => (
              <div
                  className={classNames(
          Severity: Major
          Found in scripts/apps/contacts/components/Popup/Header.tsx and 1 other location - About 4 hrs to fix
          scripts/core/ui/components/Popup/Header.tsx on lines 12..36

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

          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 Header: React.StatelessComponent<any> = (
              {text, onClose, children, className, noBorder, noPadding, centerText},
          ): any => (
              <div
                  className={classNames(
          Severity: Major
          Found in scripts/core/ui/components/Popup/Header.tsx and 1 other location - About 4 hrs to fix
          scripts/apps/contacts/components/Popup/Header.tsx on lines 7..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 118.

          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 keyboard.ts has 339 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import _ from 'lodash';
          import {gettext} from 'core/utils';
          import {sdApi} from 'api';
          
          export const KEYS = Object.freeze({
          Severity: Minor
          Found in scripts/core/keyboard/keyboard.ts - About 4 hrs to fix

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

                render() {
                    const {style} = this.props;
                    const {isLoading, selectedImage, images} = this.state;
            
                    return (

              Function getModalForMultipleHighlights has 103 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function getModalForMultipleHighlights(articles: Array<IArticle>, deskId: IDesk['_id']) {
                  class SetHighlightsForMultipleArticlesModalComponent extends React.Component<IProps, IState> {
                      constructor(props: IProps) {
                          super(props);
              
              

                File index.tsx has 338 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import React from 'react';
                import BlockStyleButtons from './BlockStyleButtons';
                import InlineStyleButtons from './InlineStyleButtons';
                import TableControls from './TableControls';
                import StyleButton from './StyleButton';
                Severity: Minor
                Found in scripts/core/editor3/components/toolbar/index.tsx - About 4 hrs to fix

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

                      setPortalNodes(node) {
                          this.dom.portal = node;
                  
                          if (this.dom.portal) {
                              this.dom.root = this.dom.portal.defaultNode || this.dom.portal.props.node;
                  Severity: Major
                  Found in scripts/apps/contacts/components/Popup/Popup.tsx and 1 other location - About 4 hrs to fix
                  scripts/core/ui/components/Popup/Popup.tsx on lines 135..143

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

                  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

                  function queryDescription(source: IRootElasticQuery, params: IAssetSearchParams) {
                      if (params.description != null && params.description.length > 0) {
                          source.query.bool.must.push(
                              superdeskApi.elasticsearch.queryString({
                                  query: `description:(${params.description})`,
                  Severity: Major
                  Found in scripts/extensions/sams/src/api/assets.ts and 2 other locations - About 4 hrs to fix
                  scripts/extensions/sams/src/api/assets.ts on lines 153..163
                  scripts/extensions/sams/src/api/assets.ts on lines 165..175

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

                  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

                  function queryName(source: IRootElasticQuery, params: IAssetSearchParams) {
                      if (params.name != null && params.name.length > 0) {
                          source.query.bool.must.push(
                              superdeskApi.elasticsearch.queryString({
                                  query: `name:(${params.name})`,
                  Severity: Major
                  Found in scripts/extensions/sams/src/api/assets.ts and 2 other locations - About 4 hrs to fix
                  scripts/extensions/sams/src/api/assets.ts on lines 165..175
                  scripts/extensions/sams/src/api/assets.ts on lines 177..187

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

                  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

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

                      setPortalNodes(node) {
                          this.dom.portal = node;
                  
                          if (this.dom.portal) {
                              this.dom.root = this.dom.portal.defaultNode || this.dom.portal.props.node;
                  Severity: Major
                  Found in scripts/core/ui/components/Popup/Popup.tsx and 1 other location - About 4 hrs to fix
                  scripts/apps/contacts/components/Popup/Popup.tsx on lines 134..142

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

                  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

                  function queryFilename(source: IRootElasticQuery, params: IAssetSearchParams) {
                      if (params.filename != null && params.filename.length > 0) {
                          source.query.bool.must.push(
                              superdeskApi.elasticsearch.queryString({
                                  query: `filename:(${params.filename})`,
                  Severity: Major
                  Found in scripts/extensions/sams/src/api/assets.ts and 2 other locations - About 4 hrs to fix
                  scripts/extensions/sams/src/api/assets.ts on lines 153..163
                  scripts/extensions/sams/src/api/assets.ts on lines 177..187

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

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

                  import * as React from 'react';
                  import {superdesk} from '../superdesk';
                  import {IArticle} from 'superdesk-api';
                  import {ITagUi} from '../types';
                  import {OrderedMap} from 'immutable';

                    Function getAutoTaggingComponent has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function getAutoTaggingComponent(superdesk: ISuperdesk, label: string) {
                        const {preferences} = superdesk;
                        const {httpRequestJsonLocal} = superdesk;
                        const {gettext, gettextPlural} = superdesk.localization;
                        const {memoize, generatePatch, arrayToTree} = superdesk.utilities;
                    Severity: Minor
                    Found in scripts/extensions/auto-tagging-widget/src/auto-tagging.tsx - About 4 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 MetaLocatorsDirective has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function MetaLocatorsDirective(places) {
                        return {
                            scope: {
                                item: '=',
                                fieldprefix: '@',
                    Severity: Minor
                    Found in scripts/apps/authoring/metadata/metadata.ts - About 4 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