integreat-io/integreat

View on GitHub

Showing 61 of 70 total issues

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

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

    Function createDispatch has a Cognitive Complexity of 25 (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

    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

    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 177..181

    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 182..186

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

      async function setUpdatedDatesAndType(params: Partial<ActionParams>) {
      const type = payload.type as string | string[] // We know it's not undefined
      const {
      retrieve,
      updatedAfter,
      Severity: Major
      Found in src/handlers/sync.ts - About 2 hrs to fix

        Function getMeta has 55 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,
            mapTransform: MapTransform,
            mapOptions: MapOptions,
            defaultErrorStatus = 'badrequest',
            Severity: Minor
            Found in src/utils/validation.ts - About 2 hrs to fix

            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

            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

            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

            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

            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

            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

                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

                Function getIdent has 38 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
                  Severity
                  Category
                  Status
                  Source
                  Language