BetterTyped/hyper-fetch

View on GitHub

Showing 248 of 345 total issues

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

const encodeArray = (key: string, array: Array<QueryParamValuesType>, options: QueryStringifyOptionsType): string => {
  const { arrayFormat, arraySeparator } = options;

  return array
    .filter(isValidValue(options))
Severity: Minor
Found in packages/core/src/client/client.utils.ts - About 1 hr to fix

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

        callback: ({
          endpoint,
          data,
          extra,
        }: {
    Severity: Major
    Found in packages/sockets/src/socket/socket.events.ts and 1 other location - About 1 hr to fix
    packages/sockets/src/socket/socket.events.ts on lines 100..108

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

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

        const listen: ReturnType<FirestoreSocketAdapterType>["listen"] = (listener, callback) => {
          const fullUrl = socket.url + listener.endpoint;
          const { options } = listener;
    
          let path;
    Severity: Minor
    Found in packages/adapter-firebase/src/firestore/firestore.sockets.ts - About 1 hr to fix

      Function addLifecycleListeners has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const addLifecycleListeners = (req: T, requestId?: string) => {
          /**
           * useFetch handles requesting by general keys
           * This makes it possible to deduplicate requests from different places and share data
           */

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

          const handleRequestStart = (cmd: T) => {
            return (details: RequestEventType<T>) => {
              onRequestStartCallback.current?.({ request: cmd, details });
            };
          };
        packages/react/src/helpers/use-request-events/use-request-events.hooks.ts on lines 132..136

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

        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

          const handleResponseStart = (cmd: T) => {
            return (details: RequestEventType<T>) => {
              onResponseStartCallback.current?.({ request: cmd, details });
            };
          };
        packages/react/src/helpers/use-request-events/use-request-events.hooks.ts on lines 127..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 62.

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

        export const useEmitter = <EmitterType extends EmitterInstance>(
          emitter: EmitterType,
          options: UseEmitterOptionsType,
        ) => {
          const [globalConfig] = useConfigProvider();
        Severity: Minor
        Found in packages/react/src/hooks/use-emitter/use-emitter.hooks.ts - About 1 hr to fix

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

          export const $orderByValue = () => {
            return {
              toString: () => `${RealtimeQueryConstraints.ORDER_BY_VALUE}`,
              type: RealtimeQueryConstraints.ORDER_BY_VALUE as const,
              values: [],
          packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 79..85
          packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 79..85
          packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 87..93

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

          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 4 locations. Consider refactoring.
          Open

          export const $orderByValue = () => {
            return {
              toString: () => `${RealtimeQueryConstraints.ORDER_BY_VALUE}`,
              type: RealtimeQueryConstraints.ORDER_BY_VALUE as const,
              values: [],
          packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 79..85
          packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 87..93
          packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 79..85

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

          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 4 locations. Consider refactoring.
          Open

          export const $orderByKey = () => {
            return {
              toString: () => `${RealtimeQueryConstraints.ORDER_BY_KEY}`,
              type: RealtimeQueryConstraints.ORDER_BY_KEY as const,
              values: [],
          packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 87..93
          packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 79..85
          packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 87..93

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

          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 4 locations. Consider refactoring.
          Open

          export const $orderByKey = () => {
            return {
              toString: () => `${RealtimeQueryConstraints.ORDER_BY_KEY}`,
              type: RealtimeQueryConstraints.ORDER_BY_KEY as const,
              values: [],
          packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 79..85
          packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 87..93
          packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 87..93

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

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

          export const getSocketAdapterBindings = <T extends SocketAdapterInstance>(
            socket: SocketInstance,
            defaults?: { open?: boolean; connecting?: boolean; forceClosed?: boolean; reconnectionAttempts?: number },
          ) => {
            const logger = socket.loggerManager.init("Socket Adapter");
          Severity: Minor
          Found in packages/sockets/src/adapter/adapter.bindings.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

            emitLoading: (queueKey: string, requestId: string, values: RequestLoadingEventType): void => {
              emitter.emit(getLoadingIdEventKey(requestId), values);
              emitter.emit(getLoadingEventKey(queueKey), values);
            },
          packages/core/src/managers/request/request.manager.events.ts on lines 80..83

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

          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

            emitAbort: (abortKey: string, requestId: string, request: RequestInstance): void => {
              emitter.emit(getAbortByIdEventKey(requestId), request);
              emitter.emit(getAbortEventKey(abortKey), request);
            },
          packages/core/src/managers/request/request.manager.events.ts on lines 33..36

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

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

            const connect = () => {
              const enabled = onConnect();
              if (!enabled) return;
          
              // Clean environment
          Severity: Minor
          Found in packages/sockets/src/adapter/adapter.websocket.ts - About 1 hr to fix

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

            export const getStatus = (res: any) => {
              // Deliberate == instead of ===
              return (Array.isArray(res) && res.length === 0) || res == null ? "emptyResource" : "success";
            };
            Severity: Major
            Found in packages/adapter-firebase/src/utils/misc.ts and 1 other location - About 1 hr to fix
            packages/adapter-firebase-admin/src/utils/misc.ts on lines 1..4

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

            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

            export const getStatus = (res: any) => {
              // Deliberate == instead of ===
              return (Array.isArray(res) && res.length === 0) || res == null ? "emptyResource" : "success";
            };
            Severity: Major
            Found in packages/adapter-firebase-admin/src/utils/misc.ts and 1 other location - About 1 hr to fix
            packages/adapter-firebase/src/utils/misc.ts on lines 1..4

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

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

            export const isEqual = (firstValue: unknown, secondValue: unknown): boolean => {
              if (firstValue === secondValue) return true;
            
              try {
                const firstValueType = Object.prototype.toString.call(firstValue);
            Severity: Minor
            Found in packages/react/src/utils/deep-equal.utils.ts - About 1 hr to fix

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

              export const getSSEAdapter = (socket: SocketInstance) => {
                if (!window?.EventSource) return null;
                return new EventSource(getSocketUrl(socket), socket.options.adapterOptions?.protocols);
              };
              Severity: Major
              Found in packages/sockets/src/adapter/adapter.utils.ts and 1 other location - About 1 hr to fix
              packages/sockets/src/adapter/adapter.utils.ts on lines 12..15

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

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

                  const listen: ReturnType<FirestoreAdminSocketAdapterType>["listen"] = (listener, callback) => {
                    const fullUrl = socket.url + listener.endpoint;
                    const { options } = listener;
                    let pathRef: DocumentReference | Query = getRef(database, fullUrl);
                    if (pathRef instanceof CollectionReference) {
              Severity: Minor
              Found in packages/adapter-firebase-admin/src/firestore/firestore.sockets.ts - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language