RackHD/on-dhcp-proxy

View on GitHub

Showing 60 of 60 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                    case 52: {          // optionOverload
                        this.len = msg.readUInt8(offset);
                        offset += 1;
                        assert.strictEqual(this.len, 1);
                        this.packet.options.optionOverload = msg.readUInt8(offset);
Severity: Major
Found in lib/parser.js and 1 other location - About 2 hrs to fix
lib/parser.js on lines 209..217

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 86.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

    Identical blocks of code found in 3 locations. Consider refactoring.
    Open

                get: function (value) {
                    for (var key in this) {
                        if (this.hasOwnProperty(key)) {
                            var obj = this[key];
                            // NOTE: DO NOT MAKE THIS TRIPLE EQUALS
    Severity: Major
    Found in lib/dhcp-protocol.js and 2 other locations - About 1 hr to fix
    lib/dhcp-protocol.js on lines 57..68
    lib/dhcp-protocol.js on lines 105..116

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 73.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 3 locations. Consider refactoring.
    Open

                get: function (value) {
                    for (var key in this) {
                        if (this.hasOwnProperty(key)) {
                            var obj = this[key];
                            // NOTE: DO NOT MAKE THIS TRIPLE EQUALS
    Severity: Major
    Found in lib/dhcp-protocol.js and 2 other locations - About 1 hr to fix
    lib/dhcp-protocol.js on lines 82..93
    lib/dhcp-protocol.js on lines 105..116

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 73.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 3 locations. Consider refactoring.
    Open

                get: function (value) {
                    for (var key in this) {
                        if (this.hasOwnProperty(key)) {
                            var obj = this[key];
                            // NOTE: DO NOT MAKE THIS TRIPLE EQUALS
    Severity: Major
    Found in lib/dhcp-protocol.js and 2 other locations - About 1 hr to fix
    lib/dhcp-protocol.js on lines 57..68
    lib/dhcp-protocol.js on lines 82..93

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 73.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

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

              function PacketFactory(protocol, configuration, _) {
                  var packetFunctions = {
                      // Expose this for test
                      createPacketBuffer: createPacketBuffer,
                      createProxyDhcpAck: function(clientPacket, bootFileName) {
              Severity: Minor
              Found in lib/packet.js - About 1 hr to fix

                Function iscDhcpLeasePollerFactory has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    lookupService,
                    configuration,
                    Logger,
                    Promise,
                    assert,
                Severity: Major
                Found in lib/isc-dhcp-lease-poller.js - About 1 hr to fix

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                      var yi = new Buffer(pkt.yiaddr ?
                          new v4.Address(pkt.yiaddr).toArray() : [0, 0, 0, 0]);
                  Severity: Major
                  Found in lib/packet.js and 2 other locations - About 40 mins to fix
                  lib/packet.js on lines 87..88
                  lib/packet.js on lines 93..94

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 49.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                      var si = new Buffer(pkt.siaddr ?
                          new v4.Address(pkt.siaddr).toArray() : [0, 0, 0, 0]);
                  Severity: Major
                  Found in lib/packet.js and 2 other locations - About 40 mins to fix
                  lib/packet.js on lines 87..88
                  lib/packet.js on lines 90..91

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 49.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                      var ci = new Buffer(pkt.ciaddr ?
                          new v4.Address(pkt.ciaddr).toArray() : [0, 0, 0, 0]);
                  Severity: Major
                  Found in lib/packet.js and 2 other locations - About 40 mins to fix
                  lib/packet.js on lines 90..91
                  lib/packet.js on lines 93..94

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 49.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Avoid too many return statements within this function.
                  Open

                              return 'monorail.ipxe';
                  Severity: Major
                  Found in lib/message-handler.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                    return 'monorail-undionly.kpxe';
                    Severity: Major
                    Found in lib/message-handler.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                      return 'monorail-efi64-snponly.efi';
                      Severity: Major
                      Found in lib/message-handler.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                        return 'monorail-efi32-snponly.efi';
                        Severity: Major
                        Found in lib/message-handler.js - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language