integreat-io/integreat

View on GitHub

Showing 64 of 71 total issues

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

    {
      match: { action: 'GET', scope: 'collection' },
      mutation: {
        $direction: 'from',
        response: {
Severity: Major
Found in src/tests/helpers/defs/services/users.ts and 1 other location - About 1 hr to fix
src/tests/helpers/defs/services/users.ts on lines 54..64

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

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

  function authorizeAction(action: Action): Action {
    const {
      payload: { type },
      response: { status } = {},
      meta: { ident } = {},
Severity: Minor
Found in src/service/utils/authAction.ts - About 1 hr to fix

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

    export default async function getIdent(
      action: Action,
      resources: ActionHandlerResources,
    ): Promise<Response> {
      const { ident } = action.meta || {}
    Severity: Minor
    Found in src/handlers/getIdent.ts - About 1 hr to fix

      Function prepareValidator has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export default function prepareValidator(
        conditions: ValidateObject[] | undefined,
        mapOptions: MapOptions,
        defaultErrorStatus = 'badrequest',
        breakByDefault = false,
      Severity: Minor
      Found in src/utils/validation.ts - About 1 hr to fix

        Function getDates has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        function getDates(
          shouldHaveCreatedAt: boolean,
          shouldHaveUpdatedAt: boolean,
          createdAt: unknown,
          updatedAt: unknown,
        Severity: Minor
        Found in src/schema/createCast.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 syncHandler has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        export default async function syncHandler(
          inputAction: Action,
          { dispatch, setProgress }: ActionHandlerResources,
        ): Promise<Response> {
          setProgress(0)
        Severity: Minor
        Found in src/handlers/sync.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 generateErrorAndReason has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        const generateErrorAndReason = (
          reason: string,
          data: unknown,
          isToService: boolean,
          service?: string,
        Severity: Minor
        Found in src/service/utils/authData.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

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

        const expandField = (val: ShapeDef | FieldDefinition | string | undefined) =>
          typeof val === 'string'
            ? { $type: val }
            : isShape(val)
            ? expandFields(val)
        Severity: Major
        Found in src/schema/expandShape.ts and 1 other location - About 1 hr to fix
        src/schema/Schema.ts on lines 15..20

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

        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

        const expandField = (val: ShapeDef | FieldDefinition | string | undefined) =>
          typeof val === 'string'
            ? { $type: val }
            : isShape(val)
              ? expandFields(val)
        Severity: Major
        Found in src/schema/Schema.ts and 1 other location - About 1 hr to fix
        src/schema/expandShape.ts on lines 4..9

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

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

        export function mergeOptions(a: PreparedOptions, b: PreparedOptions) {
          const transporterOptions = deepClone({
            ...removeIncoming(a.transporter),
            ...removeIncoming(b.transporter),
          })
        Severity: Minor
        Found in src/service/utils/options.ts - About 1 hr to fix

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

              ...(oldestAfter
                ? {
                    [`${dateSet}After`]: oldestAfter,
                    [`${dateSet}Since`]: new Date(oldestAfter.getTime() + 1),
                  }
          Severity: Major
          Found in src/handlers/sync.ts and 2 other locations - About 55 mins to fix
          src/handlers/sync.ts on lines 321..326
          src/handlers/sync.ts on lines 327..332

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

          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

              ...(until
                ? {
                    [`${dateSet}Until`]: until,
                    [`${dateSet}Before`]: new Date(until.getTime() + 1),
                  }
          Severity: Major
          Found in src/handlers/sync.ts and 2 other locations - About 55 mins to fix
          src/handlers/sync.ts on lines 315..320
          src/handlers/sync.ts on lines 327..332

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

          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

              ...(before
                ? {
                    [`${dateSet}Before`]: before,
                    [`${dateSet}Until`]: new Date(before.getTime() - 1),
                  }
          Severity: Major
          Found in src/handlers/sync.ts and 2 other locations - About 55 mins to fix
          src/handlers/sync.ts on lines 315..320
          src/handlers/sync.ts on lines 321..326

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

          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

            } else if (typeof value === 'string') {
              return numberOrUndefined(Number.parseFloat(value))
            } else if (typeof value === 'boolean') {
              return Number(value)
            } else if (isDate(value)) {
          Severity: Minor
          Found in src/schema/castFns/number.ts and 1 other location - About 55 mins to fix
          src/schema/castFns/integer.ts on lines 10..18

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

          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

            } else if (value === null || value === undefined) {
              return value
            } else if (typeof value === 'boolean') {
              return Number(value)
            } else if (isDate(value)) {
          Severity: Minor
          Found in src/schema/castFns/integer.ts and 1 other location - About 55 mins to fix
          src/schema/castFns/number.ts on lines 10..18

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

          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 castInteger has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function castInteger(value: unknown): number | null | undefined {
            if (typeof value === 'number') {
              return isNaN(value) ? undefined : Math.round(value)
            } else if (typeof value === 'string') {
              return numberOrUndefined(Number.parseInt(value, 10))
          Severity: Minor
          Found in src/schema/castFns/integer.ts - About 55 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

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

          const extractId = (action: Action, data?: unknown) =>
            action.payload.id || (isTypedData(data) && data.id) || undefined
          Severity: Minor
          Found in src/handlers/set.ts and 1 other location - About 45 mins to fix
          src/handlers/set.ts on lines 12..13

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

          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 resolveAuth has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          export const resolveAuth = (
            authenticators: Record<string, Authenticator>,
            auths?: Record<string, Auth>,
          ) =>
            function resolveAuth(auth?: AuthObject | AuthProp): Auth | undefined {
          Severity: Minor
          Found in src/service/utils/resolveAuth.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

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

          const extractType = (action: Action, data?: unknown) =>
            action.payload.type || (isTypedData(data) && data.$type) || undefined
          Severity: Minor
          Found in src/handlers/set.ts and 1 other location - About 45 mins to fix
          src/handlers/set.ts on lines 15..16

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

          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 extractMeta has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          const extractMeta = (meta: unknown, keys: unknown): Record<string, unknown> =>
            isObject(meta)
              ? typeof keys === 'string' || Array.isArray(keys)
                ? ([] as string[])
                    .concat(keys)
          Severity: Minor
          Found in src/handlers/getMeta.ts - About 35 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