rescribet/link-lib

View on GitHub

Showing 153 of 153 total issues

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

            it("replaces existing", () => {
                const store = new RDFStore();

                expect(store.processDelta(new Array(1))).toEqual([]);
            });
Severity: Minor
Found in src/__tests__/RDFStore.spec.ts and 1 other location - About 50 mins to fix
src/__tests__/RDFStore.spec.ts on lines 119..123

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

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

    store.setRecord("/b", {
      [rdfx.type.value]: rdfs.Resource,
      [rdfs.label.value]: rdf.literal("b"),
    });
Severity: Major
Found in src/messages/__tests__/messageProcessor.spec.ts and 3 other locations - About 50 mins to fix
src/messages/__tests__/messageProcessor.spec.ts on lines 188..191
src/messages/__tests__/messageProcessor.spec.ts on lines 236..239
src/messages/__tests__/messageProcessor.spec.ts on lines 240..243

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

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 empty values", () => {
            const store = new RDFStore();

            expect(store.processDelta(new Array(1))).toEqual([]);
        });
Severity: Minor
Found in src/__tests__/RDFStore.spec.ts and 1 other location - About 50 mins to fix
src/__tests__/RDFStore.spec.ts on lines 126..130

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

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

    store.setRecord("/", {
      [rdfx.type.value]: rdfs.Container,
      [rdfs.label.value]: rdf.literal("a"),
    });
Severity: Major
Found in src/messages/__tests__/messageProcessor.spec.ts and 3 other locations - About 50 mins to fix
src/messages/__tests__/messageProcessor.spec.ts on lines 192..195
src/messages/__tests__/messageProcessor.spec.ts on lines 236..239
src/messages/__tests__/messageProcessor.spec.ts on lines 240..243

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

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

export const linkMiddleware = <T, API extends LinkedDataAPI = DataProcessor>(catchActions = true):
  MiddlewareFn<T, API> => (lrs: LinkedRenderStore<T, API>): MiddlewareWithBoundLRS =>
        (next: MiddlewareActionHandler): MiddlewareActionHandler =>
            (action: SomeNode, args: any): Promise<any> => {

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

Function createProcessRDF has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const createProcessRDF = (rdfParse: RDFLibParse): (response: ResponseAndFallbacks) => Promise<Quadruple[]> => {
    return async function processRDF(response: ResponseAndFallbacks): Promise<Quadruple[]> {
        let data: string;
        if (isRdfLibResponse(response)) {
            data = response.responseText;
Severity: Minor
Found in src/transformers/rdf-formats-common.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

Function getContentType has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export function getContentType(res: ResponseAndFallbacks): string {
    const contentTypeRaw = getHeader(res, "Content-Type");
    if (contentTypeRaw === undefined || contentTypeRaw === null) {
        return "";
    }
Severity: Minor
Found in src/utilities/responses.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

Function registeredClasses has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private registeredClasses(fields: Id[], topology: Id): Id[] {
        const classes = [rdfs.Resource.value];

        for (const field of fields) {
            if (typeof this.registrations[field] === "undefined") {
Severity: Minor
Found in src/ComponentStore/ComponentStore.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

Function allValues has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public allValues(value: T): T[] {
        const node = this.nodes.get(value);
        if (!node) {
            return [value];
        }
Severity: Minor
Found in src/utilities/DisjointSet.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

        it("returns empty data for empty property", () => {
            const res = store.lrs.getResourceProperties(schemaT, undefined);
            expect(res).toEqual([]);
        });
Severity: Minor
Found in src/__tests__/LinkedRenderStore/data.spec.ts and 1 other location - About 40 mins to fix
src/__tests__/LinkedRenderStore/data.spec.ts on lines 80..83

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

        it("returns empty data for empty property", () => {
            const res = store.lrs.getResourcePropertyRaw(schemaT, undefined);
            expect(res).toEqual([]);
        });
Severity: Minor
Found in src/__tests__/LinkedRenderStore/data.spec.ts and 1 other location - About 40 mins to fix
src/__tests__/LinkedRenderStore/data.spec.ts on lines 40..43

Duplicated Code

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

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

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

Tuning

This issue has a mass of 49.

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

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

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

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

Refactorings

Further Reading

Function processObject has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

export function processObject(subject: Node,
                              predicate: NamedNode,
                              datum: DataObject | SerializableDataTypes | null | undefined,
                              store: RDFAdapter,
                              ns?: NamespaceMap): NamedBlobTuple[] {
Severity: Minor
Found in src/processor/DataToGraph.ts - About 35 mins to fix

    Function checkRegistration has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

                r: ComponentRegistration<T>,
                c: T,
                t: SomeNode,
                p: NamedNode,
                top: SomeNode,
    Severity: Minor
    Found in src/__tests__/LinkedRenderStore/components.spec.ts - About 35 mins to fix

      Function processResourceQueue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          private async processResourceQueue(): Promise<void> {
              this.resourceQueueHandle = undefined;
              const queue = this.resourceQueue;
              this.resourceQueue = [];
      
      
      Severity: Minor
      Found in src/LinkedRenderStore.ts - About 35 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

      Function registerRenderer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public static registerRenderer<T>(
              component: T,
              types: Id[],
              fields: Id[],
              topologies: Id[],
      Severity: Minor
      Found in src/ComponentStore/ComponentStore.ts - About 35 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

      Function getEntity has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public async getEntity(iri: NamedNode, opts?: APIFetchOpts): Promise<Quadruple[]> {
              const url = new URL(iri.value);
              url.hash = "";
              const requestIRI = rdfFactory.namedNode(url.toString());
              const existing = this.requestMap.get(requestIRI.id);
      Severity: Minor
      Found in src/processor/DataProcessor.ts - About 35 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

      Function digDeeper has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public digDeeper(subject: Node | undefined, path: Array<NamedNode | NamedNode[]>): [Quadruple[], SomeNode[]] {
              if (path.length === 0 || typeof subject === "undefined") {
                  return [[], []];
              }
      
      
      Severity: Minor
      Found in src/LinkedRenderStore.ts - About 35 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

      Function findSubject has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public findSubject(subject: Node | undefined, path: NamedNode[], match: Term | Term[]): Node[] {
              if (path.length === 0 || typeof subject === "undefined") {
                  return [];
              }
      
      
      Severity: Minor
      Found in src/LinkedRenderStore.ts - About 35 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

      Function deleteFieldMatching has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        public deleteFieldMatching(recordId: Id, field: FieldId, value: SomeTerm): void {
          const current = this.getField(recordId, field);
          if (current === undefined) {
            return;
          }
      Severity: Minor
      Found in src/store/StructuredStore.ts - About 35 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

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

                  const quads = normalizeType(this.store.store.getField(subject.value, prop.value))
                    .filter((v) => v !== undefined);
      Severity: Minor
      Found in src/RDFStore.ts and 1 other location - About 35 mins to fix
      src/RDFStore.ts on lines 203..204

      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

      Severity
      Category
      Status
      Source
      Language