RackHD/on-dhcp-proxy

View on GitHub
lib/parser.js

Summary

Maintainability
F
1 wk
Test Coverage

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

      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

      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

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

                            case 58: {          // renewalTimeValue
                                this.len = msg.readUInt8(offset);
                                offset += 1;
                                assert.strictEqual(this.len, 4);
                                this.packet.options.renewalTimeValue = msg.readUInt32BE(offset);
        Severity: Major
        Found in lib/parser.js and 4 other locations - About 2 hrs to fix
        lib/parser.js on lines 131..138
        lib/parser.js on lines 252..259
        lib/parser.js on lines 268..275
        lib/parser.js on lines 308..315

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

        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

                            case 57: {          // maximumMessageSize
                                this.len = msg.readUInt8(offset);
                                offset += 1;
                                assert.strictEqual(this.len, 2);
                                this.packet.options.maximumMessageSize = msg.readUInt16BE(offset);
        Severity: Major
        Found in lib/parser.js and 4 other locations - About 2 hrs to fix
        lib/parser.js on lines 131..138
        lib/parser.js on lines 260..267
        lib/parser.js on lines 268..275
        lib/parser.js on lines 308..315

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

        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

                            case 2: {           // timeOffset
                                this.len = msg.readUInt8(offset);
                                offset += 1;
                                assert.strictEqual(this.len, 4);
                                this.packet.options.timeOffset = msg.readUInt32BE(offset);
        Severity: Major
        Found in lib/parser.js and 4 other locations - About 2 hrs to fix
        lib/parser.js on lines 252..259
        lib/parser.js on lines 260..267
        lib/parser.js on lines 268..275
        lib/parser.js on lines 308..315

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

        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

                            case 93: {          // system architecture
                                this.len = msg.readUInt8(offset);
                                offset += 1;
                                assert.strictEqual(this.len, 2);
                                this.packet.options.archType = msg.readUInt16BE(offset);
        Severity: Major
        Found in lib/parser.js and 4 other locations - About 2 hrs to fix
        lib/parser.js on lines 131..138
        lib/parser.js on lines 252..259
        lib/parser.js on lines 260..267
        lib/parser.js on lines 268..275

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

        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

                            case 59: {          // rebindingTimeValue
                                this.len = msg.readUInt8(offset);
                                offset += 1;
                                assert.strictEqual(this.len, 4);
                                this.packet.options.rebindingTimeValue = msg.readUInt32BE(offset);
        Severity: Major
        Found in lib/parser.js and 4 other locations - About 2 hrs to fix
        lib/parser.js on lines 131..138
        lib/parser.js on lines 252..259
        lib/parser.js on lines 260..267
        lib/parser.js on lines 308..315

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

        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

                            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

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

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

        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

        There are no issues that match your filters.

        Category
        Status