fh1ch/node-bacstack

View on GitHub

Showing 217 of 365 total issues

Avoid deeply nested control flow statements.
Open

    } else if (service === baEnum.UnconfirmedServiceChoice.TIME_SYNCHRONIZATION) {
      result = baServices.timeSync.decode(buffer, offset, length);
      if (!result) return debug('Received invalid TimeSync message');

      /**
Severity: Major
Found in lib/client.js - About 45 mins to fix

    Function decode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports.decode = (buffer, offset, apduLen) => {
      let len = 0;
      const value = {};
      if (apduLen <= 0) return {};
      let result = baAsn1.decodeTagNumberAndValue(buffer, offset + len);
    Severity: Minor
    Found in lib/services/who-is.js - 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 decode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports.decode = (buffer, offset, apduLen) => {
      let len = 0;
      let result;
      let decodedValue;
      let requestType;
    Severity: Minor
    Found in lib/services/read-range.js - 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 encodeTarget has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    const encodeTarget = (buffer, target) => {
      buffer.buffer[buffer.offset++] = (target.net & 0xFF00) >> 8;
      buffer.buffer[buffer.offset++] = (target.net & 0x00FF) >> 0;
      if (target.net === 0xFFFF || !target.adr) {
        buffer.buffer[buffer.offset++] = 0;
    Severity: Minor
    Found in lib/npdu.js - 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

    Avoid deeply nested control flow statements.
    Open

          if (!result) return debug('Received invalid writePropertyMultiple message');
    Severity: Major
    Found in lib/client.js - About 45 mins to fix

      Function _performDefaultSegmentHandling has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        _performDefaultSegmentHandling(sender, adr, type, service, invokeId, maxSegments, maxApdu, sequencenumber, first, moreFollows, buffer, offset, length) {
          if (first) {
            this._segmentStore = [];
            type &= ~baEnum.PduConReqBits.SEGMENTED_MESSAGE;
            let apduHeaderLen = 3;
      Severity: Minor
      Found in lib/client.js - 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

      Avoid deeply nested control flow statements.
      Open

            if (!result) return debug('Received invalid covNotifyUnconfirmed message');
      Severity: Major
      Found in lib/client.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

            } else if (service === baEnum.ConfirmedServiceChoice.CONFIRMED_COV_NOTIFICATION) {
              result = baServices.covNotify.decode(buffer, offset, length);
              if (!result) return debug('Received invalid covNotify message');
              this.emit('covNotify', {address: address, invokeId: invokeId, request: result});
            } else if (service === baEnum.ConfirmedServiceChoice.ATOMIC_WRITE_FILE) {
        Severity: Major
        Found in lib/client.js - About 45 mins to fix

          Function decode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports.decode = (buffer, offset, apduLen) => {
            let len = 0;
            const value = {};
            let decodedValue;
            let result = baAsn1.decodeTagNumberAndValue(buffer, offset + len);
          Severity: Minor
          Found in lib/services/who-has.js - 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 decode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports.decode = (buffer, offset) => {
            const orgOffset = offset;
            offset++;
            const funct = buffer[offset++];
            let destination;
          Severity: Minor
          Found in lib/npdu.js - 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 decodeTagNumberAndValue has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          const decodeTagNumberAndValue = module.exports.decodeTagNumberAndValue = (buffer, offset) => {
            let value;
            let result = decodeTagNumber(buffer, offset);
            let len = result.len;
            if (isExtendedValue(buffer[offset])) {
          Severity: Minor
          Found in lib/asn1.js - 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 byteReverseBits has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          const byteReverseBits = (inByte) => {
            let outByte = 0;
            if ((inByte & 1) > 0) {
              outByte |= 0x80;
            }
          Severity: Minor
          Found in lib/asn1.js - 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

          Avoid deeply nested control flow statements.
          Open

                if (!result) return;
          Severity: Major
          Found in lib/asn1.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                } else if (propertyId === baEnum.PropertyIdentifier.LIST_OF_OBJECT_PROPERTY_REFERENCES || propertyId === baEnum.PropertyIdentifier.LOG_DEVICE_OBJECT_PROPERTY || propertyId === baEnum.PropertyIdentifier.OBJECT_PROPERTY_REFERENCE) {
                  result = decodeDeviceObjPropertyRef(buffer, offset, maxOffset);
                  if (!result) return;
                  return {
                    type: baEnum.ApplicationTags.OBJECT_PROPERTY_REFERENCE,
            Severity: Major
            Found in lib/asn1.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                        if (bacappResult.encoding !== undefined) resObj.encoding = bacappResult.encoding;
              Severity: Major
              Found in lib/asn1.js - About 45 mins to fix

                Function decode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports.decode = (buffer, offset, apduLen) => {
                  let len = 0;
                  const value = {};
                  let result;
                  let decodedValue;
                Severity: Minor
                Found in lib/services/subscribe-cov.js - 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 decode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports.decode = (buffer, offset, apduLen) => {
                  let len = 0;
                  let result;
                  let decodedValue;
                  const value = {};
                Severity: Minor
                Found in lib/services/get-enrollment-summary.js - 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 _handlePdu has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  _handlePdu(address, type, buffer, offset, length) {
                    let result;
                    // Handle different PDU types
                    switch (type & baEnum.PDU_TYPE_MASK) {
                      case baEnum.PduTypes.UNCONFIRMED_REQUEST:
                Severity: Minor
                Found in lib/client.js - 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 decode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                module.exports.decode = (buffer, offset) => {
                  let result;
                  let apduLen = 0;
                  const orgOffset = offset;
                  result = baAsn1.decodeTagNumberAndValue(buffer, offset + apduLen);
                Severity: Minor
                Found in lib/services/i-am-broadcast.js - 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

                      if (!result) return debug('Received invalid subscribeProperty message');
                Severity: Major
                Found in lib/client.js - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language