OpenHPS/openhps-core

View on GitHub

Showing 247 of 247 total issues

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

    findByParentUID(parentUID: string): Promise<T[]> {
        return this.findAll({
            parentUID,
        }) as Promise<T[]>;
    }
Severity: Major
Found in src/service/DataObjectService.ts and 1 other location - About 1 hr to fix
src/service/DataObjectService.ts on lines 41..45

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

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 _convertSingleValue has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private _convertSingleValue(
        sourceObject: any,
        typeDescriptor: TypeDescriptor,
        knownTypes: Map<string, Serializable<any>>,
        memberName: string,
Severity: Minor
Found in src/data/Deserializer.ts - About 1 hr to fix

    Function findAll has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public findAll(query?: FilterQuery<T>, options: FindOptions = {}): Promise<T[]> {
            return new Promise<T[]>((resolve) => {
                options.limit = options.limit || this._data.size;
                let data: T[] = [];
                this._data.forEach((object) => {
    Severity: Minor
    Found in src/service/MemoryDataService.ts - About 1 hr to fix

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

          set linearVelocity(value: LinearVelocity) {
              if (!this.velocity) {
                  this.velocity = new Velocity();
              }
              this.velocity.linear = value;
      Severity: Major
      Found in src/data/position/AbsolutePosition.ts and 1 other location - About 1 hr to fix
      src/data/position/AbsolutePosition.ts on lines 131..136

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

      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

          set angularVelocity(value: AngularVelocity) {
              if (!this.velocity) {
                  this.velocity = new Velocity();
              }
              this.velocity.angular = value;
      Severity: Major
      Found in src/data/position/AbsolutePosition.ts and 1 other location - About 1 hr to fix
      src/data/position/AbsolutePosition.ts on lines 110..115

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

      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 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 trilaterate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected trilaterate<P extends AbsolutePosition>(spheres: Array<Sphere<P>>): Promise<P> {
                  return new Promise<P>((resolve) => {
                      const maxIterations = this.options.maxIterations || 900;
                      const v = spheres.map((p) => p.center);
                      const ex = v[1].clone().sub(v[0]).normalize();
          Severity: Minor
          Found in src/nodes/processing/MultilaterationNode.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 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 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 _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
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language