rescribet/link-redux

View on GitHub
src/hooks/__tests__/useParsedField.spec.tsx

Summary

Maintainability
F
6 days
Test Coverage

File useParsedField.spec.tsx has 501 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import rdfFactory, { NamedNode, QuadPosition, Quadruple } from "@ontologies/core";
import * as schema from "@ontologies/schema";
import { act, render } from "@testing-library/react";
import { renderHook } from "@testing-library/react-hooks";
import React from "react";
Severity: Major
Found in src/hooks/__tests__/useParsedField.spec.tsx - About 1 day to fix

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

            return (
              <div>
                <div data-testid="len">{fields.length}</div>
                <div data-testid="s">{q1?.[QuadPosition.subject]?.value}</div>
                <div data-testid="p">{q1?.[QuadPosition.predicate]?.value}</div>
    Severity: Major
    Found in src/hooks/__tests__/useParsedField.spec.tsx and 1 other location - About 6 hrs to fix
    src/hooks/__tests__/useParsedField.spec.tsx on lines 64..72

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

    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 (
              <div>
                <div data-testid="len">{fields.length}</div>
                <div data-testid="s">{q1?.[QuadPosition.subject]?.value}</div>
                <div data-testid="p">{q1?.[QuadPosition.predicate]?.value}</div>
    Severity: Major
    Found in src/hooks/__tests__/useParsedField.spec.tsx and 1 other location - About 6 hrs to fix
    src/hooks/__tests__/useParsedField.spec.tsx on lines 107..115

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

    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 Comp = ({ resource }: { resource: NamedNode | undefined }) => {
            const id = React.useRef(idCounter++); // to ensure we don't remount a different instance
            const [data] = useHook(resource, [schema.name]);
    
            return (
    Severity: Major
    Found in src/hooks/__tests__/useParsedField.spec.tsx and 1 other location - About 5 hrs to fix
    src/hooks/__tests__/useParsedField.spec.tsx on lines 296..306

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

    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 Comp = ({ resource }: { resource: NamedNode | undefined }) => {
            const id = React.useRef(idCounter++); // to ensure we don't remount a different instance
            const [data] = useHook(resource, [schema.name]);
    
            return (
    Severity: Major
    Found in src/hooks/__tests__/useParsedField.spec.tsx and 1 other location - About 5 hrs to fix
    src/hooks/__tests__/useParsedField.spec.tsx on lines 263..273

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

    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

          it("unpacks circular List", () => {
            const { wrapper } = ctx.fullCW();
            const { result: { current } } = renderHook(() => useValues(array(example.ns("circular"))), { wrapper });
    
            expect(current).toEqual(["c0", "c1"]);
    Severity: Major
    Found in src/hooks/__tests__/useParsedField.spec.tsx and 2 other locations - About 3 hrs to fix
    src/hooks/__tests__/useParsedField.spec.tsx on lines 404..409
    src/hooks/__tests__/useParsedField.spec.tsx on lines 411..416

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 100.

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

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

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

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

    Refactorings

    Further Reading

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

          it("unpacks endless List", () => {
            const { wrapper } = ctx.fullCW();
            const { result: { current } } = renderHook(() => useValues(array(example.ns("endless"))), { wrapper });
    
            expect(current).toEqual(["e0", "e1"]);
    Severity: Major
    Found in src/hooks/__tests__/useParsedField.spec.tsx and 2 other locations - About 3 hrs to fix
    src/hooks/__tests__/useParsedField.spec.tsx on lines 404..409
    src/hooks/__tests__/useParsedField.spec.tsx on lines 418..423

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 100.

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

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

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

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

    Refactorings

    Further Reading

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

          it("unpacks broken List", () => {
            const { wrapper } = ctx.fullCW();
            const { result: { current } } = renderHook(() => useValues(array(example.ns("broken"))), { wrapper });
    
            expect(current).toEqual(["b0", "b1"]);
    Severity: Major
    Found in src/hooks/__tests__/useParsedField.spec.tsx and 2 other locations - About 3 hrs to fix
    src/hooks/__tests__/useParsedField.spec.tsx on lines 411..416
    src/hooks/__tests__/useParsedField.spec.tsx on lines 418..423

    Duplicated Code

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

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

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

    Tuning

    This issue has a mass of 100.

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

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

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

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

    Refactorings

    Further Reading

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

          describe("useDates", () => {
            const result = [new Date(dateLiteral.value)];
    
            it("returns a parsed value", () => {
              const value = renderHook(() => useDates(prop), { wrapper });
    Severity: Major
    Found in src/hooks/__tests__/useParsedField.spec.tsx and 1 other location - About 2 hrs to fix
    src/hooks/__tests__/useParsedField.spec.tsx on lines 628..636

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

    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

          describe("useUrls", () => {
            const result = [new URL(globalId.value)];
    
            it("returns a parsed value", () => {
              const value = renderHook(() => useUrls(prop), { wrapper });
    Severity: Major
    Found in src/hooks/__tests__/useParsedField.spec.tsx and 1 other location - About 2 hrs to fix
    src/hooks/__tests__/useParsedField.spec.tsx on lines 565..573

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

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

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

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

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

    Refactorings

    Further Reading

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

          const { getByTestId, rerender } = render(<Comp resource={firstId} />, { wrapper: opts.wrapper });
    Severity: Minor
    Found in src/hooks/__tests__/useParsedField.spec.tsx and 1 other location - About 35 mins to fix
    src/hooks/__tests__/useDataInvalidation.spec.tsx on lines 117..117

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

    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: { current } } = renderHook(() => useValues(array(schema.reviews)), { wrapper });
    Severity: Minor
    Found in src/hooks/__tests__/useParsedField.spec.tsx and 2 other locations - About 30 mins to fix
    src/hooks/__tests__/useParsedField.spec.tsx on lines 382..382
    src/hooks/__tests__/useParsedField.spec.tsx on lines 389..392

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

    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: { current } } = renderHook(
              () => useValues(array(schema.isSimilarTo)),
              { wrapper },
            );
    Severity: Minor
    Found in src/hooks/__tests__/useParsedField.spec.tsx and 2 other locations - About 30 mins to fix
    src/hooks/__tests__/useParsedField.spec.tsx on lines 382..382
    src/hooks/__tests__/useParsedField.spec.tsx on lines 399..399

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

    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: { current } } = renderHook(() => useValues(array(schema.comment)), { wrapper });
    Severity: Minor
    Found in src/hooks/__tests__/useParsedField.spec.tsx and 2 other locations - About 30 mins to fix
    src/hooks/__tests__/useParsedField.spec.tsx on lines 389..392
    src/hooks/__tests__/useParsedField.spec.tsx on lines 399..399

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

    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