integreat-io/integreat

View on GitHub

Showing 64 of 71 total issues

File sync.ts has 495 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import pLimit from 'p-limit'
import ms from 'ms'
import type {
  Action,
  Payload,
Severity: Minor
Found in src/handlers/sync.ts - About 7 hrs to fix

    Function getAll has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    export default async function getAll(
      action: Action,
      { dispatch }: ActionHandlerResources
    ): Promise<Response> {
      const { pageSize, noLoopCheck = false } = action.payload
    Severity: Minor
    Found in src/handlers/getAll.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 createDispatch has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function createDispatch({
      handlers = {},
      schemas = new Map(),
      services = {},
      middleware = [],
    Severity: Minor
    Found in src/dispatch.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

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

      if (after) {
        nextParams[`${dateSet}Since`] = new Date(after.getTime() + 1)
      } else if (since) {
        nextParams[`${dateSet}After`] = new Date(since.getTime() - 1)
      }
    Severity: Major
    Found in src/handlers/sync.ts and 1 other location - About 2 hrs to fix
    src/handlers/sync.ts on lines 181..185

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

    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

      if (until) {
        nextParams[`${dateSet}Before`] = new Date(until.getTime() + 1)
      } else if (before) {
        nextParams[`${dateSet}Until`] = new Date(before.getTime() - 1)
      }
    Severity: Major
    Found in src/handlers/sync.ts and 1 other location - About 2 hrs to fix
    src/handlers/sync.ts on lines 176..180

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

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

    export default async function setMeta(
      action: Action,
      resources: ActionHandlerResources
    ): Promise<Response> {
      const {
    Severity: Major
    Found in src/handlers/setMeta.ts - About 2 hrs to fix

      Function setUpdatedDatesAndType has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async function setUpdatedDatesAndType(params: Partial<ActionParams>) {
          const {
            retrieve,
            updatedAfter,
            updatedSince,
      Severity: Major
      Found in src/handlers/sync.ts - About 2 hrs to fix

        Function getMeta has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export default async function getMeta(
          action: Action,
          resources: ActionHandlerResources
        ): Promise<Response> {
          debug('Action: GET_META')
        Severity: Major
        Found in src/handlers/getMeta.ts - About 2 hrs to fix

          Function dispatch has 54 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              pProgress(async (setProgress) => {
                debug('Dispatch: %o', originalAction)
                if (!originalAction) {
                  return {
                    status: 'noaction',
          Severity: Major
          Found in src/dispatch.ts - About 2 hrs to fix

            Function prepareValidator has a Cognitive Complexity of 16 (exceeds 5 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 2 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

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

                asHttpHeaders(
                  authentication: Authentication | null,
                ): Record<string, unknown> {
                  if (isObject(authentication)) {
                    const { status, ...options } = authentication
            Severity: Major
            Found in src/authenticators/options.ts and 1 other location - About 2 hrs to fix
            src/authenticators/options.ts on lines 123..131

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

            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

                asObject(authentication: Authentication | null): Record<string, unknown> {
                  if (isObject(authentication)) {
                    const { status, ...options } = authentication
                    if (status === 'granted') {
                      return options
            Severity: Major
            Found in src/authenticators/options.ts and 1 other location - About 2 hrs to fix
            src/authenticators/options.ts on lines 138..148

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

            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

                  mutation: [
                    {
                      $direction: 'to',
                      $flip: true,
                      payload: {
            Severity: Major
            Found in src/tests/helpers/defs/services/entries.ts and 1 other location - About 2 hrs to fix
            src/tests/helpers/defs/services/entries.ts on lines 173..189

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

            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

                  mutation: [
                    {
                      $direction: 'to',
                      $flip: true,
                      payload: {
            Severity: Major
            Found in src/tests/helpers/defs/services/entries.ts and 1 other location - About 2 hrs to fix
            src/tests/helpers/defs/services/entries.ts on lines 248..264

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

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

            const authorizeDataBase = (
              schemas: Map<string, Schema>,
              isToService: boolean,
            ) =>
              function authorizeData(action: Action, allowRaw = false): Action {
            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

            Function authorizeData has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              function authorizeData(action: Action, allowRaw = false): Action {
                if (isRootIdent(action.meta?.ident)) {
                  return action
                }
            
            
            Severity: Minor
            Found in src/service/utils/authData.ts - About 1 hr to fix

              Function mutateIncomingAction has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              async function mutateIncomingAction(action: Action, getService: GetService) {
                const { sourceService } = action.payload
                if (typeof sourceService !== 'string') {
                  return { action }
                }
              Severity: Minor
              Found in src/dispatch.ts - About 1 hr to fix

                Function authorizeItem has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                  (
                    schemas: Map<string, Schema>,
                    actionType: string,
                    allowRaw: boolean,
                    ident?: Ident,
                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

                Function setData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                async function setData(
                  dispatch: HandlerDispatch,
                  data: TypedData[],
                  { alwaysSet = false, maxPerSet, setMember, ...params }: ActionParams,
                  doQueueSet: boolean,
                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

                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

                Severity
                Category
                Status
                Source
                Language