orbotix/sphero.js

View on GitHub

Showing 25 of 144 total issues

Function _incParserIndex has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

Packet.prototype._incParserIndex = function(i, fields, data, dsFlag, dsIndex) {
Severity: Minor
Found in lib/packet.js - About 35 mins to fix

    Function _parseField has a Cognitive Complexity of 7 (exceeds 5 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 35 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function sphero has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

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

    Cognitive Complexity

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

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

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

    Further reading

    Function _queuePromise has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Sphero.prototype._queuePromise = function(cmdPacket, resolve, reject) {
      var seq = cmdPacket[4];
    
      var handler = function(err, packet) {
        clearTimeout(this.responseQueue[seq].timeoutId);
    Severity: Minor
    Found in lib/sphero.js - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    Packet.prototype.create = function(opts) {
      opts = opts || {};
    
      var sop1 = (opts.sop1 === undefined) ? FIELDS.sop1.hex : opts.sop1,
          sop2 = (opts.sop2 === undefined) ? FIELDS.sop2.sync : opts.sop2,
    Severity: Minor
    Found in lib/packet.js - About 25 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

    Severity
    Category
    Status
    Source
    Language