OpenHPS/openhps-rf

View on GitHub

Showing 14 of 43 total issues

Function parseAdvertisement has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    parseAdvertisement(payload: Uint8Array): this {
        if (!payload) {
            return this;
        }
        this.rawAdvertisement = payload;
Severity: Major
Found in src/data/BLEObject.ts - About 2 hrs to fix

    Function toString has 45 lines of code (exceeds 25 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/BLEUUID.ts - About 1 hr to fix

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

          processObject(object: BLEObject, frame: DataFrame): Promise<BLEObject> {
              return new Promise((resolve) => {
                  let output = object;
                  for (let i = 0; i < this.options.types.length; i++) {
                      const BeaconType = this.options.types[i];
      Severity: Minor
      Found in src/nodes/BLEBeaconClassifierNode.ts - About 1 hr to fix

        Function parseServiceData has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            parseServiceData(uuid: BLEUUID, serviceData: Uint8Array): this {
                super.parseServiceData(uuid, serviceData);
                if (uuid === undefined && serviceData === undefined) {
                    return this;
                }
        Severity: Minor
        Found in src/data/BLEEddystoneTLM.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 parseServiceData has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            parseServiceData(uuid: BLEUUID, serviceData: Uint8Array): this {
                super.parseServiceData(uuid, serviceData);
                if (uuid === undefined && serviceData === undefined) {
                    return this;
                }
        Severity: Minor
        Found in src/data/BLEEddystoneURL.ts - About 1 hr to fix

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

              parseServiceData(uuid: BLEUUID, serviceData: Uint8Array): this {
                  super.parseServiceData(uuid, serviceData);
                  if (uuid === undefined && serviceData === undefined) {
                      return this;
                  }
          Severity: Minor
          Found in src/data/BLEEddystoneTLM.ts - About 1 hr to fix

            Function parseServiceData has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                parseServiceData(uuid: BLEUUID, serviceData: Uint8Array): this {
                    super.parseServiceData(uuid, serviceData);
                    if (uuid === undefined && serviceData === undefined) {
                        return this;
                    }
            Severity: Minor
            Found in src/data/BLEEddystoneURL.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 bundle has a Cognitive Complexity of 10 (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 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 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/BLEUUID.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 parseAdvertisement has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                parseAdvertisement(payload: Uint8Array): this {
                    if (!payload) {
                        return this;
                    }
                    this.rawAdvertisement = payload;
            Severity: Minor
            Found in src/data/BLEObject.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 constructor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                constructor(address?: MACAddress | string) {
                    super(address ? (address instanceof MACAddress ? address.toString() : address) : undefined);
                    if (address instanceof MACAddress) {
                        this.address = address;
                        if (!this.knownAddresses.includes(address) && address !== undefined) {
            Severity: Minor
            Found in src/data/BLEObject.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;
            Severity: Major
            Found in src/data/BLEEddystoneURL.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return this;
              Severity: Major
              Found in src/data/BLEEddystoneURL.ts - About 30 mins to fix

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

                    protected convertToDistance(rel: RelativeRSSI, transmitter: RFTransmitterObject): RelativeDistance {
                        const environmentFactor = this.options.environmentFactor || transmitter.environmentFactor;
                        const calibratedRSSI = transmitter.calibratedRSSI || this.options.defaultCalibratedRSSI;
                        switch (this.options.propagationModel) {
                            case PropagationModel.LOG_DISTANCE:
                Severity: Minor
                Found in src/nodes/RelativeRSSIProcessing.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