rescribet/link-redux

View on GitHub

Showing 111 of 111 total issues

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

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 memoizedResources = useMemoizedDataSubjects(resources);
          const lrs = useLRS();
      
      
      Severity: Minor
      Found in src/hooks/useDataInvalidation.ts - About 1 hr to fix

        Function useChildPropsOrFallback has a Cognitive Complexity of 11 (exceeds 5 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

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

        Function useTempRecords has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const useTempRecords = <T>(
          items: T[],
          fields: FieldSet | ItemFieldBuilder<T>,
          deps: unknown[],
          givenIds?: SomeNode[],
        Severity: Minor
        Found in src/hooks/useTempRecords.ts - About 1 hr to fix

          Function exceptResolver has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            (s: Identifier | undefined) => {
            if (s === undefined) {
              return NESTED_EMPTY_ARRAY;
            }
          
          
          Severity: Minor
          Found in src/hooks/makeParsedField/Query.ts - About 1 hr to fix

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

                describe("errorComponent", () => {
                    it("returns null without onError and registered resource", () => {
                        expect(errorComponent(props, ctx.empty().lrs)).toBeNull();
                    });
                });
            Severity: Major
            Found in src/components/__tests__/Typable.spec.ts and 1 other location - About 1 hr to fix
            src/components/__tests__/Typable.spec.ts on lines 72..76

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

            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("loadingComponent", () => {
                    it("returns null without onError and registered resource", () => {
                        expect(loadingComponent(props, ctx.empty().lrs)).toBeNull();
                    });
                });
            Severity: Major
            Found in src/components/__tests__/Typable.spec.ts and 1 other location - About 1 hr to fix
            src/components/__tests__/Typable.spec.ts on lines 66..70

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

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

            export function useResourceLinks<
              T extends MapDataToPropsParam = {},
              D extends LinkOpts = TermOpts,
            >(
              subjects: LaxNode | Node[],
            Severity: Minor
            Found in src/hooks/useResourceLinks.ts - About 1 hr to fix

              Function normalizeDataSubjects has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

              export function normalizeDataSubjects(props: Partial<DataInvalidationProps>): SubjectType[] {
                  if (!(props.subject || props.dataSubjects)) {
                      return NO_SUBJECTS;
                  }
              
              
              Severity: Minor
              Found in src/hooks/useDataInvalidation.ts - About 55 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

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

                if (!isLiteral(it) || !(equals(it.datatype, xsd.dateTime) || equals(it.datatype, xsd.date))) {
                  return undefined;
                }
              Severity: Major
              Found in src/hooks/useParsedField.ts and 2 other locations - About 50 mins to fix
              src/hooks/useParsedField.ts on lines 194..196
              src/hooks/useParsedField.ts on lines 235..237

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

              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

                if (!isLiteral(it) || !(equals(it.datatype, rdfx.langString) || equals(it.datatype, xsd.string))) {
                  return undefined;
                }
              Severity: Major
              Found in src/hooks/useParsedField.ts and 2 other locations - About 50 mins to fix
              src/hooks/useParsedField.ts on lines 179..181
              src/hooks/useParsedField.ts on lines 194..196

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

              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

                if (!isLiteral(it) || !(equals(it.datatype, rdfx.langString) || equals(it.datatype, xsd.string))) {
                  return undefined;
                }
              Severity: Major
              Found in src/hooks/useParsedField.ts and 2 other locations - About 50 mins to fix
              src/hooks/useParsedField.ts on lines 179..181
              src/hooks/useParsedField.ts on lines 235..237

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

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

              export function useRenderLoadingOrError(
                props: TypableProps & TypableInjectedProps,
                error?: Error,
              ): React.ReactElement<any> | null | undefined {
                  const lrs = useLRS();
              Severity: Minor
              Found in src/hooks/useLoadingOrError.ts - About 45 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

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

                          React.createElement(
                              Resource,
                              { loadLinkedObject, subject: iri },
                              React.createElement(
                                  Resource,
              Severity: Minor
              Found in src/components/__tests__/Resource.spec.ts and 1 other location - About 45 mins to fix
              src/components/__tests__/Resource.spec.ts on lines 152..159

              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

                          React.createElement
                          (Resource,
                              { loadLinkedObject, subject: iri },
                              React.createElement(
                                  Resource,
              Severity: Minor
              Found in src/components/__tests__/Resource.spec.ts and 1 other location - About 45 mins to fix
              src/components/__tests__/Resource.spec.ts on lines 131..138

              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

              export const except = (...fields: NamedNode[]): ExceptQuery => ({
                fields,
                type: QueryType.Except,
              });
              Severity: Minor
              Found in src/hooks/useParsedField.ts and 1 other location - About 40 mins to fix
              src/hooks/useParsedField.ts on lines 49..52

              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

              export const array = (...fields: NamedNode[]): ArrayQuery => ({
                fields,
                type: QueryType.Array,
              });
              Severity: Minor
              Found in src/hooks/useParsedField.ts and 1 other location - About 40 mins to fix
              src/hooks/useParsedField.ts on lines 31..34

              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

              Severity
              Category
              Status
              Source
              Language