verse/verse-javascript

View on GitHub
src/layer.js

Summary

Maintainability
F
1 wk
Test Coverage

File layer.js has 397 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Verse Websocket Asynchronous Module
 *
 * The MIT License (MIT)
 *
Severity: Minor
Found in src/layer.js - About 5 hrs to fix

    Function getLayerSetUint64 has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        getLayerSetUint64 = function getLayerSetUint64(opCode, receivedView, bufferPosition) {
            var result, hi, lo, bigNumber;
    
            result = getLayerCmdCommons(opCode, receivedView, bufferPosition);
    
    
    Severity: Minor
    Found in src/layer.js - About 1 hr to fix

      Function create has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              create: function(nodeId, parentLayerId, dataType, count, customType) {
      Severity: Minor
      Found in src/layer.js - About 35 mins to fix

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

            getLayerSetFloat64 = function getLayerSetFloat64(opCode, receivedView, bufferPosition) {
                var result = getLayerCmdCommons(opCode, receivedView, bufferPosition);
        
                result.VALUES = [];
                result.VALUES[0] = receivedView.getFloat64(bufferPosition + 13, false);
        Severity: Major
        Found in src/layer.js and 3 other locations - About 1 day to fix
        src/layer.js on lines 99..121
        src/layer.js on lines 127..149
        src/layer.js on lines 214..236

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

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

            getLayerSetUint32 = function getLayerSetUint32(opCode, receivedView, bufferPosition) {
                var result = getLayerCmdCommons(opCode, receivedView, bufferPosition);
        
                result.VALUES = [];
                result.VALUES[0] = receivedView.getUint32(bufferPosition + 13, false);
        Severity: Major
        Found in src/layer.js and 3 other locations - About 1 day to fix
        src/layer.js on lines 99..121
        src/layer.js on lines 214..236
        src/layer.js on lines 242..264

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

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

            getLayerSetUint16 = function getLayerSetUint16(opCode, receivedView, bufferPosition) {
                var result = getLayerCmdCommons(opCode, receivedView, bufferPosition);
        
                result.VALUES = [];
                result.VALUES[0] = receivedView.getUint16(bufferPosition + 13, false);
        Severity: Major
        Found in src/layer.js and 3 other locations - About 1 day to fix
        src/layer.js on lines 127..149
        src/layer.js on lines 214..236
        src/layer.js on lines 242..264

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

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

            getLayerSetFloat32 = function getLayerSetFloat32(opCode, receivedView, bufferPosition) {
                var result = getLayerCmdCommons(opCode, receivedView, bufferPosition);
        
                result.VALUES = [];
                result.VALUES[0] = receivedView.getFloat32(bufferPosition + 13, false);
        Severity: Major
        Found in src/layer.js and 3 other locations - About 1 day to fix
        src/layer.js on lines 99..121
        src/layer.js on lines 127..149
        src/layer.js on lines 242..264

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

        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

            getLayerCmdCommons = function getLayerCmdCommons(opCode, receivedView, bufferPosition) {
                return {
                    CMD: commands[opCode],
                    SHARE: receivedView.getUint8(bufferPosition + 2),
                    NODE_ID: receivedView.getUint32(bufferPosition + 3, false),
        Severity: Major
        Found in src/layer.js and 1 other location - About 3 hrs to fix
        src/layer.js on lines 41..49

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

        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

            getLayerCreateCommons = function getLayerCreateCommons(opCode, receivedView, bufferPosition) {
                return {
                    CMD: commands[opCode],
                    SHARE: receivedView.getUint8(bufferPosition + 2),
                    NODE_ID: receivedView.getUint32(bufferPosition + 3, false),
        Severity: Major
        Found in src/layer.js and 1 other location - About 3 hrs to fix
        src/layer.js on lines 55..63

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

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

                destroy: function(nodeId, layerId) {
                    var cmd, view;
                    cmd = command.template(9, 129);
                    view = new DataView(cmd);
                    view.setUint8(3, 0); //share
        Severity: Major
        Found in src/layer.js and 6 other locations - About 2 hrs to fix
        src/node.js on lines 219..227
        src/node.js on lines 263..271
        src/node.js on lines 278..286
        src/node.js on lines 293..301
        src/node.js on lines 308..316
        src/taggroup.js on lines 119..127

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

        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 (opCode > 146) {
                    lo = receivedView.getUint32(bufferPosition + 29, false);
                    hi = receivedView.getUint32(bufferPosition + 33, false);
                    bigNumber = new Int64(hi, lo);
                    result.VALUES[2] = bigNumber.valueOf();
        Severity: Major
        Found in src/layer.js and 1 other location - About 2 hrs to fix
        src/layer.js on lines 170..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 89.

        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 (opCode > 145) {
                    lo = receivedView.getUint32(bufferPosition + 21, false);
                    hi = receivedView.getUint32(bufferPosition + 25, false);
                    bigNumber = new Int64(hi, lo);
                    result.VALUES[1] = bigNumber.valueOf();
        Severity: Major
        Found in src/layer.js and 1 other location - About 2 hrs to fix
        src/layer.js on lines 178..183

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

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

                'UINT16': function setItemsUint16(view, buf_pos, values) {
                    var size = 0;
                    for (var i = 0; i < values.length; i++) {
                        view.setUint16(buf_pos + 2 * i, values[i]);
                        size += 2;
        Severity: Major
        Found in src/layer.js and 3 other locations - About 2 hrs to fix
        src/layer.js on lines 445..452
        src/layer.js on lines 463..470
        src/layer.js on lines 471..478

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

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

                'REAL32': function setItemsReal32(view, buf_pos, values) {
                    var size = 0;
                    for (var i = 0; i < values.length; i++) {
                        view.setFloat32(buf_pos + 4 * i, values[i]);
                        size += 4;
        Severity: Major
        Found in src/layer.js and 3 other locations - About 2 hrs to fix
        src/layer.js on lines 437..444
        src/layer.js on lines 445..452
        src/layer.js on lines 471..478

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

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

                'UINT32': function setItemsUint32(view, buf_pos, values) {
                    var size = 0;
                    for (var i = 0; i < values.length; i++) {
                        view.setUint32(buf_pos + 4 * i, values[i]);
                        size += 4;
        Severity: Major
        Found in src/layer.js and 3 other locations - About 2 hrs to fix
        src/layer.js on lines 437..444
        src/layer.js on lines 463..470
        src/layer.js on lines 471..478

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

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

                'REAL64': function setItemsReal64(view, buf_pos, values) {
                    var size = 0;
                    for (var i = 0; i < values.length; i++) {
                        view.setFloat64(buf_pos + 8 * i, values[i]);
                        size += 8;
        Severity: Major
        Found in src/layer.js and 3 other locations - About 2 hrs to fix
        src/layer.js on lines 437..444
        src/layer.js on lines 445..452
        src/layer.js on lines 463..470

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

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

            data_types = {
                'UINT8': 1,
                'UINT16': 2,
                'UINT32': 3,
                'UINT64': 4,
        Severity: Major
        Found in src/layer.js and 3 other locations - About 35 mins to fix
        src/layer.js on lines 402..410
        src/layer.js on lines 415..423
        src/tag.js on lines 422..430

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

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

            data_type_len = {
                'UINT8': 1,
                'UINT16': 2,
                'UINT32': 4,
                'UINT64': 8,
        Severity: Major
        Found in src/layer.js and 3 other locations - About 35 mins to fix
        src/layer.js on lines 389..397
        src/layer.js on lines 415..423
        src/tag.js on lines 422..430

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

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

            op_codes = {
                'UINT8': 133,
                'UINT16': 137,
                'UINT32': 141,
                'UINT64': 145,
        Severity: Major
        Found in src/layer.js and 3 other locations - About 35 mins to fix
        src/layer.js on lines 389..397
        src/layer.js on lines 402..410
        src/tag.js on lines 422..430

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

        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