rescribet/link-redux

View on GitHub

Showing 104 of 104 total issues

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

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

      return (
        <div>
          <p id="id0">{props.subject?.value}</p>
          <p id="id1">{Object.keys(props).length}</p>
        </div>
Severity: Major
Found in src/hooks/__tests__/useResourceLinks.spec.tsx and 3 other locations - About 1 hr to fix
src/hooks/__tests__/useResourceLink.spec.tsx on lines 92..97
src/hooks/__tests__/useResourceLink.spec.tsx on lines 120..125
src/hooks/__tests__/useResourceLinks.spec.tsx on lines 33..38

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

  it("handles undefined values", () => {
    expect(queryChanged(undefined, undefined)).toBeFalsy();
    expect(queryChanged(undefined, [])).toBeTruthy();
    expect(queryChanged([], undefined)).toBeTruthy();
  });
src/hooks/makeParsedField/useTargetedQuery/__tests__/targetsChanged.spec.ts on lines 20..24

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

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

  it("handles undefined values", () => {
    expect(targetsChanged(undefined, undefined)).toBeFalsy();
    expect(targetsChanged(undefined, [])).toBeTruthy();
    expect(targetsChanged([], undefined)).toBeTruthy();
  });
src/hooks/makeParsedField/useTargetedQuery/__tests__/queryChanged.spec.ts on lines 13..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 72.

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

  if (Array.isArray(previous) && Array.isArray(next)) {
    return previous.length !== next.length
      || previous.some((p, i) => !equals(p, next[i]));
  }
Severity: Major
Found in src/hooks/makeParsedField/useTargetedQuery/queryChanged.ts and 1 other location - About 1 hr to fix
src/hooks/makeParsedField/useTargetedQuery/targetsChanged.ts on lines 16..19

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

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

  if (Array.isArray(previous) && Array.isArray(next)) {
    return previous.length !== next.length
      || previous.some((p, i) => !equals(p, next[i]));
  }
src/hooks/makeParsedField/useTargetedQuery/queryChanged.ts 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 70.

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

export function useChildPropsOrFallback<P extends PropertyPropTypes>(props: P):
  null | React.ReactElement | [CalculatedChildProps<P>, SomeTerm[]] {

  const options = { topology: true };

Severity: Minor
Found in src/components/Property/useChildPropsOrFallback.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

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

    const arrayResolver: Resolver<ArrayQuery> = (lrs: LinkReduxLRSType, query: ArrayQuery) =>
      (target: Identifier | undefined) => {
        if (target === undefined) {
          return NESTED_EMPTY_ARRAY;
        }
    Severity: Minor
    Found in src/hooks/makeParsedField/Query.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 queryChanged has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const queryChanged = (previous: Query, next: Query) => {
      if (previous === next) {
        return false;
      }
    
    
    Severity: Minor
    Found in src/hooks/makeParsedField/useTargetedQuery/queryChanged.ts - About 1 hr to fix

      Similar blocks of code found in 4 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 3 other locations - About 1 hr to fix
      src/dsl.ts on lines 56..59
      src/dsl.ts on lines 68..71
      src/dsl.ts on lines 74..77

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 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 4 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 3 other locations - About 1 hr to fix
      src/dsl.ts on lines 56..59
      src/dsl.ts on lines 62..65
      src/dsl.ts on lines 74..77

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 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 4 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 3 other locations - About 1 hr to fix
      src/dsl.ts on lines 56..59
      src/dsl.ts on lines 62..65
      src/dsl.ts on lines 68..71

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

      export const useLiterals = makeParsedField<Literal>(
        (_) => (it) => isLiteral(it[QuadPosition.object])
          ? it[QuadPosition.object] as Literal
          : undefined,
      );
      Severity: Major
      Found in src/hooks/useParsedField.ts and 1 other location - About 1 hr to fix
      src/hooks/useParsedField.ts on lines 75..79

      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 4 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 3 other locations - About 1 hr to fix
      src/dsl.ts on lines 62..65
      src/dsl.ts on lines 68..71
      src/dsl.ts on lines 74..77

      Duplicated Code

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

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

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

      Tuning

      This issue has a mass of 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 2 locations. Consider refactoring.
      Open

      export const useIds = makeParsedField<Node>(
        (_) => (it) => isNode(it[QuadPosition.object])
          ? it[QuadPosition.object] as Node
          : undefined,
      );
      Severity: Major
      Found in src/hooks/useParsedField.ts and 1 other location - About 1 hr to fix
      src/hooks/useParsedField.ts on lines 110..114

      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 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: UseCalculateChildPropsOptions = {},
      ): 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

          Function useDataInvalidation has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function useDataInvalidation(subjects: LaxIdentifier | LaxIdentifier[]): number {
              const resources = normalizeType(subjects!).filter<Node>(Boolean as any).map((n) => n.value);
              const memoisedResources = useMemoizedDataSubjects(resources);
              const lrs = useLRS();
          
          
          Severity: Minor
          Found in src/hooks/useDataInvalidation.ts - About 1 hr to fix

            Function useCalculateChildProps has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            export function useCalculateChildProps<P, R = any>(
                props: P & Partial<SubjectProp & TopologyProp & PassableRef<R>>,
                context: LinkRenderContext,
                options: UseCalculateChildPropsOptions = {},
            ): CalculatedChildProps<P> {
            Severity: Minor
            Found in src/hooks/useCalculateChildProps.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

            Severity
            Category
            Status
            Source
            Language