integreat-io/integreat

View on GitHub

Showing 45 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

    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

            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

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

                      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 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 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
                        Severity
                        Category
                        Status
                        Source
                        Language