btelman96/letsrobot-android

View on GitHub

Showing 11 of 66 total issues

Method findSerialPortDevice has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private void findSerialPortDevice() {
        // This snippet will try to open the first encountered usb device connected, excluding usb root hubs
        HashMap<String, UsbDevice> usbDevices = usbManager.getDeviceList();
        if (!usbDevices.isEmpty()) {
            boolean keep = true;

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

Method record has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private void record() {
        Log.v(LOG_TAG, "Start");
        android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_AUDIO);

        // buffer size in bytes

    Method onReceive has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            @Override
            public void onReceive(Context arg0, Intent arg1) {
                if (arg1.getAction().equals(ACTION_USB_PERMISSION)) {
                    Log.d("USB", "ACTION_USB_PERMISSION");
                    boolean granted = arg1.getExtras().getBoolean(UsbManager.EXTRA_PERMISSION_GRANTED);

    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

    Method run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            @Override
            public void run() {
                serialPort = UsbSerialDevice.createUsbSerialDevice(device, connection);
                if (serialPort != null) {
                    if (serialPort.open()) {

      Method onReceive has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              @Override
              public void onReceive(Context arg0, Intent arg1) {
                  if (arg1.getAction().equals(ACTION_USB_PERMISSION)) {
                      Log.d("USB", "ACTION_USB_PERMISSION");
                      boolean granted = arg1.getExtras().getBoolean(UsbManager.EXTRA_PERMISSION_GRANTED);

        Method findSerialPortDevice has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private void findSerialPortDevice() {
                // This snippet will try to open the first encountered usb device connected, excluding usb root hubs
                HashMap<String, UsbDevice> usbDevices = usbManager.getDeviceList();
                if (!usbDevices.isEmpty()) {
                    boolean keep = true;

          Method createProgram has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  private int createProgram(String vertexSource, String fragmentSource) throws SurfaceTextureException {
                      int vertexShader = loadShader(GLES20.GL_VERTEX_SHADER, vertexSource);
                      if (vertexShader == 0) {
                          return 0;
                      }

            Method surfaceCreated has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    public void surfaceCreated() throws SurfaceTextureException {
            
                        mProgram = createProgram(VERTEX_SHADER, FRAGMENT_SHADER);
                        if (mProgram == 0) {
                            throw new SurfaceTextureException("failed creating program");

              Method run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                      @Override
                      public void run() {
                          serialPort = UsbSerialDevice.createUsbSerialDevice(device, connection);
                          if (serialPort != null) {
                              if (serialPort.open()) {

              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

              Method run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  @Override
                  public void run() {
                      while(mRunning) {
                          synchronized(mServiceSyncToken) {
                              if(mWebcamService == null) {

              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

              Method map has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public static float map(float input, float inMin, float inMax, float outMin, float outMax, float multiplier) {
                Severity
                Category
                Status
                Source
                Language