OpenHPS/openhps-sphero

View on GitHub

Showing 16 of 37 total issues

Core has 25 functions (exceeds 20 allowed). Consider refactoring.
Open

export class Core {
  // Override in child class to get right percent
  protected maxVoltage: number = 0;
  protected minVoltage: number = 1;
  protected apiVersion: APIVersion = APIVersion.V2;
Severity: Minor
Found in lib/web/src/toys/core.ts - About 2 hrs to fix

    Function factory has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    export function factory(
      callback: (err: string, response?: ICommandWithRaw) => void
    ) {
      let msg: number[] = [];
      let checksum: number = 0;
    Severity: Minor
    Found in lib/web/src/commands/decoder.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

    Function _onSensorEvent has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private _onSensorEvent(event: ISensorResponse): void {
            if (!this._calibrated) {
                // Start orientation
                this.referenceSpace.rotation(
                    Quaternion.fromEuler({
    Severity: Major
    Found in src/nodes/SpheroSensorSource.ts - About 2 hrs to fix

      Function factory has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function factory(
        callback: (err: string, response?: ICommandWithRaw) => void
      ) {
        let msg: number[] = [];
        let checksum: number = 0;
      Severity: Major
      Found in lib/web/src/commands/decoder.ts - About 2 hrs to fix

        File core.ts has 253 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import { factory } from '../commands';
        import { factory as decodeFactory, number } from '../commands/decoder';
        import {
          DeviceId,
          DriveFlag,
        Severity: Minor
        Found in lib/web/src/toys/core.ts - About 2 hrs to fix

          Function calculateDomeAngle has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private calculateDomeAngle(angle: number) {
              const result = new Uint8Array(2);
              switch (angle) {
                case -1:
                  result[0] = 0xbf;
          Severity: Minor
          Found in lib/web/src/toys/r2d2.ts - About 1 hr to fix

            Function encode has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function encode(command: ICommand): ICommandWithRaw {
              const {
                commandFlags = [Flags.requestsResponse, Flags.resetsInactivityTimeout],
                deviceId,
                commandId,
            Severity: Minor
            Found in lib/web/src/commands/encoder.ts - About 1 hr to fix

              Function add has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  add(byte: number) {
                    switch (byte) {
                      case APIConstants.startOfPacket:
                        if (msg.length !== 0) {
                          init();
              Severity: Minor
              Found in lib/web/src/commands/decoder.ts - About 1 hr to fix

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

                    public roll(speed: number, heading: number, flags: DriveFlag[] = []): Promise<void> {
                        return new Promise((resolve, reject) => {
                            const spheroObject = this.source as SpheroDataObject<T>;
                            const position = spheroObject.getPosition() || new Absolute2DPosition(0, 0);
                            position.unit = LengthUnit.CENTIMETER;
                Severity: Minor
                Found in src/nodes/SpheroInputSource.ts - About 1 hr to fix

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

                  const bundle = (env, module) => ({
                    name: PROJECT_NAME,
                    entry: `./dist/${module ? "esm" : "cjs"}/index.js`,
                    output: {
                      path: path.resolve(__dirname, 'dist'),
                  Severity: Minor
                  Found in webpack.config.js - 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 calculateDomeAngle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                    private calculateDomeAngle(angle: number) {
                      const result = new Uint8Array(2);
                      switch (angle) {
                        case -1:
                          result[0] = 0xbf;
                  Severity: Minor
                  Found in lib/web/src/toys/r2d2.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 sensorValuesToRawV2 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  const sensorValuesToRawV2 = (
                    sensorMask: SensorMaskValues[],
                    apiVersion: APIVersion = APIVersion.V2
                  ) =>
                    sensorMask.reduce((v2, m) => {
                  Severity: Minor
                  Found in lib/web/src/toys/utils.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 init();
                  Severity: Major
                  Found in lib/web/src/commands/decoder.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return error('Invalid escape char position');
                    Severity: Major
                    Found in lib/web/src/commands/decoder.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              return error('Invalid no escape char end found');
                      Severity: Major
                      Found in lib/web/src/commands/decoder.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                  return;
                        Severity: Major
                        Found in lib/web/src/commands/decoder.ts - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language