andersondanilo/jsonapi-fractal

View on GitHub
src/serializer.ts

Summary

Maintainability
B
5 hrs
Test Coverage
A
96%

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 serializeRelation has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Wontfix

    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 1 hr to fix

      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

        There are no issues that match your filters.

        Category
        Status