OpenHPS/openhps-core

View on GitHub

Showing 86 of 242 total issues

Function nls has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

    protected nls(spheres: Array<Sphere<any>>): AbsolutePosition {
        // Initiailize parameters
        const f = (point: number[]) => this._calculateError(point, spheres);
        const x0 = this._calculateInit(spheres);
        const maxIterations = this.options.maxIterations;
Severity: Minor
Found in src/nodes/processing/MultilaterationNode.ts - About 7 hrs 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

File Deserializer.ts has 454 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Deserializer as JSONDeserializer } from 'typedjson/lib/cjs/deserializer';
import type { TypeDescriptor } from 'typedjson/lib/types/type-descriptor';
import {
    ensureTypeDescriptor,
    ConcreteTypeDescriptor,
Severity: Minor
Found in src/data/Deserializer.ts - About 6 hrs to fix

    Function convertAsObject has 118 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        convertAsObject<T>(
            sourceObject: IndexedObject,
            typeDescriptor: ConcreteTypeDescriptor,
            knownTypes: Map<string, Serializable<any>>,
            memberName: string,
    Severity: Major
    Found in src/data/Deserializer.ts - About 4 hrs to fix

      Function nls has 102 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected nls(spheres: Array<Sphere<any>>): AbsolutePosition {
              // Initiailize parameters
              const f = (point: number[]) => this._calculateError(point, spheres);
              const x0 = this._calculateInit(spheres);
              const maxIterations = this.options.maxIterations;
      Severity: Major
      Found in src/nodes/processing/MultilaterationNode.ts - About 4 hrs to fix

        Function convertAsObject has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

            convertAsObject<T>(
                sourceObject: IndexedObject,
                typeDescriptor: ConcreteTypeDescriptor,
                knownTypes: Map<string, Serializable<any>>,
                memberName: string,
        Severity: Minor
        Found in src/data/Deserializer.ts - About 3 hrs 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

        File MultilaterationNode.ts has 322 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { AbsolutePosition, Accuracy1D, DataObject, GeographicalPosition, RelativeDistance } from '../../data';
        import { DataFrame } from '../../data/DataFrame';
        import { AngleUnit } from '../../utils';
        import { Vector3 } from '../../utils/math';
        import { ObjectProcessingNodeOptions } from '../ObjectProcessingNode';
        Severity: Minor
        Found in src/nodes/processing/MultilaterationNode.ts - About 3 hrs to fix

          File Serializer.ts has 315 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { Serializer as JSONSerializer } from 'typedjson/lib/cjs/serializer';
          import type { ConcreteTypeDescriptor, TypeDescriptor } from 'typedjson/lib/types/type-descriptor';
          import {
              ensureTypeDescriptor,
              ArrayTypeDescriptor,
          Severity: Minor
          Found in src/data/Serializer.ts - About 3 hrs to fix

            Function convertAsMap has 87 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                convertAsMap(
                    sourceObject: any,
                    typeDescriptor: MapTypeDescriptor,
                    knownTypes: Map<string, Serializable<any>>,
                    memberName: string,
            Severity: Major
            Found in src/data/Deserializer.ts - About 3 hrs to fix

              Function processRelativePositions has 77 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  processRelativePositions<P extends AbsolutePosition>(
                      dataObject: DataObject,
                      relativePositions: Map<RelativeDistance, DataObject>,
                      dataFrame: DataFrame,
                  ): Promise<DataObject> {
              Severity: Major
              Found in src/nodes/processing/MultilaterationNode.ts - About 3 hrs to fix

                Function init has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    init(config: WorkerData): Promise<void> {
                        return new Promise(async (resolve, reject) => {
                            this.config = config;
                            const importFn: (file: string) => Promise<any> =
                                typeof process !== 'object'
                Severity: Major
                Found in src/worker/WorkerBase.ts - About 3 hrs to fix

                  File WorkerHandler.ts has 277 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import { BlobWorker, Pool, spawn, Thread, Worker } from 'threads';
                  import { PoolEvent } from 'threads/dist/master/pool';
                  import { Observable } from 'threads/observable';
                  import { DataFrame } from '../data/DataFrame';
                  import { DataSerializer } from '../data/DataSerializer';
                  Severity: Minor
                  Found in src/worker/WorkerHandler.ts - About 2 hrs to fix

                    Function convertAsObject has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        convertAsObject(
                            sourceObject: IndexedObject,
                            typeDescriptor: ConcreteTypeDescriptor,
                            memberName: string,
                            serializer: Serializer,
                    Severity: Major
                    Found in src/data/Serializer.ts - About 2 hrs to fix

                      File Unit.ts has 271 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import 'reflect-metadata';
                      import { SerializableObject, SerializableMember } from '../../data/decorators';
                      import { UnitOptions } from './UnitOptions';
                      import { UnitBasicDefinition, UnitDefinition, UnitFunctionDefinition, UnitValueType } from './UnitDefinition';
                      import { UnitPrefix, UnitPrefixType } from './UnitPrefix';
                      Severity: Minor
                      Found in src/utils/unit/Unit.ts - About 2 hrs to fix

                        Function updateSerializableMember has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export function updateSerializableMember(
                            target: unknown,
                            propertyKey: string,
                            options: SerializableMemberOptions | IndexedObject,
                        ) {
                        Severity: Minor
                        Found in src/data/decorators/utils.ts - About 2 hrs 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

                        ReferenceSpace has 21 functions (exceeds 20 allowed). Consider refactoring.
                        Open

                        @SerializableObject()
                        export class ReferenceSpace extends DataObject implements TransformationSpace {
                            @SerializableMember({
                                name: 'translationMatrix',
                            })
                        Severity: Minor
                        Found in src/data/object/space/ReferenceSpace.ts - About 2 hrs to fix

                          Function _spawnWorker has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private _spawnWorker(): Promise<Thread> {
                                  return new Promise((resolve, reject) => {
                                      const worker = this.createWorker();
                                      spawn(worker, {
                                          timeout: this.options.timeout,
                          Severity: Minor
                          Found in src/worker/WorkerHandler.ts - About 1 hr to fix

                            Function findByName has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                            Open

                                static findByName(name: string, baseName?: string): Unit | undefined {
                                    if (name === undefined) {
                                        return undefined;
                                    } else if (Unit.UNITS.has(name)) {
                                        return Unit.UNITS.get(name);
                            Severity: Minor
                            Found in src/utils/unit/Unit.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 getCurrentPosition has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                getCurrentPosition(object: T | string, options: GeoOptions = {}): Promise<P> {
                                    return new Promise((resolve, reject) => {
                                        const maximumAge = options.maximumAge || Infinity;
                                        options.timeout = options.timeout || 10000;
                                        const uid = object instanceof DataObject ? object.uid : object;
                            Severity: Minor
                            Found in src/service/LocationBasedService.ts - About 1 hr to fix

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

                              export function updateSerializableMember(
                                  target: unknown,
                                  propertyKey: string,
                                  options: SerializableMemberOptions | IndexedObject,
                              ) {
                              Severity: Minor
                              Found in src/data/decorators/utils.ts - About 1 hr to fix

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

                                    convertAsMap(
                                        sourceObject: Map<any, any>,
                                        typeDescriptor: MapTypeDescriptor,
                                        memberName: string,
                                        serializer: Serializer,
                                Severity: Minor
                                Found in src/data/Serializer.ts - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language