vorteil/direktiv

View on GitHub
ui/src/api/__tests__/apiFactory.test.ts

Summary

Maintainability
F
4 days
Test Coverage

File apiFactory.test.ts has 418 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import "cross-fetch/polyfill";

import { ResponseParser, apiFactory } from "../apiFactory";
import {
  afterAll,
Severity: Minor
Found in ui/src/api/__tests__/apiFactory.test.ts - About 6 hrs to fix

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

        await waitFor(() => {
          expect(result.current.isSuccess).toBe(false);
          expect(result.current.status).toBe("error");
          const res = result.current.error;
          const parsedRes = ApiErrorSchema.safeParse(res);
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 1 other location - About 6 hrs to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 216..228

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

    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

        await waitFor(() => {
          expect(result.current.isSuccess).toBe(false);
          expect(result.current.status).toBe("error");
    
          const res = result.current.error;
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 1 other location - About 6 hrs to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 310..321

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

    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

      rest.get(apiEndpoint, (req, res, ctx) =>
        req?.headers?.get("direktiv-token") === API_KEY
          ? res(
              ctx.json({
                response: "this works",
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 1 other location - About 1 hr to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 43..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 68.

    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

      rest.get(apiEndpointWithDynamicSegment, (req, res, ctx) =>
        req?.headers?.get("direktiv-token") === API_KEY
          ? res(
              ctx.json({
                response: "dynamic segment this works",
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 1 other location - About 1 hr to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 34..42

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

    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

        await waitFor(() => {
          expect(result.current.isSuccess).toBe(true);
          expect(result.current.data?.response).toBe("this works");
        });
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 2 other locations - About 1 hr to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 373..376
    ui/src/api/__tests__/apiFactory.test.ts on lines 436..439

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

    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

        await waitFor(() => {
          expect(result.current.isSuccess).toBe(true);
          expect(result.current.data?.my).toBe("custom header");
        });
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 2 other locations - About 1 hr to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 195..198
    ui/src/api/__tests__/apiFactory.test.ts on lines 373..376

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

    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

        await waitFor(() => {
          expect(result.current.isSuccess).toBe(true);
          expect(result.current.data?.response).toBe("dynamic segment this works");
        });
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 2 other locations - About 1 hr to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 195..198
    ui/src/api/__tests__/apiFactory.test.ts on lines 436..439

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

    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

        const { result } = renderHook(
          () =>
            useQuery({
              queryKey: ["getmyapikey", API_KEY],
              queryFn: () =>
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 2 other locations - About 1 hr to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 272..285
    ui/src/api/__tests__/apiFactory.test.ts on lines 296..309

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 63.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

        const { result } = renderHook(
          () =>
            useQuery({
              queryKey: ["getmyapikey", API_KEY],
              queryFn: () =>
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 2 other locations - About 1 hr to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 272..285
    ui/src/api/__tests__/apiFactory.test.ts on lines 325..338

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 63.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

        const { result } = renderHook(
          () =>
            useQuery({
              queryKey: ["getmyapikey", API_KEY],
              queryFn: () =>
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 2 other locations - About 1 hr to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 296..309
    ui/src/api/__tests__/apiFactory.test.ts on lines 325..338

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 63.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

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

    const api404 = apiFactory({
      url: () => apiEndpoint404,
      method: "GET",
      schema: z.object({
        response: z.string(),
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 4 other locations - About 50 mins to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 103..109
    ui/src/api/__tests__/apiFactory.test.ts on lines 125..129
    ui/src/api/__tests__/apiFactory.test.ts on lines 139..145
    ui/src/api/__tests__/apiFactory.test.ts on lines 147..153

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

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

    const apiJSONError = apiFactory({
      url: () => apiEndpointJSONError,
      method: "GET",
      schema: z.object({
        response: z.string(),
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 4 other locations - About 50 mins to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 103..109
    ui/src/api/__tests__/apiFactory.test.ts on lines 125..129
    ui/src/api/__tests__/apiFactory.test.ts on lines 131..137
    ui/src/api/__tests__/apiFactory.test.ts on lines 147..153

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

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

    const getMyApi = apiFactory({
      url: () => apiEndpoint,
      method: "GET",
      schema: z.object({
        response: z.string(),
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 4 other locations - About 50 mins to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 125..129
    ui/src/api/__tests__/apiFactory.test.ts on lines 131..137
    ui/src/api/__tests__/apiFactory.test.ts on lines 139..145
    ui/src/api/__tests__/apiFactory.test.ts on lines 147..153

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

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

    const apiPost = apiFactory({
      url: () => apiEndpointPost,
      method: "POST",
      schema: z.object({
        body: z.string(),
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 4 other locations - About 50 mins to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 103..109
    ui/src/api/__tests__/apiFactory.test.ts on lines 125..129
    ui/src/api/__tests__/apiFactory.test.ts on lines 131..137
    ui/src/api/__tests__/apiFactory.test.ts on lines 139..145

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

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

    const textResponse = apiFactory({
      url: () => apiEndpointTextResponse,
      method: "GET",
      schema: z.object({ body: z.string() }),
    });
    Severity: Major
    Found in ui/src/api/__tests__/apiFactory.test.ts and 4 other locations - About 50 mins to fix
    ui/src/api/__tests__/apiFactory.test.ts on lines 103..109
    ui/src/api/__tests__/apiFactory.test.ts on lines 131..137
    ui/src/api/__tests__/apiFactory.test.ts on lines 139..145
    ui/src/api/__tests__/apiFactory.test.ts on lines 147..153

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

    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

    There are no issues that match your filters.

    Category
    Status