Memristor-Robotics/mep-master

View on GitHub
src/drivers/dynamixel/DynamixelDriver.js

Summary

Maintainability
D
2 days
Test Coverage

DynamixelDriver has 72 functions (exceeds 20 allowed). Consider refactoring.
Open

class DynamixelDriver {
    static get AX_MODEL_NUMBER_L() { return 0; }
    static get AX_MODEL_NUMBER_H() { return 1; }
    static get AX_VERSION() { return 2; }
    static get AX_SERVO_ID() { return 3; }
Severity: Major
Found in src/drivers/dynamixel/DynamixelDriver.js - About 1 day to fix

    File DynamixelDriver.js has 291 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    'use strict';
    
    /** @namespace drivers.dynamixel */
    const TaskError = Mep.require('strategy/TaskError');
    
    
    Severity: Minor
    Found in src/drivers/dynamixel/DynamixelDriver.js - About 3 hrs to fix

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

          go(position, config) {
              let c = Object.assign({
                  pollingPeriod: 300,
                  tolerance: 35,
                  timeout: 3000,
      Severity: Minor
      Found in src/drivers/dynamixel/DynamixelDriver.js - About 1 hr to fix

        Function _read has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            _read(address, word = false) {
                let ax = this;
                let buffer = Buffer.from([
                    this.config.id,     // AX12 ID
                    0x04,               // Length
        Severity: Minor
        Found in src/drivers/dynamixel/DynamixelDriver.js - About 1 hr to fix

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

              _onDataReceived(data) {
                  if (data.readUInt8(0) === (this.config.id | 0)) {
          
                      // Length === 1 means there is an error in communication (UART, Servo <--> AVR)
                      if (data.length === 2) {
          Severity: Minor
          Found in src/drivers/dynamixel/DynamixelDriver.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

          There are no issues that match your filters.

          Category
          Status