orbotix/sphero.js

View on GitHub

Showing 144 of 144 total issues

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

    it("#abortMacro calls #command with params", function() {
      sphero.abortMacro(callback);
      expect(sphero.command).to.be.calledOnce;
      expect(sphero.command)
        .to.be.calledWith(0x02, 0x55, null, callback);
Severity: Major
Found in spec/lib/devices/sphero.spec.js and 24 other locations - About 2 hrs to fix
spec/lib/devices/core.spec.js on lines 20..24
spec/lib/devices/core.spec.js on lines 26..30
spec/lib/devices/core.spec.js on lines 32..36
spec/lib/devices/core.spec.js on lines 45..49
spec/lib/devices/core.spec.js on lines 57..61
spec/lib/devices/core.spec.js on lines 63..67
spec/lib/devices/core.spec.js on lines 82..86
spec/lib/devices/core.spec.js on lines 102..107
spec/lib/devices/core.spec.js on lines 109..114
spec/lib/devices/core.spec.js on lines 116..121
spec/lib/devices/core.spec.js on lines 123..128
spec/lib/devices/sphero.spec.js on lines 43..47
spec/lib/devices/sphero.spec.js on lines 148..153
spec/lib/devices/sphero.spec.js on lines 201..206
spec/lib/devices/sphero.spec.js on lines 263..268
spec/lib/devices/sphero.spec.js on lines 277..282
spec/lib/devices/sphero.spec.js on lines 317..321
spec/lib/devices/sphero.spec.js on lines 323..327
spec/lib/devices/sphero.spec.js on lines 395..399
spec/lib/devices/sphero.spec.js on lines 427..432
spec/lib/devices/sphero.spec.js on lines 441..446
spec/lib/devices/sphero.spec.js on lines 483..488
spec/lib/devices/sphero.spec.js on lines 497..502
spec/lib/devices/sphero.spec.js on lines 504..509

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

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

    it("#ping calls #command with params", function() {
      core.ping(callback);
      expect(core.command).to.be.calledOnce;
      expect(core.command).to.be.calledWith(0x00, 0x01, null, callback);
    });
Severity: Major
Found in spec/lib/devices/core.spec.js and 24 other locations - About 2 hrs to fix
spec/lib/devices/core.spec.js on lines 26..30
spec/lib/devices/core.spec.js on lines 32..36
spec/lib/devices/core.spec.js on lines 45..49
spec/lib/devices/core.spec.js on lines 57..61
spec/lib/devices/core.spec.js on lines 63..67
spec/lib/devices/core.spec.js on lines 82..86
spec/lib/devices/core.spec.js on lines 102..107
spec/lib/devices/core.spec.js on lines 109..114
spec/lib/devices/core.spec.js on lines 116..121
spec/lib/devices/core.spec.js on lines 123..128
spec/lib/devices/sphero.spec.js on lines 43..47
spec/lib/devices/sphero.spec.js on lines 148..153
spec/lib/devices/sphero.spec.js on lines 201..206
spec/lib/devices/sphero.spec.js on lines 263..268
spec/lib/devices/sphero.spec.js on lines 277..282
spec/lib/devices/sphero.spec.js on lines 317..321
spec/lib/devices/sphero.spec.js on lines 323..327
spec/lib/devices/sphero.spec.js on lines 395..399
spec/lib/devices/sphero.spec.js on lines 427..432
spec/lib/devices/sphero.spec.js on lines 434..439
spec/lib/devices/sphero.spec.js on lines 441..446
spec/lib/devices/sphero.spec.js on lines 483..488
spec/lib/devices/sphero.spec.js on lines 497..502
spec/lib/devices/sphero.spec.js on lines 504..509

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

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

    it("#runL1Diags calls #command with params", function() {
      core.runL1Diags(callback);
      expect(core.command).to.be.calledOnce;
      expect(core.command)
        .to.be.calledWith(0x00, 0x40, null, callback);
Severity: Major
Found in spec/lib/devices/core.spec.js and 24 other locations - About 2 hrs to fix
spec/lib/devices/core.spec.js on lines 20..24
spec/lib/devices/core.spec.js on lines 26..30
spec/lib/devices/core.spec.js on lines 32..36
spec/lib/devices/core.spec.js on lines 45..49
spec/lib/devices/core.spec.js on lines 57..61
spec/lib/devices/core.spec.js on lines 63..67
spec/lib/devices/core.spec.js on lines 82..86
spec/lib/devices/core.spec.js on lines 102..107
spec/lib/devices/core.spec.js on lines 116..121
spec/lib/devices/core.spec.js on lines 123..128
spec/lib/devices/sphero.spec.js on lines 43..47
spec/lib/devices/sphero.spec.js on lines 148..153
spec/lib/devices/sphero.spec.js on lines 201..206
spec/lib/devices/sphero.spec.js on lines 263..268
spec/lib/devices/sphero.spec.js on lines 277..282
spec/lib/devices/sphero.spec.js on lines 317..321
spec/lib/devices/sphero.spec.js on lines 323..327
spec/lib/devices/sphero.spec.js on lines 395..399
spec/lib/devices/sphero.spec.js on lines 427..432
spec/lib/devices/sphero.spec.js on lines 434..439
spec/lib/devices/sphero.spec.js on lines 441..446
spec/lib/devices/sphero.spec.js on lines 483..488
spec/lib/devices/sphero.spec.js on lines 497..502
spec/lib/devices/sphero.spec.js on lines 504..509

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

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

    it("#getTempOptionFlags calls #command with params", function() {
      sphero.getTempOptionFlags(callback);
      expect(sphero.command).to.be.calledOnce;
      expect(sphero.command)
        .to.be.calledWith(0x02, 0x38, null, callback);
Severity: Major
Found in spec/lib/devices/sphero.spec.js and 24 other locations - About 2 hrs to fix
spec/lib/devices/core.spec.js on lines 20..24
spec/lib/devices/core.spec.js on lines 26..30
spec/lib/devices/core.spec.js on lines 32..36
spec/lib/devices/core.spec.js on lines 45..49
spec/lib/devices/core.spec.js on lines 57..61
spec/lib/devices/core.spec.js on lines 63..67
spec/lib/devices/core.spec.js on lines 82..86
spec/lib/devices/core.spec.js on lines 102..107
spec/lib/devices/core.spec.js on lines 109..114
spec/lib/devices/core.spec.js on lines 116..121
spec/lib/devices/core.spec.js on lines 123..128
spec/lib/devices/sphero.spec.js on lines 43..47
spec/lib/devices/sphero.spec.js on lines 148..153
spec/lib/devices/sphero.spec.js on lines 201..206
spec/lib/devices/sphero.spec.js on lines 263..268
spec/lib/devices/sphero.spec.js on lines 317..321
spec/lib/devices/sphero.spec.js on lines 323..327
spec/lib/devices/sphero.spec.js on lines 395..399
spec/lib/devices/sphero.spec.js on lines 427..432
spec/lib/devices/sphero.spec.js on lines 434..439
spec/lib/devices/sphero.spec.js on lines 441..446
spec/lib/devices/sphero.spec.js on lines 483..488
spec/lib/devices/sphero.spec.js on lines 497..502
spec/lib/devices/sphero.spec.js on lines 504..509

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

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

    it("#abortOrbBasicProgram calls #command with params", function() {
      sphero.abortOrbBasicProgram(callback);
      expect(sphero.command).to.be.calledOnce;
      expect(sphero.command)
        .to.be.calledWith(0x02, 0x63, null, callback);
Severity: Major
Found in spec/lib/devices/sphero.spec.js and 24 other locations - About 2 hrs to fix
spec/lib/devices/core.spec.js on lines 20..24
spec/lib/devices/core.spec.js on lines 26..30
spec/lib/devices/core.spec.js on lines 32..36
spec/lib/devices/core.spec.js on lines 45..49
spec/lib/devices/core.spec.js on lines 57..61
spec/lib/devices/core.spec.js on lines 63..67
spec/lib/devices/core.spec.js on lines 82..86
spec/lib/devices/core.spec.js on lines 102..107
spec/lib/devices/core.spec.js on lines 109..114
spec/lib/devices/core.spec.js on lines 116..121
spec/lib/devices/core.spec.js on lines 123..128
spec/lib/devices/sphero.spec.js on lines 43..47
spec/lib/devices/sphero.spec.js on lines 148..153
spec/lib/devices/sphero.spec.js on lines 201..206
spec/lib/devices/sphero.spec.js on lines 263..268
spec/lib/devices/sphero.spec.js on lines 277..282
spec/lib/devices/sphero.spec.js on lines 317..321
spec/lib/devices/sphero.spec.js on lines 323..327
spec/lib/devices/sphero.spec.js on lines 395..399
spec/lib/devices/sphero.spec.js on lines 427..432
spec/lib/devices/sphero.spec.js on lines 434..439
spec/lib/devices/sphero.spec.js on lines 441..446
spec/lib/devices/sphero.spec.js on lines 497..502
spec/lib/devices/sphero.spec.js on lines 504..509

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

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

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

        it("calls @packet#create with params", function() {
          expect(sphero.packet.create).to.be.calledOnce;
          expect(sphero.packet.create).to.be.calledWith(opts);
        });
    Severity: Major
    Found in spec/lib/sphero.spec.js and 2 other locations - About 1 hr to fix
    spec/lib/sphero.spec.js on lines 136..139
    spec/lib/sphero.spec.js on lines 338..341

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

    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("calls @packet.parse passing the buffer", function() {
          expect(sphero.packet.parse).to.be.calledOnce;
          expect(sphero.packet.parse).to.be.calledWith(buffer);
        });
    Severity: Major
    Found in spec/lib/sphero.spec.js and 2 other locations - About 1 hr to fix
    spec/lib/sphero.spec.js on lines 328..331
    spec/lib/sphero.spec.js on lines 338..341

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

    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("converts to an RGB object at +20%", function() {
            device.color(0x6699cc, .2);
            var color = { red: 0x7a, green: 0xb8, blue: 0xf5 };
            expect(rgb).to.be.calledWith(color);
          });
    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 99..103

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

    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("converts to an RGB object at normal %", function() {
            device.color(0x6699cc, 0);
            var color = { red: 0x66, green: 0x99, blue: 0xcc };
            expect(rgb).to.be.calledWith(color);
          });
    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 87..91

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

    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("calls @connection#write with param commandPacket", function() {
          expect(sphero.connection.write).to.be.calledOnce;
          expect(sphero.connection.write).to.be.calledWith(cmdByteArray);
        });
    Severity: Major
    Found in spec/lib/sphero.spec.js and 2 other locations - About 1 hr to fix
    spec/lib/sphero.spec.js on lines 136..139
    spec/lib/sphero.spec.js on lines 328..331

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

    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("converts 'FF00FF' to an RGB object", function() {
            device.color("FF0000");
            var color = { red: 255, blue: 0, green: 0 };
            expect(rgb).to.be.calledWith(color);
          });
    Severity: Major
    Found in spec/lib/devices/custom.spec.js and 2 other locations - About 1 hr to fix
    spec/lib/devices/custom.spec.js on lines 37..41
    spec/lib/devices/custom.spec.js on lines 57..61

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

    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("converts to an RGB object", function() {
            device.color("azure");
            var color = { red: 240, blue: 255, green: 255 };
            expect(rgb).to.be.calledWith(color);
          });
    Severity: Major
    Found in spec/lib/devices/custom.spec.js and 2 other locations - About 1 hr to fix
    spec/lib/devices/custom.spec.js on lines 37..41
    spec/lib/devices/custom.spec.js on lines 43..47

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

    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("converts to an RGB object", function() {
            device.color("#FF0000");
            var color = { red: 255, blue: 0, green: 0 };
            expect(rgb).to.be.calledWith(color);
          });
    Severity: Major
    Found in spec/lib/devices/custom.spec.js and 2 other locations - About 1 hr to fix
    spec/lib/devices/custom.spec.js on lines 43..47
    spec/lib/devices/custom.spec.js on lines 57..61

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

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

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

          it("returns 0 when DS valid and field not in mask1|2", function() {
            packet._checkDSBit(
              { mask1: 0x0FFF },
              { bitmask: 0x1000, maskField: "mask1"
            });
      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 618..624

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

      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("returns 1 when DS valid and field in mask1|2", function() {
            packet._checkDSBit(
              { mask1: 0xFFFF },
              { bitmask: 0x1000, maskField: "mask1"
            });
      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 626..632

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

      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("adds core device methods", function() {
            expect(sphero.ping).to.be.a("function");
            expect(sphero.setDeviceName).to.be.a("function");
          });
      Severity: Major
      Found in spec/lib/sphero.spec.js and 1 other location - About 1 hr to fix
      spec/lib/sphero.spec.js on lines 45..48

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

      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("adds sphero device methods", function() {
            expect(sphero.setHeading).to.be.a("function");
            expect(sphero.setRgbLed).to.be.a("function");
          });
      Severity: Major
      Found in spec/lib/sphero.spec.js and 1 other location - About 1 hr to fix
      spec/lib/sphero.spec.js on lines 40..43

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

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

      Severity
      Category
      Status
      Source
      Language