rescribet/link-lib

View on GitHub

Showing 137 of 137 total issues

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

    public fetchResource(iri: string): Promise<object> {
        return sendMessage(
            this.worker,
            {
                method: FETCH_RESOURCE,
Severity: Minor
Found in src/worker/DataWorkerLoader.ts and 1 other location - About 50 mins to fix
src/worker/DataWorkerLoader.ts on lines 45..55

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 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 144..148

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("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 137..141

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

Avoid deeply nested control flow statements.
Open

                        if (value === recordId) {
                            references.push(rId);
                        }
Severity: Major
Found in src/store/RDFIndex.ts - About 45 mins to fix

    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 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 (let i = 0; i < fields.length; i++) {
                const field = fields[i];
    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 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

    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

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

        this.store.deleteFieldMatching(
          quad[QuadPosition.subject].value,
          quad[QuadPosition.predicate].value,
          quad[QuadPosition.object],
        );
    Severity: Minor
    Found in src/store/RDFAdapter.ts and 1 other location - About 40 mins to fix
    src/store/RDFAdapter.ts on lines 92..96

    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

        this.store.deleteFieldMatching(
            st[QuadPosition.subject].value,
            st[QuadPosition.predicate].value,
            st[QuadPosition.object],
        );
    Severity: Minor
    Found in src/store/RDFAdapter.ts and 1 other location - About 40 mins to fix
    src/store/RDFAdapter.ts on lines 106..110

    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: RDFIndex,
                                  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 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 withAlias has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          public withAlias(previous: Id, current: Id): StructuredStore {
            if (previous === current
              || this.aliases[previous] === current
              || this.aliases[current] === previous) {
              return this;
        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

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

          public addField(recordId: Id, field: FieldId, value: SomeTerm): boolean {
            if (field === idField) {
              throw new Error("Can't set system fields");
            }
            this.initializeRecord(recordId);
        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

        Severity
        Category
        Status
        Source
        Language