rescribet/link-redux

View on GitHub

Showing 39 of 39 total issues

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

describe("useResourceView", () => {
  let container: HTMLElement | undefined;

  beforeEach(() => {
    container = document.createElement("div");
Severity: Major
Found in src/hooks/__tests__/useResourceView.spec.tsx and 2 other locations - About 2 days to fix
src/hooks/__tests__/useResourcePropertyView.spec.tsx on lines 11..51
src/hooks/__tests__/useView.spec.tsx on lines 11..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 392.

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

describe("useResourcePropertyView", () => {
  let container: HTMLElement | undefined;

  beforeEach(() => {
    container = document.createElement("div");
Severity: Major
Found in src/hooks/__tests__/useResourcePropertyView.spec.tsx and 2 other locations - About 2 days to fix
src/hooks/__tests__/useResourceView.spec.tsx on lines 11..51
src/hooks/__tests__/useView.spec.tsx on lines 11..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 392.

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

describe("useView", () => {
  let container: HTMLElement | undefined;

  beforeEach(() => {
    container = document.createElement("div");
Severity: Major
Found in src/hooks/__tests__/useView.spec.tsx and 2 other locations - About 2 days to fix
src/hooks/__tests__/useResourcePropertyView.spec.tsx on lines 11..51
src/hooks/__tests__/useResourceView.spec.tsx on lines 11..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 392.

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

export const Property: React.ComponentType<PropertyPropTypes & any> = (props): React.ReactElement<any> | null => {
    const lrs = useLRS();
    const childPropsOrFallback = useChildPropsOrFallback(props);

    if (childPropsOrFallback === null || !Array.isArray(childPropsOrFallback)) {
Severity: Major
Found in src/components/Property.tsx - About 2 hrs to fix

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

      describe("rendering", () => {
        it("has force", () => expect(renderAlways(schema.name))
          .toHaveProperty("forceRender", true));
        it("has partial", () => expect(renderPartial(schema.name))
          .toHaveProperty("forceRender", false));
    Severity: Major
    Found in src/__tests__/dsl.spec.ts and 1 other location - About 2 hrs to fix
    src/__tests__/dsl.spec.ts on lines 86..91

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

    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("data fetching", () => {
        it("has dereference", () => expect(dereference(schema.name))
          .toHaveProperty("fetch", true));
        it("has hold", () => expect(hold(schema.name))
          .toHaveProperty("fetch", false));
    Severity: Major
    Found in src/__tests__/dsl.spec.ts and 1 other location - About 2 hrs to fix
    src/__tests__/dsl.spec.ts on lines 93..98

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

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

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

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

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

    Refactorings

    Further Reading

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

    export function loadingComponent(props: TypableProps & TypableInjectedProps, lrs: LinkReduxLRSType) {
        return (props.onLoad as any)
            || lrs.getComponentForType(ll.LoadingResource, props.topology || props.topologyCtx)
            || null;
    }
    Severity: Major
    Found in src/components/Typable.ts and 1 other location - About 1 hr to fix
    src/components/Typable.ts on lines 87..91

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

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

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

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

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

    Refactorings

    Further Reading

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

    export function errorComponent(props: TypableProps & TypableInjectedProps, lrs: LinkReduxLRSType) {
        return (props.onError as any)
            || lrs.getComponentForType(ll.ErrorResource, props.topology || props.topologyCtx)
            || null;
    }
    Severity: Major
    Found in src/components/Typable.ts and 1 other location - About 1 hr to fix
    src/components/Typable.ts on lines 93..97

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

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

    export function useManyLinkedObjectProperties<
      T extends DataToPropsMapping = {},
      D extends ReturnType = ReturnType.Term,
      OutVal = LinkedDataObject<T, D>,
    >(
    Severity: Minor
    Found in src/hooks/useManyLinkedObjectProperties.ts - About 1 hr to fix

      Function Property has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      export const Property: React.ComponentType<PropertyPropTypes & any> = (props): React.ReactElement<any> | null => {
          const lrs = useLRS();
          const childPropsOrFallback = useChildPropsOrFallback(props);
      
          if (childPropsOrFallback === null || !Array.isArray(childPropsOrFallback)) {
      Severity: Minor
      Found in src/components/Property.tsx - 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 6 locations. Consider refactoring.
      Open

      export const literal = <P extends PropParam>(predicate: P): MapWithReplacedReturnType<P, LiteralOpts> => ({
        ...mergedMap(predicate),
        returnType: ReturnType.Literal,
      });
      Severity: Major
      Found in src/dsl.ts and 5 other locations - About 1 hr to fix
      src/dsl.ts on lines 58..61
      src/dsl.ts on lines 70..73
      src/dsl.ts on lines 76..79
      src/dsl.ts on lines 82..85
      src/dsl.ts on lines 88..91

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

      export const value = <P extends PropParam>(predicate: P): MapWithReplacedReturnType<P, ValueOpts> => ({
        ...mergedMap(predicate),
        returnType: ReturnType.Value,
      });
      Severity: Major
      Found in src/dsl.ts and 5 other locations - About 1 hr to fix
      src/dsl.ts on lines 58..61
      src/dsl.ts on lines 64..67
      src/dsl.ts on lines 76..79
      src/dsl.ts on lines 82..85
      src/dsl.ts on lines 88..91

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

      export const terms = <P extends PropParam>(predicate: P): MapWithReplacedReturnType<P, AllTermsOpts> => ({
        ...mergedMap(predicate),
        returnType: ReturnType.AllTerms,
      });
      Severity: Major
      Found in src/dsl.ts and 5 other locations - About 1 hr to fix
      src/dsl.ts on lines 58..61
      src/dsl.ts on lines 64..67
      src/dsl.ts on lines 70..73
      src/dsl.ts on lines 82..85
      src/dsl.ts on lines 88..91

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

      export const statement = <P extends PropParam>(predicate: P): MapWithReplacedReturnType<P, StatementOpts> => ({
        ...mergedMap(predicate),
        returnType: ReturnType.Statement,
      });
      Severity: Major
      Found in src/dsl.ts and 5 other locations - About 1 hr to fix
      src/dsl.ts on lines 64..67
      src/dsl.ts on lines 70..73
      src/dsl.ts on lines 76..79
      src/dsl.ts on lines 82..85
      src/dsl.ts on lines 88..91

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

      export const literals = <P extends PropParam>(predicate: P): MapWithReplacedReturnType<P, AllLiteralsOpts> => ({
        ...mergedMap(predicate),
        returnType: ReturnType.AllLiterals,
      });
      Severity: Major
      Found in src/dsl.ts and 5 other locations - About 1 hr to fix
      src/dsl.ts on lines 58..61
      src/dsl.ts on lines 64..67
      src/dsl.ts on lines 70..73
      src/dsl.ts on lines 76..79
      src/dsl.ts on lines 82..85

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

      export const statements = <P extends PropParam>(predicate: P): MapWithReplacedReturnType<P, AllStatementsOpts> => ({
        ...mergedMap(predicate),
        returnType: ReturnType.AllStatements,
      });
      Severity: Major
      Found in src/dsl.ts and 5 other locations - About 1 hr to fix
      src/dsl.ts on lines 58..61
      src/dsl.ts on lines 64..67
      src/dsl.ts on lines 70..73
      src/dsl.ts on lines 76..79
      src/dsl.ts on lines 88..91

      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

      Function chargeLRS has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function chargeLRS(delta: Quadruple[] = [], subject: SomeNode): TestContext<React.ComponentType<any>> {
          const store = new RDFStore();
          const s = new Schema(store);
          const lrsOpts = {
            mapping: new ComponentStoreTestProxy<React.ComponentType>(s),
      Severity: Minor
      Found in src/__tests__/helpers/fixtures.ts - About 1 hr to fix

        Function buildPropSets has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        const buildPropSets = <D extends LinkOpts>(
          lrs: LinkReduxLRSType,
          dataSubjects: Array<Node | undefined>,
          requestedProperties: number[],
          opts: D,
        Severity: Minor
        Found in src/hooks/useResourceLinks.ts - 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

        Function useCalculateChildProps has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function useCalculateChildProps<P, R = any>(
            props: P & Partial<SubjectProp & TopologyProp & PassableRef<R>>,
            context: LinkRenderContext,
            options: WithLinkCtxOptions = {},
        ): CalculatedChildProps<P> {
        Severity: Minor
        Found in src/hooks/useCalculateChildProps.ts - About 1 hr to fix

          Function UpdateComp has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              const UpdateComp = () => {
                const props = useResourceLink(
                  opts.subject,
                  {
                    creation: schema.dateCreated,
          Severity: Minor
          Found in src/hooks/__tests__/useResourceLink.spec.tsx - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language