OpenHPS/openhps-core

View on GitHub

Showing 87 of 247 total issues

Function loadClasses has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected static loadClasses(module: NodeModule = require.main): void {
        if (module === undefined) {
            // Use cache instead
            Object.values(require.cache).map((m) => this.loadClasses(m));
            return;
Severity: Minor
Found in src/ModelSerializer.ts - About 1 hr to fix

    Function createMetadata has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        static createMetadata(proto: IndexedObject): ObjectMetadata {
            if (Object.prototype.hasOwnProperty.call(proto, this.META_FIELD)) {
                return proto[this.META_FIELD];
            }
            // Target has no JsonObjectMetadata associated with it yet, create it now.
    Severity: Minor
    Found in src/data/DataSerializerUtils.ts - About 1 hr to fix

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

          static getValueFromPath<T>(object: T, path: string): [any, any, string] {
              // https://stackoverflow.com/questions/6491463/accessing-nested-javascript-objects-and-arays-by-string-path
              let o: any = object;
              path = path.replace(/\[(\w+)\]/g, '.$1'); // convert indexes to properties
              path = path.replace(/^\./, ''); // strip a leading dot
      Severity: Minor
      Found in src/service/MemoryQueryEvaluator.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 evaluateComponent has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          static evaluateComponent<T>(object: T, key: string, query: any): boolean {
              let result = true;
              const value = (object as any)[key];
              if (key.startsWith('$')) {
                  result = result && MemoryQueryEvaluator.evaluateOp(key, object, query);
      Severity: Minor
      Found in src/service/MemoryQueryEvaluator.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

      Avoid deeply nested control flow statements.
      Open

                          if (sigma >= 1) break;
      Severity: Major
      Found in src/nodes/processing/MultilaterationNode.ts - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if (contracted.fx < worst.fx) {
                                updateSimplex(contracted);
                            } else {
                                shouldReduce = true;
                            }
        Severity: Major
        Found in src/nodes/processing/MultilaterationNode.ts - About 45 mins to fix

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

              convert<T extends UnitValueType>(value: T, target: string | Unit): T {
                  const targetUnit: Unit = target instanceof Unit ? target : Unit.findByName(target, this.baseName);
          
                  // Do not convert if target unit is the same or undefined
                  if (!targetUnit || targetUnit.name === this.name) {
          Severity: Minor
          Found in src/utils/unit/Unit.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 registerUnit has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              static registerUnit(unit: Unit, override: boolean = false): Unit {
                  if (!unit.name) {
                      return unit;
                  }
          
          
          Severity: Minor
          Found in src/utils/unit/Unit.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 constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              constructor(worker: ((...args: any[]) => void) | string | Node<In, Out>, options?: WorkerNodeOptions) {
                  super(options);
                  this.options.worker = this.options.worker || '../worker/WorkerRunner';
                  this.options.type = this.options.type || 'classic';
                  if (worker instanceof GraphBuilder) {
          Severity: Minor
          Found in src/nodes/WorkerNode.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 convertAsMap has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              convertAsMap(
                  sourceObject: any,
                  typeDescriptor: MapTypeDescriptor,
                  knownTypes: Map<string, Serializable<any>>,
                  memberName: string,
          Severity: Minor
          Found in src/data/Deserializer.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 (contracted.fx < reflected.fx) {
                                  updateSimplex(contracted);
                              } else {
                                  shouldReduce = true;
                              }
          Severity: Major
          Found in src/nodes/processing/MultilaterationNode.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                for (let i = 1; i < simplex.length; ++i) {
                                    weightedSum(simplex[i], 1 - sigma, simplex[0], sigma, simplex[i]);
                                    simplex[i].fx = f(simplex[i]);
                                }
            Severity: Major
            Found in src/nodes/processing/MultilaterationNode.ts - About 45 mins to fix

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

                  public transform<In extends AbsolutePosition, Out extends AbsolutePosition = In>(
                      position: In,
                      options?: SpaceTransformationOptions,
                  ): Out {
                      const config = options || {};
              Severity: Minor
              Found in src/data/object/space/ReferenceSpace.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

              Consider simplifying this complex logical expression.
              Open

                  if (options) {
                      const ownMeta = JsonObjectMetadata.ensurePresentInPrototype(target);
                      const rootMeta = DataSerializerUtils.getRootMetadata(target.constructor);
                      const ownMemberMetadata = ownMeta.dataMembers.get(propertyKey) || ownMeta.dataMembers.get(options.name);
                      const rootMemberMetadata = rootMeta
              Severity: Major
              Found in src/data/decorators/utils.ts - About 40 mins to fix

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

                        function weightedSum(ret, w1, v1, w2, v2) {
                Severity: Minor
                Found in src/nodes/processing/MultilaterationNode.ts - About 35 mins to fix

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

                      toString(byteLength?: number, padding: boolean = true): string {
                          byteLength = byteLength ?? this._raw.byteLength;
                          const bytes = [];
                          for (const [, value] of this._raw.entries()) {
                              bytes.push(value);
                  Severity: Minor
                  Found in src/data/UUID.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 fromAxisAngle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      static fromAxisAngle<T extends typeof Quaternion>(this: T, axis: any): InstanceType<T> {
                          const quaternion = new this();
                          if (axis instanceof AxisAngle) {
                              quaternion.setFromAxisAngle(new Vector3(axis.x, axis.y, axis.z), axis.angle);
                          } else if (axis instanceof Array) {
                  Severity: Minor
                  Found in src/utils/math/Quaternion.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 _convertSingleValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private _convertSingleValue(
                          sourceObject: any,
                          typeDescriptor: TypeDescriptor,
                          memberName?: string,
                          memberOptions?: ObjectMemberMetadata,
                  Severity: Minor
                  Found in src/data/Serializer.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

                  Avoid too many return statements within this function.
                  Open

                              return this.convertAsObject(
                                  sourceObject,
                                  typeDescriptor,
                                  memberName,
                                  this,
                  Severity: Major
                  Found in src/data/Serializer.ts - About 30 mins to fix

                    Function createWorker has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected createWorker(): Worker {
                            if (this.options.blob) {
                                const worker = new BlobWorker(this.options.worker as any, {
                                    type: this.options.type === 'typescript' ? 'classic' : this.options.type,
                                });
                    Severity: Minor
                    Found in src/worker/WorkerHandler.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

                    Severity
                    Category
                    Status
                    Source
                    Language