andersondanilo/jsonapi-fractal

View on GitHub

Showing 8 of 11 total issues

Function parseJsonApiSimpleResourceData has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

function parseJsonApiSimpleResourceData<TEntity, TExtraOptions>(
  data: ResourceObject,
  included: ExistingResourceObject[],
  options: Options<TExtraOptions>,
  useCache: boolean,
Severity: Minor
Found in src/deserializer.ts - About 3 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 parseJsonApiSimpleResourceData has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function parseJsonApiSimpleResourceData<TEntity, TExtraOptions>(
  data: ResourceObject,
  included: ExistingResourceObject[],
  options: Options<TExtraOptions>,
  useCache: boolean,
Severity: Major
Found in src/deserializer.ts - About 2 hrs to fix

    Function serializeEntity has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function serializeEntity<TEntity, TExtraOptions>(
      entity: TEntity,
      transformer: Transformer<TEntity, TExtraOptions>,
      included: boolean,
      options: Options<TExtraOptions>,
    Severity: Minor
    Found in src/serializer.ts - About 1 hr to fix

      Function serializeEntity has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      function serializeEntity<TEntity, TExtraOptions>(
        entity: TEntity,
        transformer: Transformer<TEntity, TExtraOptions>,
        included: boolean,
        options: Options<TExtraOptions>,
      Severity: Minor
      Found in src/serializer.ts - About 1 hr 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 changeCase has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      export function changeCase(originalAttributes: AttributesObject, caseType: CaseType, deep = false): AttributesObject {
        const caseFunction = caseTypes[caseType]
      
        if (!caseFunction) {
          throw new Error('Invalid case type: ' + caseType)
      Severity: Minor
      Found in src/utils.ts - About 1 hr 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 serializeRelation has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function serializeRelation<TEntity = unknown, TExtraOptions = unknown>(
        context: Context<TEntity, TExtraOptions>,
        includedByType: IncludedRecord,
      ): ResourceIdentifierObject | undefined {
        const { input: entity, options, transformer, included } = context
      Severity: Minor
      Found in src/serializer.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

      Function serializeEntity has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        entity: TEntity,
        transformer: Transformer<TEntity, TExtraOptions>,
        included: boolean,
        options: Options<TExtraOptions>,
        includedByType: IncludedRecord,
      Severity: Minor
      Found in src/serializer.ts - About 35 mins to fix

        Function serializeContext has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function serializeContext<TEntity, TExtraOptions = unknown>(context: Context<TEntity, TExtraOptions>): DocumentObject {
          if (!context.input) {
            // eslint-disable-next-line unicorn/no-null
            return { data: null }
          }
        Severity: Minor
        Found in src/serializer.ts - About 25 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

        Severity
        Category
        Status
        Source
        Language