oddbit/sonosjs

View on GitHub
src/net/environments/chrome.js

Summary

Maintainability
F
4 days
Test Coverage

Function httpServer has 164 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function httpServer() {
            var that = {};
            var serverSocketRegistry = {};
            var httpRequests = {};

Severity: Major
Found in src/net/environments/chrome.js - About 6 hrs to fix

File chrome.js has 363 lines of code (exceeds 250 allowed). Consider refactoring.
Open

define(function (require) {
        "use strict";

        var convert = require("net/convert");
        var httpResponse = require("net/http/response");
Severity: Minor
Found in src/net/environments/chrome.js - About 4 hrs to fix

Function tcp has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function tcp() {
            var that = {};
            var socketRegistry = {};

            /**
Severity: Major
Found in src/net/environments/chrome.js - About 3 hrs to fix

Function udp has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function udp() {
            var that = {};
            var socketRegistry = {};

            /**
Severity: Major
Found in src/net/environments/chrome.js - About 3 hrs to fix

Function onReceive has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            function onReceive(info) {
                var clientSocket = info.socketId;

                if (!httpRequests.hasOwnProperty(clientSocket)) {
                    return;
Severity: Minor
Found in src/net/environments/chrome.js - About 1 hr to fix

Function open has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

            that.open = function (options, callback) {
                options = options || {};

                var ip = options.remoteIp;
                var port = Number(options.remotePort);
Severity: Minor
Found in src/net/environments/chrome.js - About 1 hr to fix

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

            that.close = function (socketId) {
                if (socketRegistry.hasOwnProperty(socketId)) {
                    delete(socketRegistry[socketId]);
                    chrome.sockets.udp.close(socketId, function () {
                        console.debug("Closed UDP  socket '%d'", socketId);
Severity: Major
Found in src/net/environments/chrome.js and 2 other locations - About 2 hrs to fix
src/net/environments/chrome.js on lines 80..87
src/net/environments/chrome.js on lines 387..394

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

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

            that.close = function (socketId) {
                if (socketRegistry.hasOwnProperty(socketId)) {
                    delete(socketRegistry[socketId]);
                    chrome.sockets.tcp.close(socketId, function () {
                        console.debug("Closed TCP socket '%d'", socketId);
Severity: Major
Found in src/net/environments/chrome.js and 2 other locations - About 2 hrs to fix
src/net/environments/chrome.js on lines 203..210
src/net/environments/chrome.js on lines 387..394

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

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

            that.destroy = function (socketId) {
                if (serverSocketRegistry.hasOwnProperty(socketId)) {
                    delete(serverSocketRegistry[socketId]);
                    chrome.sockets.tcpServer.close(socketId, function () {
                        console.debug("Shut down the HTTP server with socket id: %d", socketId);
Severity: Major
Found in src/net/environments/chrome.js and 2 other locations - About 2 hrs to fix
src/net/environments/chrome.js on lines 80..87
src/net/environments/chrome.js on lines 203..210

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

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

            function onReceiveError(info) {
                if (!socketRegistry.hasOwnProperty(info.socketId)) {
                    return;
                }

Severity: Major
Found in src/net/environments/chrome.js and 1 other location - About 2 hrs to fix
src/net/environments/chrome.js on lines 125..132

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

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

            function onReceiveError(info) {
                if (!socketRegistry.hasOwnProperty(info.socketId)) {
                    return;
                }

Severity: Major
Found in src/net/environments/chrome.js and 1 other location - About 2 hrs to fix
src/net/environments/chrome.js on lines 271..278

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

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

            (function init() {
                console.debug("Initializing Chrome TCP sockets module.");
                chrome.sockets.tcp.onReceive.addListener(onReceive);
                chrome.sockets.tcp.onReceiveError.addListener(onReceiveError);
            }());
Severity: Major
Found in src/net/environments/chrome.js and 1 other location - About 1 hr to fix
src/net/environments/chrome.js on lines 285..289

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

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

            (function init() {
                console.debug("Initializing Chrome UDP sockets module.");
                chrome.sockets.udp.onReceive.addListener(onReceive);
                chrome.sockets.udp.onReceiveError.addListener(onReceiveError);
            }());
Severity: Major
Found in src/net/environments/chrome.js and 1 other location - About 1 hr to fix
src/net/environments/chrome.js on lines 139..143

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

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

            that.stop = function (socketId) {
                console.debug("Stopping HTTP server (socket: %d)", socketId);
                chrome.sockets.tcpServer.setPaused(socketId, true);
            };
Severity: Minor
Found in src/net/environments/chrome.js and 1 other location - About 55 mins to fix
src/net/environments/chrome.js on lines 366..369

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

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

            that.start = function (socketId) {
                console.debug("Starting HTTP server (socket: %d)", socketId);
                chrome.sockets.tcpServer.setPaused(socketId, false);
            };
Severity: Minor
Found in src/net/environments/chrome.js and 1 other location - About 55 mins to fix
src/net/environments/chrome.js on lines 377..380

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

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

                if (socketInfo.consumer) {
                    socketInfo.consumer({
                        socketId: info.socketId,
                        data: convert.fromBuffer(info.data)
                    });
Severity: Minor
Found in src/net/environments/chrome.js and 1 other location - About 40 mins to fix
src/net/environments/chrome.js on lines 263..268

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

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

                if (socketInfo.consumer) {
                    socketInfo.consumer({
                        socketId: info.socketId,
                        data: convert.fromBuffer(info.data)
                    });
Severity: Minor
Found in src/net/environments/chrome.js and 1 other location - About 40 mins to fix
src/net/environments/chrome.js on lines 114..119

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

There are no issues that match your filters.

Category
Status