RackHD/on-dhcp-proxy

View on GitHub

Showing 60 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

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

            if(pkt.options && pkt.options.timeServerOption) {       //option 4
                p.writeUInt8(4, i);
                i += 1; // option 4
                // If timeServerOption is not an array by human error,
                // it's probably a string and we should just make it an array.
        Severity: Major
        Found in lib/packet.js and 1 other location - About 7 hrs to fix
        lib/packet.js on lines 214..233

        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 188.

        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 2 locations. Consider refactoring.
        Open

            if (pkt.options && pkt.options.routerOptions) {         // option 3
                p.writeUInt8(3, i);
                i += 1; // option 3
                // If routerOptions is not an array by human error,
                // it's probably a string and we should just make it an array.
        Severity: Major
        Found in lib/packet.js and 1 other location - About 7 hrs to fix
        lib/packet.js on lines 234..253

        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 188.

        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

        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

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

                                case 6: {           // domainNameServerOption
                                    this.len = msg.readUInt8(offset);
                                    offset += 1;
                                    assert.strictEqual(this.len % 4, 0);
                                    this.packet.options.domainNameServerOption = [];
            Severity: Major
            Found in lib/parser.js and 2 other locations - About 5 hrs to fix
            lib/parser.js on lines 139..150
            lib/parser.js on lines 151..162

            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 141.

            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

                                case 4: {           // timeServerOption
                                    this.len = msg.readUInt8(offset);
                                    offset += 1;
                                    assert.strictEqual(this.len % 4, 0);
                                    this.packet.options.timeServerOption = [];
            Severity: Major
            Found in lib/parser.js and 2 other locations - About 5 hrs to fix
            lib/parser.js on lines 139..150
            lib/parser.js on lines 163..175

            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 141.

            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

                                case 3: {           // routerOptions
                                    this.len = msg.readUInt8(offset);
                                    offset += 1;
                                    assert.strictEqual(this.len % 4, 0);
                                    this.packet.options.routerOptions = [];
            Severity: Major
            Found in lib/parser.js and 2 other locations - About 5 hrs to fix
            lib/parser.js on lines 151..162
            lib/parser.js on lines 163..175

            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 141.

            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 2 locations. Consider refactoring.
            Open

                if (pkt.options && pkt.options.requestedIpAddress) {    // option 50
                    p.writeUInt8(50, i);
                    i += 1;  // option 50
                    var requestedIpAddress = new Buffer(
                        new v4.Address(pkt.options.requestedIpAddress).toArray());
            Severity: Major
            Found in lib/packet.js and 1 other location - About 4 hrs to fix
            lib/packet.js on lines 291..300

            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 132.

            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 2 locations. Consider refactoring.
            Open

                if (pkt.options && pkt.options.broadcastAddress) {      // option 28
                    p.writeUInt8(28, i);
                    i += 1; // option 28
                    var broadcastAddress = new Buffer(
                        new v4.Address(pkt.options.broadcastAddress).toArray());
            Severity: Major
            Found in lib/packet.js and 1 other location - About 4 hrs to fix
            lib/packet.js on lines 328..337

            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 132.

            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 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

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

                  if(pkt.options && pkt.options.domainName) {             //option 15
                      p.writeUInt8(15, i);
                      i += 1; // option 15
                      var domainName = new Buffer(pkt.options.domainName);
                      p.writeUInt8(domainName.length, i);
              Severity: Major
              Found in lib/packet.js and 4 other locations - About 3 hrs to fix
              lib/packet.js on lines 273..281
              lib/packet.js on lines 414..422
              lib/packet.js on lines 448..456
              lib/packet.js on lines 457..465

              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 113.

              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 5 locations. Consider refactoring.
              Open

                  if (pkt.options && pkt.options.bootFileName) {          // option 67
                      p.writeUInt8(67, i);
                      i += 1; // option 67
                      var bootFileName = new Buffer(pkt.options.bootFileName);
                      p.writeUInt8(bootFileName.length, i);
              Severity: Major
              Found in lib/packet.js and 4 other locations - About 3 hrs to fix
              lib/packet.js on lines 273..281
              lib/packet.js on lines 282..290
              lib/packet.js on lines 414..422
              lib/packet.js on lines 457..465

              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 113.

              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 5 locations. Consider refactoring.
              Open

                  if (pkt.options && pkt.options.userClass) {          // option 77
                      p.writeUInt8(77, i);
                      i += 1; // option 60
                      var userClass = new Buffer(pkt.options.userClass);
                      p.writeUInt8(userClass.length, i);
              Severity: Major
              Found in lib/packet.js and 4 other locations - About 3 hrs to fix
              lib/packet.js on lines 273..281
              lib/packet.js on lines 282..290
              lib/packet.js on lines 414..422
              lib/packet.js on lines 448..456

              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 113.

              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 5 locations. Consider refactoring.
              Open

                  if (pkt.options && pkt.options.vendorClassIdentifier) {   // option 60
                      p.writeUInt8(60, i);
                      i += 1; // option 60
                      var vendorClassIdentifier = new Buffer(pkt.options.vendorClassIdentifier);
                      p.writeUInt8(vendorClassIdentifier.length, i);
              Severity: Major
              Found in lib/packet.js and 4 other locations - About 3 hrs to fix
              lib/packet.js on lines 273..281
              lib/packet.js on lines 282..290
              lib/packet.js on lines 448..456
              lib/packet.js on lines 457..465

              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 113.

              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

              Severity
              Category
              Status
              Source
              Language