orbotix/sphero.js

View on GitHub
lib/packet.js

Summary

Maintainability
C
1 day
Test Coverage

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

"use strict";

var inherits = require("util").inherits,
    EventEmitter = require("events").EventEmitter;

Severity: Minor
Found in lib/packet.js - About 2 hrs to fix

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

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

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

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

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

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

        Cognitive Complexity

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

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

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

        Further reading

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

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

        Cognitive Complexity

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

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

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

        Further reading

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

          There are no issues that match your filters.

          Category
          Status