BetterTyped/hyper-fetch

View on GitHub

Showing 248 of 345 total issues

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

const config: Config.InitialOptions = {
  cacheDirectory: "../../node_modules/.cache/rhf/jest",
  testEnvironment: "jsdom",
  preset: "ts-jest",
  testRegex: [".spec.ts"],
Severity: Major
Found in packages/adapter-firebase-admin/jest.config.ts and 2 other locations - About 5 hrs to fix
packages/adapter-firebase/jest.config.ts on lines 3..25
packages/sockets/jest.config.ts on lines 3..25

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

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 getGroupedResultFirestore = (snapshot: any) => {
  const groupedResult = { added: [], modified: [], removed: [] };
  snapshot.docChanges().forEach((change) => {
    groupedResult[change.type].push(change.doc.data());
  });
packages/adapter-firebase/src/firestore/utils/result.utils.ts on lines 9..17

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

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 getGroupedResultFirestore = (snapshot: any) => {
  const groupedResult = { added: [], modified: [], removed: [] };
  snapshot.docChanges().forEach((change) => {
    groupedResult[change.type].push(change.doc.data());
  });
packages/adapter-firebase-admin/src/firestore/utils/result.utils.ts on lines 9..17

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

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 type FirestoreAdapterType =
  | AdapterType<Record<string, never>, "getDoc", FirestoreStatuses, FirestoreExtra, FirestoreQueryParams>
  | AdapterType<Record<string, never>, "getDocs", FirestoreStatuses, FirestoreGetDocsExtra, FirestoreQueryParams>
  | AdapterType<{ merge: boolean }, "setDoc", FirestoreStatuses, FirestoreRefOnlyExtra, Record<string, never>>
  | AdapterType<
packages/adapter-firebase/src/adapter/types/adapter.firestore.types.ts on lines 24..34

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

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 type FirestoreAdapterType =
  | AdapterType<Record<string, never>, "getDoc", FirestoreStatuses, FirestoreExtra, FirestoreQueryParams>
  | AdapterType<Record<string, never>, "getDocs", FirestoreStatuses, FirestoreGetDocsExtra, FirestoreQueryParams>
  | AdapterType<{ merge: boolean }, "setDoc", FirestoreStatuses, FirestoreRefOnlyExtra, Record<string, never>>
  | AdapterType<
packages/adapter-firebase-admin/src/adapter/types/adapter.firestore.types.ts on lines 24..34

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

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 124 lines of code (exceeds 25 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: Major
Found in packages/sockets/src/adapter/adapter.bindings.ts - About 4 hrs to fix

    Function getAdapterBindings has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

    export const getAdapterBindings = async <T extends AdapterInstance = AdapterType>(
      req: RequestInstance,
      requestId: string,
      systemErrorStatus: ExtractAdapterStatusType<T>,
      systemErrorExtra: ExtractAdapterExtraType<T>,
    Severity: Minor
    Found in packages/core/src/adapter/adapter.bindings.ts - About 4 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

    Request has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class Request<
      Response,
      Payload,
      QueryParams,
      GlobalError, // Global Error Type
    Severity: Minor
    Found in packages/core/src/request/request.ts - About 4 hrs to fix

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

        private paramsMapper = (params: ParamsType | null | undefined): Endpoint => {
          let endpoint = this.emitterOptions.endpoint as string;
          if (params) {
            Object.entries(params).forEach(([key, value]) => {
              endpoint = endpoint.replace(new RegExp(`:${key}`, "g"), String(value));
      Severity: Major
      Found in packages/sockets/src/emitter/emitter.ts and 1 other location - About 4 hrs to fix
      packages/sockets/src/listener/listener.ts on lines 36..45

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

      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

        private paramsMapper = (params: ParamsType | null | undefined): Endpoint => {
          let endpoint = this.listenerOptions.endpoint as string;
          if (params) {
            Object.entries(params).forEach(([key, value]) => {
              endpoint = endpoint.replace(new RegExp(`:${key}`, "g"), String(value));
      Severity: Major
      Found in packages/sockets/src/listener/listener.ts and 1 other location - About 4 hrs to fix
      packages/sockets/src/emitter/emitter.ts on lines 72..81

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

      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,
          fullUrl,
      Severity: Major
      Found in packages/adapter-axios/src/adapter/adapter.ts and 1 other location - About 3 hrs to fix
      packages/core/src/adapter/adapter.browser.ts on lines 12..31

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

      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,
          fullUrl,
          config,
          payload,
      Severity: Major
      Found in packages/core/src/adapter/adapter.browser.ts and 1 other location - About 3 hrs to fix
      packages/adapter-axios/src/adapter/adapter.ts on lines 7..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 110.

      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

      File client.ts has 316 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import {
        adapter as defaultAdapter,
        AdapterInstance,
        AdapterPayloadMappingType,
        AdapterType,
      Severity: Minor
      Found in packages/core/src/client/client.ts - About 3 hrs to fix

        Function sseAdapter has 85 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const sseAdapter: SSEAdapterType = (socket) => {
          const {
            open,
            reconnectionAttempts,
            listeners,
        Severity: Major
        Found in packages/sockets/src/adapter/adapter.sse.ts - About 3 hrs to fix

          Function firestoreSockets has 84 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const firestoreSockets = (database: Firestore): FirestoreSocketAdapterType => {
            return (socket) => {
              const {
                open,
                connecting,
          Severity: Major
          Found in packages/adapter-firebase/src/firestore/firestore.sockets.ts - About 3 hrs to fix

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

              const handleRequestProgress = (
                startTimestamp: number,
                progressTimestamp: number,
                progressEvent: AdapterProgressEventType,
              ) => {
            Severity: Major
            Found in packages/core/src/adapter/adapter.bindings.ts and 1 other location - About 3 hrs to fix
            packages/core/src/adapter/adapter.bindings.ts on lines 108..119

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

            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 handleResponseProgress = (
                startTimestamp: number,
                progressTimestamp: number,
                progressEvent: AdapterProgressEventType,
              ) => {
            Severity: Major
            Found in packages/core/src/adapter/adapter.bindings.ts and 1 other location - About 3 hrs to fix
            packages/core/src/adapter/adapter.bindings.ts on lines 95..106

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

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

            export const useCache = <T extends RequestInstance>(
              request: T,
              options: UseCacheOptionsType<T> = useCacheDefaultOptions,
            ): UseCacheReturnType<T> => {
              const { cacheKey, client } = request;
            Severity: Major
            Found in packages/react/src/hooks/use-cache/use-cache.hooks.ts - About 3 hrs to fix

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

                onUploadProgressById: <T extends RequestInstance = RequestInstance>(
                  requestId: string,
                  callback: (values: ProgressType, details: RequestEventType<T>) => void,
                ): VoidFunction => {
                  emitter.on(getUploadProgressIdEventKey(requestId), callback);
              packages/core/src/managers/request/request.manager.events.ts on lines 151..157
              packages/core/src/managers/request/request.manager.events.ts on lines 158..164

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

              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

                onDownloadProgress: <T extends RequestInstance = RequestInstance>(
                  queueKey: string,
                  callback: (values: ProgressType, details: RequestEventType<T>) => void,
                ): VoidFunction => {
                  emitter.on(getDownloadProgressEventKey(queueKey), callback);
              packages/core/src/managers/request/request.manager.events.ts on lines 144..150
              packages/core/src/managers/request/request.manager.events.ts on lines 158..164

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

              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