react18-tools/nextjs-themes-ultra

View on GitHub

Showing 17 of 17 total issues

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

  test("Test theme", ({ expect }) => {
    const { result } = renderHook(() => useTheme());
    act(() => result.current.setTheme("my-theme"));
    expect(result.current.theme).toBe("my-theme");
  });
Severity: Major
Found in lib/src/hooks/use-theme.test.ts and 1 other location - About 2 hrs to fix
lib/src/hooks/use-theme.test.ts on lines 8..12

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

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

  test("Test colorSchemePreference", ({ expect }) => {
    const { result } = renderHook(() => useTheme());
    act(() => result.current.setColorSchemePreference("light"));
    expect(result.current.colorSchemePreference).toBe("light");
  });
Severity: Major
Found in lib/src/hooks/use-theme.test.ts and 1 other location - About 2 hrs to fix
lib/src/hooks/use-theme.test.ts on lines 14..18

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

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

function getNestedRouteActions(data) {
  const { isClient } = data;
  const name = data.name.replace(/\/+/g, "/").replace(/\/$/, "").trim();
  const root = `${data.pkgPath}/src/${isClient ? "client/" : "server/"}`;
  const nestedRouteActions = [];
Severity: Minor
Found in scripts/rc.js - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

  test("test custom tag", ({ expect }) => {
    render(<ServerTarget tag="h1" />);
    expect(screen.getByTestId("server-target").tagName).toBe("H1");
  });
Severity: Major
Found in lib/src/server/server-target/server-target.test.tsx and 1 other location - About 1 hr to fix
lib/src/server/force-theme/force-theme.test.tsx on lines 13..16

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

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

  test("force theme", ({ expect }) => {
    render(<ForceTheme theme="my-theme" />);
    expect(screen.getByTestId("force-theme").classList).toContain("th-my-theme");
  });
Severity: Major
Found in lib/src/server/force-theme/force-theme.test.tsx and 1 other location - About 1 hr to fix
lib/src/server/server-target/server-target.test.tsx on lines 14..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 65.

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

function getNestedRouteActions(data) {
  const { isClient } = data;
  const name = data.name.replace(/\/+/g, "/").replace(/\/$/, "").trim();
  const root = `${data.pkgPath}/src/${isClient ? "client/" : "server/"}`;
  const nestedRouteActions = [];
Severity: Minor
Found in scripts/rc.js - About 1 hr to fix

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

      test("check specificity class exists", ({ expect }) => {
        render(<ForceTheme />);
        expect(screen.getByTestId("force-theme").classList).toContain("nth-scoped");
      });
    Severity: Major
    Found in lib/src/server/force-theme/force-theme.test.tsx and 1 other location - About 1 hr to fix
    lib/src/server/server-target/server-target.test.tsx on lines 9..12

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

    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

      test("test default tag", ({ expect }) => {
        render(<ServerTarget />);
        expect(screen.getByTestId("server-target").tagName).toBe("DIV");
      });
    Severity: Major
    Found in lib/src/server/server-target/server-target.test.tsx and 1 other location - About 1 hr to fix
    lib/src/server/force-theme/force-theme.test.tsx on lines 8..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 60.

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

    export default function ThemeSwitch() {
      const { colorSchemePreference, setColorSchemePreference } = useTheme();
      const toggle = useCallback(() => {
        switch (colorSchemePreference) {
          case "dark":
    Severity: Minor
    Found in packages/shared/src/client/header/theme-switch.tsx - About 1 hr to fix

      Function getActions has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function getActions(data) {
        const actions = [];
        if (!fs.existsSync(path.resolve(__dir, `${data.pkgPath}/src/hooks`, "index.ts"))) {
          actions.push({
            type: "add",
      Severity: Minor
      Found in scripts/hook.js - About 1 hr to fix

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

        describe.concurrent("global-loader", () => {
          afterEach(cleanup);
        
          test("check if renders", () => {
            render(<GlobalLoader />);
        packages/shared/src/client/demo/demo.test.tsx on lines 5..11
        packages/shared/src/client/header/header.test.tsx on lines 5..11
        packages/shared/src/server/layout/layout.test.tsx on lines 5..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 50.

        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

        describe.concurrent("layout", () => {
          afterEach(cleanup);
        
          test("check if renders without errors", () => {
            render(<Layout />);
        Severity: Major
        Found in packages/shared/src/server/layout/layout.test.tsx and 3 other locations - About 45 mins to fix
        packages/shared/src/client/demo/demo.test.tsx on lines 5..11
        packages/shared/src/client/global-loader/global-loader.test.tsx on lines 5..11
        packages/shared/src/client/header/header.test.tsx on lines 5..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 50.

        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

        describe.concurrent("header", () => {
          afterEach(cleanup);
        
          test("check if h1 heading exists", () => {
            render(<Header />);
        Severity: Major
        Found in packages/shared/src/client/header/header.test.tsx and 3 other locations - About 45 mins to fix
        packages/shared/src/client/demo/demo.test.tsx on lines 5..11
        packages/shared/src/client/global-loader/global-loader.test.tsx on lines 5..11
        packages/shared/src/server/layout/layout.test.tsx on lines 5..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 50.

        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

        describe.concurrent("demo", () => {
          afterEach(cleanup);
        
          test("Dummy test - test if renders without errors", () => {
            render(<Demo />);
        Severity: Major
        Found in packages/shared/src/client/demo/demo.test.tsx and 3 other locations - About 45 mins to fix
        packages/shared/src/client/global-loader/global-loader.test.tsx on lines 5..11
        packages/shared/src/client/header/header.test.tsx on lines 5..11
        packages/shared/src/server/layout/layout.test.tsx on lines 5..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 50.

        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

          actions.push({
            type: "add",
            path: `${data.pkgPath}/src/hooks/{{kebabCase name}}.test.ts`,
            templateFile: `${TEMPLATE_DIR}hook.test.hbs`,
          });
        Severity: Minor
        Found in scripts/hook.js and 1 other location - About 40 mins to fix
        scripts/hook.js on lines 29..33

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

        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

          actions.push({
            type: "add",
            path: `${data.pkgPath}/src/hooks/{{kebabCase name}}.ts`,
            templateFile: `${TEMPLATE_DIR}hook.hbs`,
          });
        Severity: Minor
        Found in scripts/hook.js and 1 other location - About 40 mins to fix
        scripts/hook.js on lines 35..39

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

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

        export function ColorSwitch({ targetId, skipSystem, size, ...props }: ColorSwitchProps) {
          const {
            setColorSchemePreference,
            resolvedColorScheme: rcs,
            colorSchemePreference: csp,
        Severity: Minor
        Found in lib/src/client/color-switch/color-switch.tsx - About 25 mins 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

        Severity
        Category
        Status
        Source
        Language