BetterTyped/hyper-fetch

View on GitHub

Showing 248 of 345 total issues

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

export const getWebsocketAdapter = (socket: SocketInstance) => {
  if (!window?.WebSocket) return null;
  return new WebSocket(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 17..20

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

    const listen: ReturnType<RealtimeSocketAdapterType>["listen"] = (listener, callback) => {
      const fullUrl = socket.url + listener.endpoint;
      const path = ref(database, fullUrl);

      const { options } = listener;
Severity: Minor
Found in packages/adapter-firebase/src/realtime/realtime.sockets.ts - About 1 hr to fix

    Function handleMountEvents has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const handleMountEvents = () => {
        addDataListener(request);
        addLifecycleListeners(request);
    
        const focusUnmount = appManager.events.onFocus(() => {
    Severity: Minor
    Found in packages/react/src/hooks/use-fetch/use-fetch.hooks.ts - About 1 hr to fix

      Function clone has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        public clone<D extends true | false = HasData, P extends true | false = HasParams, Q extends true | false = HasQuery>(
          options?: RequestCurrentType<
            Payload,
            QueryParams,
            Endpoint,
      Severity: Minor
      Found in packages/core/src/request/request.ts - About 1 hr to fix

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

        export const applyFireStoreAdminConstraints = (
          collectionRef: CollectionReference,
          constraints: FirestorePermittedMethods[],
        ) => {
          return constraints.reduce((collection, constraint) => {
        packages/adapter-firebase-admin/src/realtime/utils/constraints.utils.ts on lines 50..54

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

        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 applyRealtimeAdminConstraints = (ref: Reference, constraints: RealtimePermittedMethods[]) => {
          return constraints.reduce((collection, constraint) => {
            return applyRealtimeAdminConstraint(collection, constraint);
          }, ref);
        };
        packages/adapter-firebase-admin/src/firestore/utils/constraints.utils.ts on lines 44..51

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

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

            const httpRequest = httpClient.request(options, (response) => {
              response.setEncoding("utf8");
              unmountListener = createAbortListener(0, gqlExtra, response.destroy, resolve);
        
              let chunks = "";
        Severity: Minor
        Found in packages/adapter-graphql/src/adapter/adapter.server.ts - About 1 hr to fix

          Function listen has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              const listen: ReturnType<RealtimeAdminSocketAdapterType>["listen"] = (listener, callback) => {
                const fullUrl = socket.url + listener.endpoint;
                const path = database.ref(fullUrl);
                const { options } = listener;
                const onlyOnce = options?.onlyOnce || false;
          Severity: Minor
          Found in packages/adapter-firebase-admin/src/realtime/realtime.sockets.ts - About 1 hr to fix

            Function httpRequest has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                const httpRequest = httpClient.request(requestUrl, options, (response) => {
                  response.setEncoding("utf8");
                  unmountListener = createAbortListener(0, xhrExtra, response.destroy, resolve);
            
                  let chunks = "";
            Severity: Minor
            Found in packages/core/src/adapter/adapter.server.ts - About 1 hr to fix

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

                const adapter: GraphQLAdapterType = async (request, requestId) => {
                  if (typeof XMLHttpRequest !== "undefined") {
                    return browser.adapter(request, requestId);
                  }
                  return server.adapter(request, requestId);
              Severity: Major
              Found in packages/adapter-graphql/src/adapter/adapter.ts and 1 other location - About 1 hr to fix
              packages/core/src/adapter/adapter.ts on lines 6..11

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

              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

                setLoggerSeverity = (severity: SeverityType): Client<GlobalErrorType, Adapter, EndpointMapper> => {
                  this.loggerManager.setSeverity(severity);
                  return this;
                };
              Severity: Major
              Found in packages/core/src/client/client.ts and 2 other locations - About 1 hr to fix
              packages/core/src/client/client.ts on lines 262..265
              packages/core/src/client/client.ts on lines 320..323

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

              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

                onAuth = (callback: RequestInterceptorType): Client<GlobalErrorType, Adapter, EndpointMapper> => {
                  this.__onAuthCallbacks.push(callback);
                  return this;
                };
              Severity: Major
              Found in packages/core/src/client/client.ts and 2 other locations - About 1 hr to fix
              packages/core/src/client/client.ts on lines 154..157
              packages/core/src/client/client.ts on lines 320..323

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

              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

                onRequest = (callback: RequestInterceptorType): Client<GlobalErrorType, Adapter, EndpointMapper> => {
                  this.__onRequestCallbacks.push(callback);
                  return this;
                };
              Severity: Major
              Found in packages/core/src/client/client.ts and 2 other locations - About 1 hr to fix
              packages/core/src/client/client.ts on lines 154..157
              packages/core/src/client/client.ts on lines 262..265

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

              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 adapter: AdapterType = async (request, requestId) => {
                if (typeof XMLHttpRequest !== "undefined") {
                  return browser.adapter(request, requestId);
                }
                return server.adapter(request, requestId);
              Severity: Major
              Found in packages/core/src/adapter/adapter.ts and 1 other location - About 1 hr to fix
              packages/adapter-graphql/src/adapter/adapter.ts on lines 9..14

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

              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

                  if (controllers) {
                    const entries = Array.from(controllers.entries());
                    entries.forEach(([key]) => {
                      this.useAbortController(abortKey, key);
                    });
              Severity: Major
              Found in packages/core/src/managers/request/request.manager.ts and 1 other location - About 1 hr to fix
              packages/core/src/managers/request/request.manager.ts on lines 61..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 56.

              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

                  entries.forEach(([abortKey, value]) => {
                    const controllers = Array.from(value.entries());
                    controllers.forEach(([requestId]) => {
                      this.useAbortController(abortKey, requestId);
                    });
              Severity: Major
              Found in packages/core/src/managers/request/request.manager.ts and 1 other location - About 1 hr to fix
              packages/core/src/managers/request/request.manager.ts on lines 47..52

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

              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 26 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.sse.ts - About 1 hr to fix

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

                    set: async ({ data }) => {
                      await path.set(data);
                      return { result: data, status: "success", extra: { ref: path } };
                    },
                packages/adapter-firebase-admin/src/realtime/realtime.methods.ts on lines 49..52

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

                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

                    requestManager.events.emitLoading(queueKey, requestId, {
                      queueKey,
                      requestId,
                      loading: true,
                      isRetry: !!storageElement.retries,
                Severity: Major
                Found in packages/core/src/dispatcher/dispatcher.ts and 1 other location - About 1 hr to fix
                packages/core/src/dispatcher/dispatcher.ts on lines 533..539

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

                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

                    requestManager.events.emitLoading(queueKey, requestId, {
                      queueKey,
                      requestId,
                      loading: false,
                      isRetry: !!storageElement.retries,
                Severity: Major
                Found in packages/core/src/dispatcher/dispatcher.ts and 1 other location - About 1 hr to fix
                packages/core/src/dispatcher/dispatcher.ts on lines 498..504

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

                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