fh1ch/node-bacstack

View on GitHub

Showing 217 of 365 total issues

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

module.exports.decode = (buffer, offset) => {
  let len = 0;
  let result;
  let decodedValue;
  let isStream = true;
Severity: Minor
Found in lib/services/atomic-read-file.js - 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 bacappEncodePropertyState has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports.bacappEncodePropertyState = (buffer, value) => {
  switch (value.type) {
    case baEnum.PropertyStates.BOOLEAN_VALUE:
      encodeContextBoolean(buffer, 0, value.state === 1 ? true : false);
      break;
Severity: Minor
Found in lib/asn1.js - About 1 hr to fix

    Function _handlePdu has 44 lines of code (exceeds 25 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 1 hr to fix

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

      module.exports.decode = (buffer, offset) => {
        let len = 0;
        let result;
        let decodedValue;
        const eventData = {};
      Severity: Minor
      Found in lib/services/event-notify-data.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 decodeAcknowledge has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports.decodeAcknowledge = (buffer, offset, apduLen) => {
        let result;
        let decodedValue;
        const objectId = {};
        const property = {};
      Severity: Minor
      Found in lib/services/read-property.js - About 1 hr to fix

        Function decodeAcknowledge has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports.decodeAcknowledge = (buffer, offset, apduLen) => {
          let len = 0;
          let result;
          let decodedValue;
          if (!baAsn1.decodeIsContextTag(buffer, offset + len, 0)) return;
        Severity: Minor
        Found in lib/services/read-range.js - About 1 hr to fix

          Function decodeReadAccessSpecification has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const decodeReadAccessSpecification = module.exports.decodeReadAccessSpecification = (buffer, offset, apduLen) => {
            let len = 0;
            const value = {};
            if (!decodeIsContextTag(buffer, offset + len, 0)) return;
            len++;
          Severity: Minor
          Found in lib/asn1.js - About 1 hr to fix

            Function decodeAcknowledge has 41 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            module.exports.decodeAcknowledge = (buffer, offset, apduLen) => {
              let len = 0;
              let result;
              const enrollmentSummaries = [];
              while ((apduLen - len) > 0) {
            Severity: Minor
            Found in lib/services/get-enrollment-summary.js - About 1 hr to fix

              Function _processUnconfirmedServiceRequest has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                _processUnconfirmedServiceRequest(address, type, service, buffer, offset, length) {
                  let result;
                  debug('Handle this._processUnconfirmedServiceRequest');
                  if (service === baEnum.UnconfirmedServiceChoice.I_AM) {
                    result = baServices.iAmBroadcast.decode(buffer, offset);
              Severity: Minor
              Found in lib/client.js - About 1 hr to fix

                Function decodeAcknowledge has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports.decodeAcknowledge = (buffer, offset) => {
                  let len = 0;
                  let result;
                  let decodedValue;
                  let isStream;
                Severity: Minor
                Found in lib/services/atomic-read-file.js - About 1 hr to fix

                  Function decode has 39 lines of code (exceeds 25 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 1 hr to fix

                    Function decode has 38 lines of code (exceeds 25 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/add-list-element.js - About 1 hr to fix

                      Function decode has 37 lines of code (exceeds 25 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 1 hr to fix

                        Function decode has 37 lines of code (exceeds 25 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 1 hr to fix

                          Function decode has 35 lines of code (exceeds 25 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 1 hr to fix

                            Function encodeTag has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            const encodeTag = module.exports.encodeTag = (buffer, tagNumber, contextSpecific, lenValueType) => {
                              let len = 1;
                              const tmp = new Array(3);
                              tmp[0] = 0;
                              if (contextSpecific) {
                            Severity: Minor
                            Found in lib/asn1.js - About 1 hr to fix

                              Function decode has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              module.exports.decode = (buffer, offset, apduLen) => {
                                let len = 0;
                                let result;
                                let decodedValue;
                                if (apduLen < 7) return;
                              Severity: Minor
                              Found in lib/services/read-property.js - About 1 hr to fix

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

                                module.exports.decodeAcknowledge = (buffer, offset, apduLen) => {
                                  let len = 0;
                                  let result;
                                  const enrollmentSummaries = [];
                                  while ((apduLen - len) > 0) {
                                Severity: Minor
                                Found in lib/services/get-enrollment-summary.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 decode has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                module.exports.decode = (buffer, offset) => {
                                  let len;
                                  const func = buffer[1];
                                  const msgLength = (buffer[2] << 8) | (buffer[3] << 0);
                                  if (buffer[0] !== baEnum.BVLL_TYPE_BACNET_IP || buffer.length !== msgLength) return;
                                Severity: Minor
                                Found in lib/bvlc.js - About 1 hr to fix

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

                                  const decodeDeviceObjPropertyRef = (buffer, offset) => {
                                    let len = 0;
                                    let arrayIndex = baEnum.ASN1_ARRAY_ALL;
                                    if (!decodeIsContextTag(buffer, offset + len, 0)) return;
                                    len++;
                                  Severity: Minor
                                  Found in lib/asn1.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language