rescribet/link-lib

View on GitHub

Showing 153 of 153 total issues

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

        const quadDelta = [
            [ex("1"), ex("p"), ex("2"), ld.add],
            [ex("1"), ex("t"), rdfFactory.literal("Test"), ld.add],
            [ex("2"), ex("t"), rdfFactory.literal("Value"), ld.add],
        ] as Quadruple[];
Severity: Major
Found in src/__tests__/LinkedRenderStore/delta.spec.ts and 1 other location - About 2 hrs to fix
src/__tests__/LinkedRenderStore/delta.spec.ts on lines 88..92

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

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

    expect(store.getRecord("/")).toEqual({
      _id: rdf.namedNode("/"),
      [rdfx.type.value]: rdfs.Container,
      [rdfs.label.value]: rdf.literal("a"),
    });
Severity: Major
Found in src/messages/__tests__/messageProcessor.spec.ts and 4 other locations - About 2 hrs to fix
src/messages/__tests__/messageProcessor.spec.ts on lines 67..71
src/messages/__tests__/messageProcessor.spec.ts on lines 104..108
src/messages/__tests__/messageProcessor.spec.ts on lines 111..115
src/messages/__tests__/messageProcessor.spec.ts on lines 215..219

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

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

      expect(store.getRecord("/")).toEqual({
        _id: rdf.namedNode("/"),
        [rdfx.type.value]: rdfs.Resource,
        [rdfs.label.value]: rdf.literal("a"),
      });
Severity: Major
Found in src/messages/__tests__/messageProcessor.spec.ts and 4 other locations - About 2 hrs to fix
src/messages/__tests__/messageProcessor.spec.ts on lines 67..71
src/messages/__tests__/messageProcessor.spec.ts on lines 111..115
src/messages/__tests__/messageProcessor.spec.ts on lines 206..210
src/messages/__tests__/messageProcessor.spec.ts on lines 215..219

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

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

      expect(store.getRecord("/")).toEqual({
        _id: rdf.namedNode("/"),
        [rdfx.type.value]: rdfs.Container,
        [rdfs.label.value]: rdf.literal("a"),
      });
Severity: Major
Found in src/messages/__tests__/messageProcessor.spec.ts and 4 other locations - About 2 hrs to fix
src/messages/__tests__/messageProcessor.spec.ts on lines 104..108
src/messages/__tests__/messageProcessor.spec.ts on lines 111..115
src/messages/__tests__/messageProcessor.spec.ts on lines 206..210
src/messages/__tests__/messageProcessor.spec.ts on lines 215..219

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

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

      expect(store.getRecord("/")).toEqual({
        _id: rdf.namedNode("/"),
        [rdfx.type.value]: rdfs.Resource,
        [rdfs.label.value]: rdf.literal("b"),
      });
Severity: Major
Found in src/messages/__tests__/messageProcessor.spec.ts and 4 other locations - About 2 hrs to fix
src/messages/__tests__/messageProcessor.spec.ts on lines 67..71
src/messages/__tests__/messageProcessor.spec.ts on lines 104..108
src/messages/__tests__/messageProcessor.spec.ts on lines 206..210
src/messages/__tests__/messageProcessor.spec.ts on lines 215..219

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

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

    expect(store.getRecord("/c")).toEqual({
      _id: rdf.namedNode("/c"),
      [rdfx.type.value]: rdfs.Class,
      [rdfs.label.value]: rdf.literal("c"),
    });
Severity: Major
Found in src/messages/__tests__/messageProcessor.spec.ts and 4 other locations - About 2 hrs to fix
src/messages/__tests__/messageProcessor.spec.ts on lines 67..71
src/messages/__tests__/messageProcessor.spec.ts on lines 104..108
src/messages/__tests__/messageProcessor.spec.ts on lines 111..115
src/messages/__tests__/messageProcessor.spec.ts on lines 206..210

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

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

    private queue(idleCallback?: IdleDeadline | number): void {
        if (this.timeout !== 0 && this.hasIdleCallback) {
            while (typeof idleCallback === "object"
                && (!this.done() && (idleCallback.timeRemaining() > 0 || idleCallback.didTimeout))) {
                this.process();
Severity: Minor
Found in src/ProcessBroadcast.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 getEntity has 47 lines of code (exceeds 25 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 1 hr to fix

    Function deltaProcessor has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const deltaProcessor = (
        addGraphIRIS: NamedNode[],
        replaceGraphIRIS: NamedNode[],
        removeGraphIRIS: NamedNode[],
        purgeGraphIRIS: NamedNode[],
    Severity: Minor
    Found in src/store/deltaProcessor.ts - About 1 hr to fix

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

              it("rejects for server errors", async () => {
                  const store = getBasicStore();
      
                  const res = new Response(null, { status: INTERNAL_SERVER_ERROR });
                  expect(store.processor.processExternalResponse(res)).rejects.toBeTruthy();
      Severity: Major
      Found in src/processor/__tests__/DataProcessor.spec.ts and 2 other locations - About 1 hr to fix
      src/processor/__tests__/DataProcessor.spec.ts on lines 366..371
      src/processor/__tests__/DataProcessor.spec.ts on lines 373..378

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

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

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

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

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

      Refactorings

      Further Reading

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

              it("rejects for not-found responses", async () => {
                  const store = getBasicStore();
      
                  const res = new Response(null, { status: NOT_FOUND });
                  expect(store.processor.processExternalResponse(res)).rejects.toBeTruthy();
      Severity: Major
      Found in src/processor/__tests__/DataProcessor.spec.ts and 2 other locations - About 1 hr to fix
      src/processor/__tests__/DataProcessor.spec.ts on lines 373..378
      src/processor/__tests__/DataProcessor.spec.ts on lines 380..385

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

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

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

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

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

      Refactorings

      Further Reading

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

              it("rejects for client errors", async () => {
                  const store = getBasicStore();
      
                  const res = new Response(null, { status: BAD_REQUEST });
                  expect(store.processor.processExternalResponse(res)).rejects.toBeTruthy();
      Severity: Major
      Found in src/processor/__tests__/DataProcessor.spec.ts and 2 other locations - About 1 hr to fix
      src/processor/__tests__/DataProcessor.spec.ts on lines 366..371
      src/processor/__tests__/DataProcessor.spec.ts on lines 380..385

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

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

      const getSortedFieldMembers = (record: DataRecord): MultimapTerm => {
        const values: FieldValue = [];
        const sortedEntries = Object
            .entries(record)
            .sort(([k1], [k2]) => {
      Severity: Minor
      Found in src/store/StructuredStore.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

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

              it("handles null", () => {
                  const g = new RDFAdapter();
                  processObject(example.ns("a"), example.ns("property"), null, g);
                  expect(g.quads).toHaveLength(0);
              });
      Severity: Major
      Found in src/processor/__tests__/DataToGraph.spec.ts and 1 other location - About 1 hr to fix
      src/processor/__tests__/DataToGraph.spec.ts on lines 231..235

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

      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", () => {
                  const g = new RDFAdapter();
                  processObject(example.ns("a"), example.ns("property"), null, g);
                  expect(g.quads).toHaveLength(0);
              });
      Severity: Major
      Found in src/processor/__tests__/DataToGraph.spec.ts and 1 other location - About 1 hr to fix
      src/processor/__tests__/DataToGraph.spec.ts on lines 237..241

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

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

          public mineForTypes(lookupTypes: string[]): string[] {
              if (lookupTypes.length === 0) {
                  return [rdfs.Resource.value];
              }
      
      
      Severity: Minor
      Found in src/Schema.ts - About 1 hr to fix

        Function processDelta has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public processDelta(delta: Array<Quadruple|void>): Quadruple[] {
                for (const s of delta) {
                    const subj = s ? s[0] : undefined;
        
                    if (!s || !equals(s[QuadPosition.graph], ll.meta)) {
        Severity: Minor
        Found in src/processor/DataProcessor.ts - About 1 hr to fix

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

          export function linkedDeltaProcessor(lrs: LinkedRenderStore<any>): ResponseTransformer {
              return async function processLinkedDelta(response: ResponseAndFallbacks): Promise<Quadruple[]> {
                  let data: string;
                  if (response instanceof Response) {
                      data = response.bodyUsed ? "" : await response.text();
          Severity: Minor
          Found in src/transformers/linked-delta.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 processObject has a Cognitive Complexity of 13 (exceeds 5 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 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 getEntities has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public getEntities(resources: ResourceQueueItem[]): Promise<Quadruple[]> {
                  const reload: NamedNode[] = [];
          
                  const toBeFetched = new Set<NamedNode>();
          
          
          Severity: Minor
          Found in src/processor/DataProcessor.ts - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language