orbotix/sphero.js

View on GitHub

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

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

            describe("Core Commands", function() {
              it("is an object", function() {
                expect(commands).to.be.an("object");
              });
            
            
            Severity: Major
            Found in spec/lib/commands/core.spec.js and 1 other location - About 4 hrs to fix
            spec/lib/commands/sphero.spec.js on lines 5..18

            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

            describe("Sphero Commands", function() {
              it("is an object", function() {
                expect(commands).to.be.an("object");
              });
            
            
            Severity: Major
            Found in spec/lib/commands/sphero.spec.js and 1 other location - About 4 hrs to fix
            spec/lib/commands/core.spec.js on lines 5..18

            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

            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

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

                  it("#setRgbLed calls #command with params", function() {
                    var opts = {
                      red: 0xFF,
                      green: 0xFE,
                      blue: 0xFD,
              Severity: Major
              Found in spec/lib/devices/sphero.spec.js and 1 other location - About 4 hrs to fix
              spec/lib/devices/sphero.spec.js on lines 229..247

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

              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

                  it("#setRawMotors calls #command with params", function() {
                    var opts = {
                      lmode: 0x03,
                      lpower: 0xFE,
                      rmode: 0x02,
              Severity: Major
              Found in spec/lib/devices/sphero.spec.js and 1 other location - About 4 hrs to fix
              spec/lib/devices/sphero.spec.js on lines 174..192

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

              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

                  it("#streamGyroscope calls #streamData with", function() {
                    var opts = {
                      event: "gyroscope",
                      mask1: 0x00001C00,
                      fields: ["xGyro", "yGyro", "zGyro"],
              Severity: Major
              Found in spec/lib/devices/custom.spec.js and 2 other locations - About 3 hrs to fix
              spec/lib/devices/custom.spec.js on lines 302..315
              spec/lib/devices/custom.spec.js on lines 317..330

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

              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

                    it("emits a collision event", function() {
                      expect(sphero.emit).to.be.calledWith("collision", {
                        axis: 1,
                        cid: 18,
                        did: 2,
              Severity: Major
              Found in spec/lib/sphero.spec.js and 1 other location - About 3 hrs to fix
              spec/lib/sphero.spec.js on lines 170..187

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

              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

                    it("emits an async event", function() {
                      expect(sphero.emit).to.be.calledWith("async", {
                        axis: 1,
                        cid: 18,
                        did: 2,
              Severity: Major
              Found in spec/lib/sphero.spec.js and 1 other location - About 3 hrs to fix
              spec/lib/sphero.spec.js on lines 189..206

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

              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

                  it("#streamImuAngles calls #streamData with", function() {
                    var opts = {
                      event: "imuAngles",
                      mask1: 0x00070000,
                      fields: ["pitchAngle", "rollAngle", "yawAngle"],
              Severity: Major
              Found in spec/lib/devices/custom.spec.js and 2 other locations - About 3 hrs to fix
              spec/lib/devices/custom.spec.js on lines 317..330
              spec/lib/devices/custom.spec.js on lines 332..345

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

              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

                  it("#streamAccelerometer calls #streamData with", function() {
                    var opts = {
                      event: "accelerometer",
                      mask1: 0x0000E000,
                      fields: ["xAccel", "yAccel", "zAccel"],
              Severity: Major
              Found in spec/lib/devices/custom.spec.js and 2 other locations - About 3 hrs to fix
              spec/lib/devices/custom.spec.js on lines 302..315
              spec/lib/devices/custom.spec.js on lines 332..345

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

              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

                  it("#streamOdometer calls #streamData with", function() {
                    var opts = {
                      event: "odometer",
                      mask2: 0x0C000000,
                      fields: ["xOdometer", "yOdometer"],
              Severity: Major
              Found in spec/lib/devices/custom.spec.js and 2 other locations - About 3 hrs to fix
              spec/lib/devices/custom.spec.js on lines 287..300
              spec/lib/devices/custom.spec.js on lines 362..375

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

              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

                  it("#streamVelocity calls #streamData with", function() {
                    var opts = {
                      event: "velocity",
                      mask2: 0x01800000,
                      fields: ["xVelocity", "yVelocity"],
              Severity: Major
              Found in spec/lib/devices/custom.spec.js and 2 other locations - About 3 hrs to fix
              spec/lib/devices/custom.spec.js on lines 272..285
              spec/lib/devices/custom.spec.js on lines 362..375

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

              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

                  it("#streamMotorsBackEmf calls #streamData with", function() {
                    var opts = {
                      event: "motorsBackEmf",
                      mask1: 0x00000060,
                      fields: ["rMotorBackEmf", "lMotorBackEmf"],
              Severity: Major
              Found in spec/lib/devices/custom.spec.js and 2 other locations - About 3 hrs to fix
              spec/lib/devices/custom.spec.js on lines 272..285
              spec/lib/devices/custom.spec.js on lines 287..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 111.

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

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

                      it("res should be a packet obj", function() {
                        expect(res).to.not.be.null;
                        expect(res).to.be.eql({
                          sop1: 0xFF,
                          sop2: 0xFF,
              Severity: Major
              Found in spec/lib/packet.spec.js and 1 other location - About 3 hrs to fix
              spec/lib/packet.spec.js on lines 292..303

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

              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