orbotix/sphero.js

View on GitHub

Showing 25 of 144 total issues

File packet.spec.js has 643 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"use strict";

var Packet = lib("packet"),
    utils = lib("utils");

Severity: Major
Found in spec/lib/packet.spec.js - About 1 day to fix

    Function sphero has 246 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function sphero(device) {
      // Sphero Virtual Device Address = 0x02
      var command = device.command.bind(device, 0x02);
    
      /**
    Severity: Major
    Found in lib/devices/sphero.js - About 1 day to fix

      Function custom has 198 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports = function custom(device) {
        function mergeMasks(id, mask, remove) {
          if (remove) {
            mask = utils.xor32bit(mask);
            return device.ds[id] & mask;
      Severity: Major
      Found in lib/devices/custom.js - About 7 hrs to fix

        File sphero.spec.js has 440 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        "use strict";
        
        var Sphero = lib("sphero");
        
        var Packet = lib("packet"),
        Severity: Minor
        Found in spec/lib/sphero.spec.js - About 6 hrs to fix

          File sphero.spec.js has 439 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          "use strict";
          
          var mutator = lib("devices/sphero");
          
          describe("Sphero", function() {
          Severity: Minor
          Found in spec/lib/devices/sphero.spec.js - About 6 hrs to fix

            File custom.spec.js has 346 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            "use strict";
            
            var mutator = lib("devices/custom"),
                utils = lib("utils");
            
            
            Severity: Minor
            Found in spec/lib/devices/custom.spec.js - About 4 hrs to fix

              Function custom has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
              Open

              module.exports = function custom(device) {
                function mergeMasks(id, mask, remove) {
                  if (remove) {
                    mask = utils.xor32bit(mask);
                    return device.ds[id] & mask;
              Severity: Minor
              Found in lib/devices/custom.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

              Function core has 73 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports = function core(device) {
                // Core Virtual Device Address = 0x00
                var command = device.command.bind(device, 0x00);
              
                /**
              Severity: Major
              Found in lib/devices/core.js - About 2 hrs to fix

                File packet.js has 281 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                "use strict";
                
                var inherits = require("util").inherits,
                    EventEmitter = require("events").EventEmitter;
                
                
                Severity: Minor
                Found in lib/packet.js - About 2 hrs to fix

                  File ble.js has 263 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  "use strict";
                  
                  var util = require("util"),
                      EventEmitter = require("events").EventEmitter;
                  
                  
                  Severity: Minor
                  Found in lib/adaptors/ble.js - About 2 hrs to fix

                    File sphero.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    "use strict";
                    
                    var utils = require("../utils"),
                        commands = require("../commands/sphero");
                    
                    
                    Severity: Minor
                    Found in lib/devices/sphero.js - About 2 hrs to fix

                      Function connect has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      Sphero.prototype.connect = function(callback) {
                        var self = this,
                            connection = this.connection,
                            packet = this.packet;
                      
                      
                      Severity: Minor
                      Found in lib/sphero.js - About 1 hr to fix

                        Function connect has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                        Sphero.prototype.connect = function(callback) {
                          var self = this,
                              connection = this.connection,
                              packet = this.packet;
                        
                        
                        Severity: Minor
                        Found in lib/sphero.js - About 1 hr to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Function _parseField has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        Packet.prototype._parseField = function(field, data, pData) {
                          var pField;
                          var width;
                        
                          data = data.slice(field.from, field.to);
                        Severity: Minor
                        Found in lib/packet.js - About 1 hr to fix

                          Function _parseData has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          Packet.prototype._parseData = function(parser, payload, ds) {
                            var data = payload.data,
                                pData, fields, field;
                          
                          
                          
                          Severity: Minor
                          Found in lib/packet.js - About 1 hr to fix

                            Function color has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              device.color = function(color, luminance, callback) {
                                var cb = callback;
                                switch (typeof color) {
                                  case "number":
                                    color = hexToRgb(color);
                            Severity: Minor
                            Found in lib/devices/custom.js - About 1 hr to fix

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

                                var p = new Promise(function (resolve, reject) {
                                  connection.on("open", function() {
                                    emit("open");
                                  });
                                  connection.on("close", emit("close"));
                              Severity: Minor
                              Found in lib/sphero.js - About 1 hr to fix

                                Function exports has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                module.exports = function(grunt) {
                                  grunt.registerTask("default", ["lint", "test"]);
                                
                                  grunt.registerTask("lint", "Lints code with ESLint", function() {
                                    var lint = new ESLint(),
                                Severity: Minor
                                Found in Gruntfile.js - About 1 hr to fix

                                  Function _parseData has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  Packet.prototype._parseData = function(parser, payload, ds) {
                                    var data = payload.data,
                                        pData, fields, field;
                                  
                                  
                                  
                                  Severity: Minor
                                  Found in lib/packet.js - About 1 hr to fix

                                  Cognitive Complexity

                                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                  A method's cognitive complexity is based on a few simple rules:

                                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                  • Code is considered more complex for each "break in the linear flow of the code"
                                  • Code is considered more complex when "flow breaking structures are nested"

                                  Further reading

                                  Function parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  Packet.prototype.parse = function(buffer) {
                                    if (this.partialBuffer.length > 0) {
                                      buffer = Buffer.concat(
                                        [this.partialBuffer, buffer],
                                        buffer.length + this.partialBuffer.length
                                  Severity: Minor
                                  Found in lib/packet.js - About 45 mins 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

                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language