superdesk/superdesk-client-core

View on GitHub

Showing 3,654 of 3,654 total issues

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

                        <div className="proofreading-panel-content__block">
                            <label className="proofreading-panel-content__label">
                                {gettext('Abstract')}
                            </label>

scripts/apps/authoring-react/toolbar/proofreading-theme-panel.tsx on lines 132..160
scripts/apps/authoring-react/toolbar/proofreading-theme-panel.tsx on lines 194..224

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

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

export const headline: IFieldAdapter<IArticle> = {
    getFieldV2: (fieldEditor, fieldSchema) => {
        const fieldConfig: IEditor3Config = {
            editorFormat: fieldEditor.formatOptions ?? [],
            minLength: fieldSchema?.minlength,
Severity: Major
Found in scripts/apps/authoring-react/field-adapters/headline.ts and 1 other location - About 1 day to fix
scripts/apps/authoring-react/field-adapters/abstract.ts on lines 5..46

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

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

export const abstract: IFieldAdapter<IArticle> = {
    getFieldV2: (fieldEditor, fieldSchema) => {
        const fieldConfig: IEditor3Config = {
            editorFormat: fieldEditor.formatOptions ?? [],
            minLength: fieldSchema?.minlength,
Severity: Major
Found in scripts/apps/authoring-react/field-adapters/abstract.ts and 1 other location - About 1 day to fix
scripts/apps/authoring-react/field-adapters/headline.ts on lines 5..46

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

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

export function AuthoringHeaderDirective(
    api,
    authoringWidgets,
    $rootScope,
    archiveService,

    Function DeskeditStages has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
    Open

    export function DeskeditStages(api, WizardHandler, tasks, desks, notify, macros) {
        return {
            link: function(scope, elem) {
                var orig = null;
    
    
    Severity: Minor
    Found in scripts/apps/desks/directives/DeskeditStages.ts - About 1 day 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 assets.ts has 559 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    // Types
    import {
        IAttachment,
        IElasticRangeQueryParams,
        IRestApiResponse,
    Severity: Major
    Found in scripts/extensions/sams/src/api/assets.ts - About 1 day to fix

      Function ItemList has 235 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function ItemList(
          $timeout,
          search,
          monitoringState,
          $rootScope,
      Severity: Major
      Found in scripts/apps/search/directives/ItemList.tsx - About 1 day to fix

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

            constructor() {
                this.ingestRepo = element(by.id('ingest-collection'));
                this.archiveRepo = element(by.id('archive-collection'));
                this.publishedRepo = element(by.id('published-collection'));
                this.archivedRepo = element(by.id('archived-collection'));
        Severity: Major
        Found in e2e/client/specs/helpers/search.ts - About 1 day to fix

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

                  link: function(scope, elem) {
                      const abortController = new AbortController();
                      var groupId = scope.$id;
                      var groups = monitoringState.state.groups || [];
          
          
          Severity: Major
          Found in scripts/apps/search/directives/ItemList.tsx - About 1 day to fix

            Function UserEditDirective has 230 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function UserEditDirective(api, notify, usersService, userList, session, _,
                langmap, $location, $route, superdesk, features, asset, privileges, desks, keyboardManager,
                gettextCatalog, metadata, modal, $q) {
                return {
                    templateUrl: asset.templateUrl('apps/users/views/edit-form.html'),
            Severity: Major
            Found in scripts/apps/users/directives/UserEditDirective.ts - About 1 day to fix

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

                      link: function(scope, elem, attrs, WidgetsManagerCtrl) {
                          scope.contentType = null;
                          scope.displayCompanyCodes = null;
                          scope.features = features;
                          scope.translationService = TranslationService;

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

                        superdesk
                            .activity('authoring', {
                                category: '/authoring',
                                href: '/authoring/:_id',
                                when: '/authoring/:_id',
                Severity: Major
                Found in scripts/apps/authoring/authoring/index.ts and 1 other location - About 1 day to fix
                scripts/apps/authoring/authoring/index.ts on lines 188..343

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

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

                import React from 'react';
                import ReactDOM from 'react-dom';
                import {
                    Editor,
                    RichUtils,
                Severity: Major
                Found in scripts/core/editor3/components/Editor3Component.tsx - About 1 day to fix

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

                  export const byline: IFieldAdapter<IArticle> = {
                      getFieldV2: (fieldEditor, fieldSchema) => {
                          const fieldConfig: IEditor3Config = {
                              editorFormat: [],
                              minLength: fieldSchema?.minlength,
                  Severity: Major
                  Found in scripts/apps/authoring-react/field-adapters/byline.ts and 2 other locations - About 1 day to fix
                  scripts/apps/authoring-react/field-adapters/anpa_take_key.ts on lines 5..46
                  scripts/apps/authoring-react/field-adapters/usageterms.ts on lines 5..46

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

                  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

                  export const usageterms: IFieldAdapter<IArticle> = {
                      getFieldV2: (fieldEditor, fieldSchema) => {
                          const fieldConfig: IEditor3Config = {
                              editorFormat: [],
                              minLength: fieldSchema?.minlength,
                  Severity: Major
                  Found in scripts/apps/authoring-react/field-adapters/usageterms.ts and 2 other locations - About 1 day to fix
                  scripts/apps/authoring-react/field-adapters/anpa_take_key.ts on lines 5..46
                  scripts/apps/authoring-react/field-adapters/byline.ts on lines 5..46

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

                  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

                  export const anpa_take_key: IFieldAdapter<IArticle> = {
                      getFieldV2: (fieldEditor, fieldSchema) => {
                          const fieldConfig: IEditor3Config = {
                              editorFormat: [],
                              minLength: fieldSchema?.minlength,
                  scripts/apps/authoring-react/field-adapters/byline.ts on lines 5..46
                  scripts/apps/authoring-react/field-adapters/usageterms.ts on lines 5..46

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

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

                          link: function(scope: IScope, elem, attr, controller) {
                              let carousel;
                              let previousItems: Array<any>;
                  
                              scope.currentIndex = 0;
                  Severity: Major
                  Found in scripts/apps/authoring/authoring/directives/ItemCarouselDirective.ts - About 1 day to fix

                    Function getFieldsAdapter has 223 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function getFieldsAdapter(authoringStorage: IAuthoringStorage<IArticle>): IFieldsAdapter<IArticle> {
                        const customFieldVocabularies = getCustomFieldVocabularies();
                        const adapter: IFieldsAdapter<IArticle> = getBaseFieldsAdapter();
                    
                        for (const vocabulary of customFieldVocabularies) {
                    Severity: Major
                    Found in scripts/apps/authoring-react/field-adapters/index.tsx - About 1 day to fix

                      Function SpellcheckService has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function SpellcheckService($q, api, dictionaries, $rootScope, $location, _, preferencesService) {
                          var PREFERENCES_KEY = 'spellchecker:status',
                              lang = getUserInterfaceLanguage(),
                              dict = {} as any,
                              ignored = {},
                      Severity: Minor
                      Found in scripts/core/spellcheck/spellcheck.ts - About 1 day 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 template-edit.tsx has 537 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import * as React from 'react';
                      import * as Layout from 'superdesk-ui-framework/react/components/Layouts';
                      import {isEqual} from 'lodash';
                      import {
                          Input,
                        Severity
                        Category
                        Status
                        Source
                        Language