OpenHPS/openhps-core

View on GitHub

Showing 87 of 247 total issues

Function updateSerializableObject has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function updateSerializableObject<T>(target: Serializable<T>, options: SerializableObjectOptions<T>): void {
    const ownMeta = DataSerializerUtils.getMetadata(target);
    const rootMeta = DataSerializerUtils.getRootMetadata(target.prototype);
    rootMeta.knownTypes.add(target);
    if (rootMeta.initializerCallback && !ownMeta.initializerCallback) {
Severity: Minor
Found in src/data/decorators/utils.ts - About 1 hr to fix

    Function callService has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        callService(call: WorkerServiceCall): Promise<WorkerServiceResponse> {
            return new Promise((resolve, reject) => {
                const service: Service =
                    this.model.findDataService(call.serviceUID) || this.model.findService(call.serviceUID);
                if ((service as any)[call.method]) {
    Severity: Minor
    Found in src/worker/WorkerBase.ts - About 1 hr to fix

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

          public processRelativePositions<P extends Absolute2DPosition | Absolute3DPosition | GeographicalPosition>(
              dataObject: DataObject,
              relativePositions: Map<RelativeAngle, DataObject>,
              dataFrame: DataFrame,
          ): Promise<DataObject> {
      Severity: Minor
      Found in src/nodes/processing/TriangulationNode.ts - About 1 hr to fix

        Function constructor has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            constructor(
                x?: number,
                y?: number,
                z?: number,
                unit?: Unit,
        Severity: Minor
        Found in src/data/values/SensorValue.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 swap has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            swap(subunits: Unit[], options?: UnitOptions): DerivedUnit {
                if (Unit.UNITS.has(options.name)) {
                    return Unit.UNITS.get(options.name) as this;
                }
        
        
        Severity: Minor
        Found in src/utils/unit/DerivedUnit.ts - About 1 hr to fix

          Function merge has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public merge(frames: InOut[]): InOut {
                  const mergedFrame = frames[0];
                  const mergedObjects: Map<string, DataObject[]> = new Map();
                  mergedFrame.getObjects().forEach((object) => {
                      if (mergedObjects.get(object.uid)) {
          Severity: Minor
          Found in src/nodes/shapes/FrameMergeNode.ts - About 1 hr to fix

            Function createHandler has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                createHandler(target: Service, p: PropertyKey): (...args: any[]) => any {
                    return (...args: any[]) =>
                        new Promise<any>((resolve, reject) => {
                            const uuid = uuidv4();
                            this._promises.set(uuid, { resolve, reject });
            Severity: Minor
            Found in src/service/WorkerServiceProxy.ts - About 1 hr to fix

              Function convertAsArray has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  convertAsArray(
                      sourceObject: Array<any>,
                      typeDescriptor: ArrayTypeDescriptor,
                      memberName: string,
                      serializer: Serializer,
              Severity: Minor
              Found in src/data/Serializer.ts - About 1 hr to fix

                Function createDefinition has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    createDefinition(targetUnit: Unit): UnitFunctionDefinition<any, any> {
                        let newDefinition: UnitFunctionDefinition<any, any>;
                
                        // Get base unit
                        const baseUnitName = Unit.UNIT_BASES.get(this.baseName);
                Severity: Minor
                Found in src/utils/unit/Unit.ts - About 1 hr to fix

                  Function _onWorkerService has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private _onWorkerService(threadId: number, value: WorkerServiceCall): void {
                          const service: Service =
                              this.model.findDataService(value.serviceUID) || this.model.findService(value.serviceUID);
                          if ((service as any)[value.method]) {
                              const serializedParams = value.parameters;
                  Severity: Minor
                  Found in src/worker/WorkerHandler.ts - About 1 hr to fix

                    Function midpointGeographical has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected midpointGeographical(
                            sphereA: Sphere<GeographicalPosition>,
                            sphereB: Sphere<GeographicalPosition>,
                        ): GeographicalPosition {
                            const pointA = sphereA.position;
                    Severity: Minor
                    Found in src/nodes/processing/MultilaterationNode.ts - About 1 hr to fix

                      Function processObject has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public processObject(dataObject: DataObject, dataFrame: InOut): Promise<DataObject> {
                              return new Promise((resolve, reject) => {
                                  const referencePromises: Array<Promise<DataObject>> = [];
                                  const index = new Map<string, R>();
                                  for (const relativePosition of dataObject.relativePositions) {
                      Severity: Minor
                      Found in src/nodes/processing/RelativePositionProcessing.ts - About 1 hr to fix

                        Function process has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public process(frame: InOut, options?: GraphOptions): Promise<InOut> {
                                return new Promise<InOut>((resolve, reject) => {
                                    const processObjectPromises: Array<Promise<DataObject>> = [];
                                    const uids = [];
                                    const sourceUID = frame.source ? frame.source.uid : undefined;
                        Severity: Minor
                        Found in src/nodes/ObjectProcessingNode.ts - About 1 hr to fix

                          Function onPull has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public onPull(options: PullOptions = { requestedObjects: [] }): Promise<Out> {
                                  return new Promise<Out>((resolve, reject) => {
                                      const service = this.model.findDataService(DataObject);
                                      const requestPromises: Array<Promise<DataObject>> = [];
                                      options.requestedObjects.forEach((uid) => {
                          Severity: Minor
                          Found in src/nodes/source/HistorySourceNode.ts - About 1 hr to fix

                            Function addShape has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public addShape(shape: GraphBuilder<any, any> | GraphShape<any, any>): this {
                                    let graph: GraphShape<any, any>;
                                    if (shape instanceof GraphBuilder) {
                                        graph = shape.graph;
                                    } else {
                            Severity: Minor
                            Found in src/graph/builders/GraphBuilder.ts - About 1 hr to fix

                              Function processObject has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  processObject(object: DataObject): Promise<DataObject> {
                                      return new Promise((resolve, reject) => {
                                          const relativePositions = object.relativePositions
                                              // For each relative position matching the type
                                              .filter((x) => x instanceof this._relativePositionType);
                              Severity: Minor
                              Found in src/nodes/processing/dsp/RelativePositionFilter.ts - About 1 hr to fix

                                Function triangulate has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    protected triangulate<P extends AbsolutePosition>(points: P[], angles: number[]): Promise<P> {
                                        return new Promise<P>((resolve, reject) => {
                                            const vectors = [points[0].toVector3(), points[1].toVector3(), points[2].toVector3()];
                                
                                            const x1 = vectors[0].x - vectors[1].x;
                                Severity: Minor
                                Found in src/nodes/processing/TriangulationNode.ts - About 1 hr to fix

                                  Function _addServices has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      private _addServices(services: any[], call: (call: WorkerServiceCall) => Promise<WorkerServiceResponse>): void {
                                          const model = this.model as ModelGraph<any, any>;
                                          services
                                              .filter((service) => {
                                                  const internalService =
                                  Severity: Minor
                                  Found in src/worker/WorkerHandler.ts - About 1 hr to fix

                                    Function evaluateArraySelector has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        protected static evaluateArraySelector<T>(selector: string, value: any, subquery: QuerySelector<T>): boolean {
                                            let result = true;
                                            switch (selector) {
                                                case '$in':
                                                    result = result && Array.from(value).includes(subquery[selector]);
                                    Severity: Minor
                                    Found in src/service/MemoryQueryEvaluator.ts - About 1 hr to fix

                                      Function _onOutput has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          private _onOutput(next: { id: string; success: boolean; result?: any }): void {
                                              if (this._promises.has(next.id)) {
                                                  const promise = this._promises.get(next.id);
                                                  if (next.success) {
                                                      if (next.result === undefined) {
                                      Severity: Minor
                                      Found in src/service/WorkerServiceProxy.ts - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language