BetterTyped/hyper-fetch

View on GitHub

Showing 248 of 345 total issues

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

  return makeRequest((resolve) => {
    const xhr = new XMLHttpRequest();
    xhr.timeout = defaultTimeout;

    const abort = () => xhr.abort();
Severity: Major
Found in packages/core/src/adapter/adapter.browser.ts and 1 other location - About 3 days to fix
packages/adapter-graphql/src/adapter/adapter.browser.ts on lines 25..89

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

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

  return makeRequest((resolve) => {
    const xhr = new XMLHttpRequest();
    xhr.timeout = defaultTimeout;

    const abort = () => xhr.abort();
Severity: Major
Found in packages/adapter-graphql/src/adapter/adapter.browser.ts and 1 other location - About 3 days to fix
packages/core/src/adapter/adapter.browser.ts on lines 35..99

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

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

export const getAdapterBindings = async <T extends AdapterInstance = AdapterType>(
  req: RequestInstance,
  requestId: string,
  systemErrorStatus: ExtractAdapterStatusType<T>,
  systemErrorExtra: ExtractAdapterExtraType<T>,
Severity: Major
Found in packages/core/src/adapter/adapter.bindings.ts - About 1 day to fix

    Function useFetch has 193 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const useFetch = <RequestType extends RequestInstance>(
      request: RequestType,
      options: UseFetchOptionsType<RequestType> = useFetchDefaultOptions,
    ): UseFetchReturnType<RequestType> => {
      // Build the configuration options
    Severity: Major
    Found in packages/react/src/hooks/use-fetch/use-fetch.hooks.ts - About 7 hrs to fix

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

              if (database instanceof Firestore) {
                const {
                  method = FirestoreMethods.getDocs,
                  queryParams,
                  data,
      Severity: Major
      Found in packages/adapter-firebase-admin/src/adapter/adapter.ts and 1 other location - About 7 hrs to fix
      packages/adapter-firebase/src/adapter/adapter.ts on lines 26..77

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

      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 (database instanceof Database) {
                const {
                  method = RealtimeDBMethods.get,
                  queryParams,
                  data,
      Severity: Major
      Found in packages/adapter-firebase/src/adapter/adapter.ts and 1 other location - About 7 hrs to fix
      packages/adapter-firebase-admin/src/adapter/adapter.ts on lines 26..68

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

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

      export const useSubmit = <RequestType extends RequestInstance>(
        request: RequestType,
        options: UseSubmitOptionsType<RequestType> = useSubmitDefaultOptions,
      ): UseSubmitReturnType<RequestType> => {
        // Build the configuration options
      Severity: Major
      Found in packages/react/src/hooks/use-submit/use-submit.hooks.ts - About 6 hrs to fix

        Identical blocks of code found in 4 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-graphql/jest.config.ts and 3 other locations - About 6 hrs to fix
        packages/adapter-axios/jest.config.ts on lines 3..29
        packages/codegen-openapi/jest.config.ts on lines 3..29
        packages/core/jest.config.ts on lines 3..29

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

        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 4 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-axios/jest.config.ts and 3 other locations - About 6 hrs to fix
        packages/adapter-graphql/jest.config.ts on lines 3..29
        packages/codegen-openapi/jest.config.ts on lines 3..29
        packages/core/jest.config.ts on lines 3..29

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

        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 4 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/core/jest.config.ts and 3 other locations - About 6 hrs to fix
        packages/adapter-axios/jest.config.ts on lines 3..29
        packages/adapter-graphql/jest.config.ts on lines 3..29
        packages/codegen-openapi/jest.config.ts on lines 3..29

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

        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 startEndConstraintsImpl = (constraintType: SharedQueryConstraints) => {
          return (...docOrFields: any[]) => {
            if (docOrFields.length === 1 && docOrFields[0].query) {
              return {
                toString: () => `${constraintType}_${docOrFields[0].query?._query?.memoizedTarget?.memoizedCanonicalId}`,
        packages/adapter-firebase-admin/src/constraints/firebase.constraints.ts on lines 48..63

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

        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 startEndConstraintsImpl = (constraintType: SharedQueryConstraints) => {
          return (...docOrFields: any[]) => {
            if (docOrFields.length === 1 && docOrFields[0].query) {
              return {
                toString: () => `${constraintType}_${docOrFields[0].query?._query?.memoizedTarget?.memoizedCanonicalId}`,
        packages/adapter-firebase/src/constraints/firebase.constraints.ts on lines 48..63

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

        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

          return async (methodName: FirestoreMethodsUnion, data) => {
            try {
              events.onRequestStart();
              const { result, status, extra } = await methods[methodName](data);
              events.onRequestEnd();
        packages/adapter-firebase-admin/src/firestore/firestore.methods.ts on lines 71..85
        packages/adapter-firebase-admin/src/realtime/realtime.methods.ts on lines 59..73
        packages/adapter-firebase/src/realtime/realtime.methods.ts on lines 63..77

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

        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

          return async (methodName: FirestoreMethodsUnion, data) => {
            try {
              events.onRequestStart();
              const { result, status, extra } = await methods[methodName](data);
              events.onRequestEnd();
        packages/adapter-firebase-admin/src/realtime/realtime.methods.ts on lines 59..73
        packages/adapter-firebase/src/firestore/firestore.methods.ts on lines 89..103
        packages/adapter-firebase/src/realtime/realtime.methods.ts on lines 63..77

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

        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

          return async (methodName: RealtimeDBMethodsUnion, data) => {
            try {
              events.onRequestStart();
              const { result, status, extra } = await methods[methodName](data);
              events.onRequestEnd();
        packages/adapter-firebase-admin/src/firestore/firestore.methods.ts on lines 71..85
        packages/adapter-firebase/src/firestore/firestore.methods.ts on lines 89..103
        packages/adapter-firebase/src/realtime/realtime.methods.ts on lines 63..77

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

        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

          return async (methodName: RealtimeDBMethodsUnion, data) => {
            try {
              events.onRequestStart();
              const { result, status, extra } = await methods[methodName](data);
              events.onRequestEnd();
        Severity: Major
        Found in packages/adapter-firebase/src/realtime/realtime.methods.ts and 3 other locations - About 5 hrs to fix
        packages/adapter-firebase-admin/src/firestore/firestore.methods.ts on lines 71..85
        packages/adapter-firebase-admin/src/realtime/realtime.methods.ts on lines 59..73
        packages/adapter-firebase/src/firestore/firestore.methods.ts on lines 89..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 153.

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

        export const useFetch = <RequestType extends RequestInstance>(
          request: RequestType,
          options: UseFetchOptionsType<RequestType> = useFetchDefaultOptions,
        ): UseFetchReturnType<RequestType> => {
          // Build the configuration options
        Severity: Minor
        Found in packages/react/src/hooks/use-fetch/use-fetch.hooks.ts - About 5 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

        File request.ts has 398 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import {
          RequestSendOptionsType,
          ParamsType,
          RequestSendType,
          PayloadType,
        Severity: Minor
        Found in packages/core/src/request/request.ts - About 5 hrs to fix

          Client has 40 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export class Client<
            GlobalErrorType extends ClientErrorType = Error,
            Adapter extends AdapterInstance = AdapterType,
            EndpointMapper extends DefaultEndpointMapper = DefaultEndpointMapper,
          > {
          Severity: Minor
          Found in packages/core/src/client/client.ts - About 5 hrs to fix

            Function websocketAdapter has 133 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const websocketAdapter: WebsocketAdapterType = (socket) => {
              const {
                open,
                listeners,
                connecting,
            Severity: Major
            Found in packages/sockets/src/adapter/adapter.websocket.ts - About 5 hrs to fix
              Severity
              Category
              Status
              Source
              Language