BetterTyped/hyper-fetch

View on GitHub

Showing 248 of 345 total issues

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

  return {
    open,
    connecting,
    reconnectionAttempts,
    forceClosed,
Severity: Major
Found in packages/sockets/src/adapter/adapter.bindings.ts and 1 other location - About 2 hrs to fix
packages/core/src/adapter/adapter.server.ts on lines 8..24

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

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

export const isDocOrQuery = (fullUrl: string): string => {
  const withoutSurroundingSlashes = fullUrl.replace(/^\/|\/$/g, "");
  const pathElements = withoutSurroundingSlashes.split("/").length;
  return pathElements % 2 === 0 ? "doc" : "query";
};
Severity: Major
Found in packages/adapter-firebase/src/utils/misc.ts and 1 other location - About 2 hrs to fix
packages/adapter-firebase-admin/src/utils/misc.ts on lines 6..10

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

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

export const isDocOrQuery = (fullUrl: string): string => {
  const withoutSurroundingSlashes = fullUrl.replace(/^\/|\/$/g, "");
  const pathElements = withoutSurroundingSlashes.split("/").length;
  return pathElements % 2 === 0 ? "doc" : "query";
};
Severity: Major
Found in packages/adapter-firebase-admin/src/utils/misc.ts and 1 other location - About 2 hrs to fix
packages/adapter-firebase/src/utils/misc.ts on lines 6..10

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

export type EmitType<Emitter extends EmitterInstance> = ExtractEmitterHasDataType<Emitter> extends false
  ? (
      options: EmitDataType<ExtractEmitterPayloadType<Emitter>, ExtractEmitterHasParamsType<Emitter>> &
        EmitParamsType<ExtractRouteParams<ExtractEmitterEndpointType<Emitter>>, ExtractEmitterHasParamsType<Emitter>> &
        EmitRestType<Emitter>,
Severity: Major
Found in packages/sockets/src/emitter/emitter.types.ts and 2 other locations - About 2 hrs to fix
packages/sockets/src/emitter/emitter.types.ts on lines 54..70
packages/sockets/src/emitter/emitter.types.ts on lines 60..70

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

  emitDownloadProgress: (
    queueKey: string,
    requestId: string,
    values: ProgressType,
    details: RequestEventType<RequestInstance>,
Severity: Major
Found in packages/core/src/managers/request/request.manager.events.ts and 1 other location - About 2 hrs to fix
packages/core/src/managers/request/request.manager.events.ts on lines 49..57

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

  () => {
    const adapter: FirebaseAdminAdapterTypes<T> = async (request, requestId) => {
      const { fullUrl, onSuccess, onError, onRequestStart, onResponseEnd, onResponseStart, onRequestEnd } =
        await getAdapterBindings<RealtimeDbAdapterType | FirestoreAdapterType>(request, requestId, "error", {});
      return new Promise<ResponseReturnType<any, any, FirebaseAdminAdapterTypes<T>>>((resolve) => {
Severity: Minor
Found in packages/adapter-firebase-admin/src/adapter/adapter.ts - About 2 hrs to fix

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

      emitUploadProgress: (
        queueKey: string,
        requestId: string,
        values: ProgressType,
        details: RequestEventType<RequestInstance>,
    Severity: Major
    Found in packages/core/src/managers/request/request.manager.events.ts and 1 other location - About 2 hrs to fix
    packages/core/src/managers/request/request.manager.events.ts on lines 58..66

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

      constructor(
        readonly client: Client<GlobalError, Adapter>,
        readonly requestOptions: RequestOptionsType<
          Endpoint,
          ExtractAdapterOptionsType<Adapter>,
    Severity: Minor
    Found in packages/core/src/request/request.ts - About 1 hr to fix

      Function useSubmit has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

      export const useSubmit = <RequestType extends RequestInstance>(
        request: RequestType,
        options: UseSubmitOptionsType<RequestType> = useSubmitDefaultOptions,
      ): UseSubmitReturnType<RequestType> => {
        // Build the configuration options
      Severity: Minor
      Found in packages/react/src/hooks/use-submit/use-submit.hooks.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

        onLoadingById: (requestId: string, callback: (values: RequestLoadingEventType) => void): VoidFunction => {
          emitter.on(getLoadingIdEventKey(requestId), callback);
          return () => emitter.removeListener(getLoadingIdEventKey(requestId), callback);
        },
      packages/core/src/managers/request/request.manager.events.ts on lines 188..191

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

      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

        onAbortById: (requestId: string, callback: (request: RequestInstance) => void): VoidFunction => {
          emitter.on(getAbortByIdEventKey(requestId), callback);
          return () => emitter.removeListener(getAbortByIdEventKey(requestId), callback);
        },
      packages/core/src/managers/request/request.manager.events.ts on lines 100..103

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

      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 {
          makeRequest,
          config,
          headers,
          onError,
      Severity: Major
      Found in packages/adapter-graphql/src/adapter/adapter.browser.ts and 1 other location - About 1 hr to fix
      packages/sockets/src/adapter/adapter.websocket.ts on lines 22..37

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

      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 {
          open,
          listeners,
          connecting,
          reconnectionAttempts,
      Severity: Major
      Found in packages/sockets/src/adapter/adapter.websocket.ts and 1 other location - About 1 hr to fix
      packages/adapter-graphql/src/adapter/adapter.browser.ts on lines 6..21

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

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

          const adapter: FirebaseAdminAdapterTypes<T> = async (request, requestId) => {
            const { fullUrl, onSuccess, onError, onRequestStart, onResponseEnd, onResponseStart, onRequestEnd } =
              await getAdapterBindings<RealtimeDbAdapterType | FirestoreAdapterType>(request, requestId, "error", {});
            return new Promise<ResponseReturnType<any, any, FirebaseAdminAdapterTypes<T>>>((resolve) => {
              if (database instanceof Firestore) {
      Severity: Minor
      Found in packages/adapter-firebase-admin/src/adapter/adapter.ts - About 1 hr to fix

        Function getRealtimeDbBrowserMethods has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const getRealtimeDbBrowserMethods = <R extends RequestInstance>(
          request: R,
          database: Database,
          url: string,
          onSuccess,
        Severity: Minor
        Found in packages/adapter-firebase/src/realtime/realtime.methods.ts - About 1 hr to fix

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

          export const useEventMessages = <ResponsesType extends { endpoint: string }>(
            socket: SocketInstance,
            options: UseEventMessagesOptionsType<ResponsesType>,
          ) => {
            const [globalConfig] = useConfigProvider();

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

            export const $limit = (num: number) => {
              return {
                toString: () => `${FirestoreQueryConstraints.LIMIT}_${num}`,
                type: FirestoreQueryConstraints.LIMIT as const,
                values: [num],
            packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 95..101
            packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 103..109
            packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 40..46
            packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 95..101
            packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 103..109

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

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

            export const $limit = (num: number) => {
              return {
                toString: () => `${FirestoreQueryConstraints.LIMIT}_${num}`,
                type: FirestoreQueryConstraints.LIMIT as const,
                values: [num],
            packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 40..46
            packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 95..101
            packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 103..109
            packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 95..101
            packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 103..109

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

            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

            export const $equalTo = (value: any) => {
              return {
                toString: () => `${RealtimeQueryConstraints.LIMIT_TO_LAST}_${value}`,
                type: RealtimeQueryConstraints.EQUAL_TO as const,
                values: [value],
            packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 111..117

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

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

            export const $limitToFirst = (num: number) => {
              return {
                toString: () => `${RealtimeQueryConstraints.LIMIT_TO_FIRST}_${num}`,
                type: RealtimeQueryConstraints.LIMIT_TO_FIRST as const,
                values: [num],
            packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 40..46
            packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 103..109
            packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 40..46
            packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 95..101
            packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 103..109

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

            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