RackHD/on-dhcp-proxy

View on GitHub

Showing 26 of 60 total issues

Function createPacketBuffer has 385 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function createPacketBuffer(pkt) {
    if (!('xid' in pkt)) {
        throw new Error('pkt.xid required');
    }

Severity: Major
Found in lib/packet.js - About 1 day to fix

    Function createPacketBuffer has a Cognitive Complexity of 75 (exceeds 5 allowed). Consider refactoring.
    Open

    function createPacketBuffer(pkt) {
        if (!('xid' in pkt)) {
            throw new Error('pkt.xid required');
        }
    
    
    Severity: Minor
    Found in lib/packet.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 ParserFactory has 287 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function ParserFactory(protocol, Logger, assert) {
        return {
            logger: Logger.initialize(ParserFactory),
            len: null,
    
    
    Severity: Major
    Found in lib/parser.js - About 1 day to fix

      Function parse has 240 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              parse: function(msg) {
                  this.len = null;
      
                  var unhandledOptions = [],
                      offset = 240,
      Severity: Major
      Found in lib/parser.js - About 1 day to fix

        File packet.js has 426 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*
        Copyright (c) 2011-2014 Andrew Paprocki
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        Severity: Minor
        Found in lib/packet.js - About 6 hrs to fix

          Function ParserFactory has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
          Open

          function ParserFactory(protocol, Logger, assert) {
              return {
                  logger: Logger.initialize(ParserFactory),
                  len: null,
          
          
          Severity: Minor
          Found in lib/parser.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 messageHandlerFactory has 139 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function messageHandlerFactory(
              packetUtil,
              parser,
              lookupService,
              configuration,
          Severity: Major
          Found in lib/message-handler.js - About 5 hrs to fix

            Function iscDhcpLeasePollerFactory has 120 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function iscDhcpLeasePollerFactory(
                lookupService,
                configuration,
                Logger,
                Promise,
            Severity: Major
            Found in lib/isc-dhcp-lease-poller.js - About 4 hrs to fix

              Function ProtocolFactory has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

              function ProtocolFactory() {
                  var createEnum = function (v, n) {
                      function Enum(value, name) {
                          this.value = value;
                          this.name = name;
              Severity: Minor
              Found in lib/dhcp-protocol.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 prepareGrunt has 95 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function prepareGrunt(grunt) {
                  var allFiles = [
                      'package.json',
                      'Gruntfile.js',
                      'lib/**/*.js',
              Severity: Major
              Found in gruntfile.js - About 3 hrs to fix

                Function messageHandlerFactory has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                Open

                function messageHandlerFactory(
                    packetUtil,
                    parser,
                    lookupService,
                    configuration,
                Severity: Minor
                Found in lib/message-handler.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 ProtocolFactory has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function ProtocolFactory() {
                    var createEnum = function (v, n) {
                        function Enum(value, name) {
                            this.value = value;
                            this.name = name;
                Severity: Major
                Found in lib/dhcp-protocol.js - About 3 hrs to fix

                  File parser.js has 294 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  /*
                   Copyright (c) 2011-2014 Andrew Paprocki
                  
                   Permission is hereby granted, free of charge, to any person obtaining a copy
                   of this software and associated documentation files (the "Software"), to deal
                  Severity: Minor
                  Found in lib/parser.js - About 3 hrs to fix

                    Function serverFactory has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function serverFactory(core, messageHandler, IscDhcpLeasePoller, Logger) {
                        var logger = Logger.initialize(Server);
                    
                        function Server(inPort, outPort, address) {
                            this.server = dgram.createSocket('udp4');
                    Severity: Major
                    Found in lib/server.js - About 2 hrs to fix

                      Function isBootFileNameSent has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          MessageHandler.prototype.isBootFileNameSent = function(packetData) {
                              var macAddress = packetData.chaddr.address;
                              return lookupService.macAddressToNode(macAddress)
                              .then(function(node) {
                                  return node.discovered()
                      Severity: Minor
                      Found in lib/message-handler.js - About 1 hr to fix

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

                        function iscDhcpLeasePollerFactory(
                            lookupService,
                            configuration,
                            Logger,
                            Promise,
                        Severity: Minor
                        Found in lib/isc-dhcp-lease-poller.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 getDefaultBootfile has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            MessageHandler.prototype.getDefaultBootfile = function(packetData) {
                                assert.object(packetData);
                                assert.object(packetData.options);
                                assert.string(packetData.chaddr.address);
                        
                        
                        Severity: Minor
                        Found in lib/message-handler.js - About 1 hr to fix

                          Function handleDhcpPacket has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              MessageHandler.prototype.handleDhcpPacket = function(packet, sendCallback) {
                                  var self = this;
                                  var packetData;
                          
                                  try {
                          Severity: Minor
                          Found in lib/message-handler.js - About 1 hr to fix

                            Function messageHandlerFactory has 10 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                packetUtil,
                                parser,
                                lookupService,
                                configuration,
                                taskProtocol,
                            Severity: Major
                            Found in lib/message-handler.js - About 1 hr to fix

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

                                  IscDhcpLeasePoller.prototype.parseLeaseData = function(data) {
                                      /*
                                       * SAMPLE ISC DHCP LEASE FILE
                                       *
                                       *  # The format of this file is documented in the dhcpd.leases(5) manual page.
                              Severity: Minor
                              Found in lib/isc-dhcp-lease-poller.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language