superdesk/superdesk-client-core

View on GitHub
scripts/apps/authoring-react/data-layer.ts

Summary

Maintainability
C
1 day
Test Coverage

File data-layer.ts has 364 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {OrderedMap} from 'immutable';
import {
    IArticle,
    IAuthoringFieldV2,
    IFieldsV2,
Severity: Minor
Found in scripts/apps/authoring-react/data-layer.ts - About 4 hrs to fix

    Function getArticleContentProfile has 106 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function getArticleContentProfile<T>(
        item: IArticle,
        fieldsAdapter: IFieldsAdapter<T>,
    ): Promise<IContentProfileV2> {
        interface IFakeScope {
    Severity: Major
    Found in scripts/apps/authoring-react/data-layer.ts - About 4 hrs to fix

      Function saveEntity has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          saveEntity: (current, original) => {
              const adapter = getArticleAdapter();
      
              return authoringApiCommon.saveBefore(current, original).then((_current) => {
                  const id = original._id;
      Severity: Minor
      Found in scripts/apps/authoring-react/data-layer.ts - About 1 hr to fix

        Function getPackagesContentProfile has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function getPackagesContentProfile<T>(
            item: IArticle,
            fieldsAdapter: IFieldsAdapter<T>,
        ): Promise<IContentProfileV2> {
            const headlineField: IAuthoringFieldV2 = {
        Severity: Minor
        Found in scripts/apps/authoring-react/data-layer.ts - About 1 hr to fix

          Function getEntity has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              getEntity: (id) => {
                  return authoringStorageIArticle.getEntity(id).then(({saved, autosaved}) => {
                      const newItem = {...saved};
          
                      newItem.flags.marked_for_sms = false;
          Severity: Minor
          Found in scripts/apps/authoring-react/data-layer.ts - About 45 mins 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

          There are no issues that match your filters.

          Category
          Status