rescribet/link-lib

View on GitHub
src/store/StructuredStore.ts

Summary

Maintainability
B
6 hrs
Test Coverage

File StructuredStore.ts has 263 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import rdfFactory, { SomeTerm } from "@ontologies/core";
import * as rdf from "@ontologies/rdf";
import * as rdfs from "@ontologies/rdfs";

import { SomeNode } from "../types";
Severity: Minor
Found in src/store/StructuredStore.ts - About 2 hrs to fix

    Function withAlias has 26 lines of code (exceeds 25 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 1 hr to fix

      Function getSortedFieldMembers has a Cognitive Complexity of 9 (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 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

      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

      Function deleteFieldMatching has a Cognitive Complexity of 6 (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 25 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 collectRecord has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        public collectRecord(recordId: Id, collected: Id[] = []): DeepRecord | undefined {
          const record = this.getRecord(recordId);
      
          if (!record) { return undefined; }
      
      
      Severity: Minor
      Found in src/store/StructuredStore.ts - About 25 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

      There are no issues that match your filters.

      Category
      Status