fh1ch/node-bacstack

View on GitHub

Showing 263 of 263 total issues

File enum.js has 2069 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

module.exports.PDU_TYPE_MASK = 0xF0;
module.exports.ASN1_MAX_OBJECT = 0x3FF;
module.exports.ASN1_INSTANCE_BITS = 22;
Severity: Major
Found in lib/enum.js - About 5 days to fix

    File asn1.js has 1528 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    const iconv       = require('iconv-lite');
    const baEnum      = require('./enum');
    
    
    Severity: Major
    Found in lib/asn1.js - About 4 days to fix

      File client.js has 833 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict';
      
      // Util Modules
      const EventEmitter      = require('events').EventEmitter;
      const debug             = require('debug')('bacstack');
      Severity: Major
      Found in lib/client.js - About 2 days to fix

        Function bacappDecodeContextApplicationData has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
        Open

        const bacappDecodeContextApplicationData = (buffer, offset, maxOffset, objectType, propertyId) => {
          let len = 0;
          let result;
          if (isContextSpecific(buffer[offset])) {
            if (propertyId === baEnum.PropertyIdentifier.LIST_OF_GROUP_MEMBERS) {
        Severity: Minor
        Found in lib/asn1.js - About 1 day 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 _processConfirmedServiceRequest has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
        Open

          _processConfirmedServiceRequest(address, type, service, maxSegments, maxApdu, invokeId, buffer, offset, length) {
            let result;
            debug('Handle this._processConfirmedServiceRequest');
            if (service === baEnum.ConfirmedServiceChoice.READ_PROPERTY) {
              result = baServices.readProperty.decode(buffer, offset, length);
        Severity: Minor
        Found in lib/client.js - About 1 day 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

        File service-read-property.spec.js has 519 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict';
        
        const expect      = require('chai').expect;
        const utils       = require('./utils');
        const baServices  = require('../../lib/services');
        Severity: Major
        Found in test/unit/service-read-property.spec.js - About 1 day to fix

          Client has 49 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Client extends EventEmitter {
            constructor(options) {
              super();
          
              options = options || {};
          Severity: Minor
          Found in lib/client.js - About 6 hrs to fix

            Function decodeReadAccessResult has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
            Open

            const decodeReadAccessResult = module.exports.decodeReadAccessResult = (buffer, offset, apduLen) => {
              let len = 0;
              let value = {};
              if (!decodeIsContextTag(buffer, offset + len, 0)) return;
              len++;
            Severity: Minor
            Found in lib/asn1.js - About 5 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 bacappDecodeContextApplicationData has 127 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const bacappDecodeContextApplicationData = (buffer, offset, maxOffset, objectType, propertyId) => {
              let len = 0;
              let result;
              if (isContextSpecific(buffer[offset])) {
                if (propertyId === baEnum.PropertyIdentifier.LIST_OF_GROUP_MEMBERS) {
            Severity: Major
            Found in lib/asn1.js - About 5 hrs to fix

              Function bacappContextTagType has 117 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const bacappContextTagType = (property, tagNumber) => {
                let tag = 0;
                switch (property) {
                  case baEnum.PropertyIdentifier.ACTUAL_SHED_LEVEL:
                  case baEnum.PropertyIdentifier.REQUESTED_SHED_LEVEL:
              Severity: Major
              Found in lib/asn1.js - About 4 hrs to fix

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

                module.exports.encode = (buffer, data) => {
                  baAsn1.encodeContextUnsigned(buffer, 0, data.processId);
                  baAsn1.encodeContextObjectId(buffer, 1, data.initiatingObjectId.type, data.initiatingObjectId.instance);
                  baAsn1.encodeContextObjectId(buffer, 2, data.eventObjectId.type, data.eventObjectId.instance);
                  baAsn1.bacappEncodeContextTimestamp(buffer, 3, data.timeStamp);
                Severity: Major
                Found in lib/services/event-notify-data.js - About 4 hrs to fix

                  Function _processUnconfirmedServiceRequest has a Cognitive Complexity of 28 (exceeds 5 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 4 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 _processConfirmedServiceRequest has 95 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    _processConfirmedServiceRequest(address, type, service, maxSegments, maxApdu, invokeId, buffer, offset, length) {
                      let result;
                      debug('Handle this._processConfirmedServiceRequest');
                      if (service === baEnum.ConfirmedServiceChoice.READ_PROPERTY) {
                        result = baServices.readProperty.decode(buffer, offset, length);
                  Severity: Major
                  Found in lib/client.js - About 3 hrs to fix

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

                    module.exports.decode = (buffer, offset) => {
                      let len = 0;
                      let result;
                      let decodedValue;
                      let eventData = {};
                    Severity: Major
                    Found in lib/services/event-notify-data.js - About 3 hrs to fix

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

                      module.exports.decode = (buffer, offset, apduLen) => {
                        let len = 0;
                        let result;
                        let decodedValue;
                        let requestType;
                      Severity: Major
                      Found in lib/services/read-range.js - About 3 hrs to fix

                        Function decodeReadAccessResult has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

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

                          Function decodeCovSubscription has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const decodeCovSubscription = (buffer, offset, apduLen) => {
                            let len = 0;
                            let value = {};
                            let result;
                            let decodedValue;
                          Severity: Major
                          Found in lib/asn1.js - About 3 hrs to fix

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

                            module.exports.decode = (buffer, offset, apduLen) => {
                              let len = 0;
                              let result;
                              let decodedValue;
                              let objectId;
                            Severity: Minor
                            Found in lib/services/create-object.js - About 3 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 decodeAcknowledge has 83 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            module.exports.decodeAcknowledge = (buffer, offset, apduLen) => {
                              let len = 0;
                              let result;
                              let decodedValue;
                              let value = {};
                            Severity: Major
                            Found in lib/services/get-event-information.js - About 3 hrs to fix

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

                              module.exports.decode = (buffer, offset, apduLen) => {
                                let len = 0;
                                let result;
                                let decodedValue;
                                if (!baAsn1.decodeIsContextTag(buffer, offset + len, 0)) return;
                              Severity: Minor
                              Found in lib/services/cov-notify.js - About 3 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

                              Severity
                              Category
                              Status
                              Source
                              Language