orbotix/sphero.js

View on GitHub

Showing 144 of 144 total issues

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

      beforeEach(function() {
        data = [0x05, 0x04, 0x03, 0x02, 0x01];
        buffer = new Buffer([0xFF, 0xFE, 0x0A, 0x00, 0x06].concat(data, 0xE0));

        res = packet.parse(buffer);
Severity: Major
Found in spec/lib/packet.spec.js and 1 other location - About 1 hr to fix
spec/lib/packet.spec.js on lines 105..110

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

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

      beforeEach(function() {
        data = [0x05, 0x04, 0x03, 0x02, 0x01];
        buffer = new Buffer([0xFF, 0xFF, 0x00, 0x02, 0x06].concat(data, 0xE8));

        res = packet.parse(buffer);
Severity: Major
Found in spec/lib/packet.spec.js and 1 other location - About 1 hr to fix
spec/lib/packet.spec.js on lines 314..319

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

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

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

            it("#_checkSOPs with SOP2 0xFF should return 'sync'", function() {
              var buffer = [0xFF, 0xFF, 0x00, 0x02, 0x01, 0xFC],
                  check = packet._checkSOPs(buffer);
              expect(check).to.be.eql("sync");
            });
        Severity: Major
        Found in spec/lib/packet.spec.js and 1 other location - About 1 hr to fix
        spec/lib/packet.spec.js on lines 567..571

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

        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("#_checkSOPs with SOP2 0xFE should return 'async'", function() {
              var buffer = [0xFF, 0xFC, 0x00, 0x02, 0x01, 0xFC],
                  check = packet._checkSOPs(buffer);
              expect(check).to.be.eql(false);
            });
        Severity: Major
        Found in spec/lib/packet.spec.js and 1 other location - About 1 hr to fix
        spec/lib/packet.spec.js on lines 591..595

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

        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

          device.streamGyroscope = function(sps, remove) {
            return device.streamData({
              event: "gyroscope",
              mask1: 0x00001C00,
              fields: ["xGyro", "yGyro", "zGyro"],
        Severity: Major
        Found in lib/devices/custom.js and 2 other locations - About 1 hr to fix
        lib/devices/custom.js on lines 447..455
        lib/devices/custom.js on lines 476..484

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

        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

          device.streamImuAngles = function(sps, remove) {
            return device.streamData({
              event: "imuAngles",
              mask1: 0x00070000,
              fields: ["pitchAngle", "rollAngle", "yawAngle"],
        Severity: Major
        Found in lib/devices/custom.js and 2 other locations - About 1 hr to fix
        lib/devices/custom.js on lines 476..484
        lib/devices/custom.js on lines 505..513

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

        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("#_checkSOPs with SOP2 0xFE should return 'async'", function() {
              var buffer = [0xFF, 0xFE, 0x00, 0x02, 0x01, 0xFC],
                  check = packet._checkSOPs(buffer);
              expect(check).to.be.eql("async");
            });
        Severity: Major
        Found in spec/lib/packet.spec.js and 1 other location - About 1 hr to fix
        spec/lib/packet.spec.js on lines 561..565

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

        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("#_checkMinSize should return true when size >= min", function() {
              var buffer = [0xFF, 0xFF, 0x00, 0x02, 0x01, 0xFC],
                  check = packet._checkMinSize(buffer);
              expect(check).to.be.eql(true);
            });
        Severity: Major
        Found in spec/lib/packet.spec.js and 1 other location - About 1 hr to fix
        spec/lib/packet.spec.js on lines 573..577

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

        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

          device.streamAccelerometer = function(sps, remove) {
            return device.streamData({
              event: "accelerometer",
              mask1: 0x0000E000,
              fields: ["xAccel", "yAccel", "zAccel"],
        Severity: Major
        Found in lib/devices/custom.js and 2 other locations - About 1 hr to fix
        lib/devices/custom.js on lines 447..455
        lib/devices/custom.js on lines 505..513

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

        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

          device.streamOdometer = function(sps, remove) {
            return device.streamData({
              event: "odometer",
              mask2: 0x0C000000,
              fields: ["xOdometer", "yOdometer"],
        Severity: Major
        Found in lib/devices/custom.js and 2 other locations - About 1 hr to fix
        lib/devices/custom.js on lines 391..399
        lib/devices/custom.js on lines 533..541

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

        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

          device.streamMotorsBackEmf = function(sps, remove) {
            return device.streamData({
              event: "motorsBackEmf",
              mask1: 0x00000060,
              fields: ["rMotorBackEmf", "lMotorBackEmf"],
        Severity: Major
        Found in lib/devices/custom.js and 2 other locations - About 1 hr to fix
        lib/devices/custom.js on lines 363..371
        lib/devices/custom.js on lines 391..399

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

        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

          device.streamVelocity = function(sps, remove) {
            return device.streamData({
              event: "velocity",
              mask2: 0x01800000,
              fields: ["xVelocity", "yVelocity"],
        Severity: Major
        Found in lib/devices/custom.js and 2 other locations - About 1 hr to fix
        lib/devices/custom.js on lines 363..371
        lib/devices/custom.js on lines 533..541

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

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

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

                  expect(device.configureCollisions).to.be.calledWith({
                    meth: 0x01,
                    xt: 0x20,
                    yt: 0x20,
                    xs: 0x20,
            Severity: Major
            Found in spec/lib/devices/custom.spec.js and 1 other location - About 1 hr to fix
            spec/lib/devices/custom.spec.js on lines 144..151

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

            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

                  expect(device.configureCollisions).to.be.calledWith({
                    meth: 0x01,
                    xt: 0x40,
                    yt: 0x40,
                    xs: 0x50,
            Severity: Major
            Found in spec/lib/devices/custom.spec.js and 1 other location - About 1 hr to fix
            spec/lib/devices/custom.spec.js on lines 156..163

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

            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