btelman96/letsrobot-android

View on GitHub

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

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

package tv.letsrobot.android.api.settings

import android.content.SharedPreferences

/**
letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/settings/IntPreference.kt on lines 1..13
letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/settings/StringPreference.kt on lines 1..14

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

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

package tv.letsrobot.android.api.settings

import android.content.SharedPreferences

/**
letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/settings/BooleanPreference.kt on lines 1..13
letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/settings/IntPreference.kt on lines 1..13

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

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

package tv.letsrobot.android.api.settings

import android.content.SharedPreferences

/**
letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/settings/BooleanPreference.kt on lines 1..13
letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/settings/StringPreference.kt on lines 1..14

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

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

    /**
     * Calls api.getServiceBoundObserver().observe(activity, observer) in ILetsRobotControl
     * @see ILetsRobotControl.getServiceBoundObserver(activity, observer)
     */
    fun setServiceBoundListener(activity: FragmentActivity, observer : (Operation) -> Unit){
letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/viewModels/LetsRobotViewModel.kt on lines 23..32

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

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

    /**
     * Calls api.getServiceStateObserver().observe(activity, observer) in ILetsRobotControl
     * @see ILetsRobotControl.getServiceStateObserver(activity, observer)
     */
    fun setStatusObserver(activity: FragmentActivity, observer : (Operation) -> Unit){
letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/viewModels/LetsRobotViewModel.kt on lines 34..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 116.

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

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");

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

                  @Suppress("UNCHECKED_CAST")
                  val protocol = Preference.fromEnumId(preferenceManager, context,
                          ProtocolType.values()[0], R.string.robotProtocolTypeKey)
              letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/settings/LRPreferences.kt on lines 53..58
              letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/settings/LRPreferences.kt on lines 131..133

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

              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

                  @Suppress("UNCHECKED_CAST")
                  val communication = Preference.fromEnumId(preferenceManager, context,
                          CommunicationType.values()[0], R.string.robotConnectionTypeKey)
              letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/settings/LRPreferences.kt on lines 53..58
              letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/settings/LRPreferences.kt on lines 135..137

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

              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

                  /**
                   * Camera orientation of video
                   */
                  @Suppress("UNCHECKED_CAST")
                  val orientation = Preference.fromEnumId(preferenceManager, context,
              letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/settings/LRPreferences.kt on lines 131..133
              letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/settings/LRPreferences.kt on lines 135..137

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

              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

              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

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

                      if(LRPreferences.INSTANCE.internalSystemTTSMessagesEnabled.value)
                          sendText(TTSBaseComponent.TTSObject(TTSBaseComponent.TTS_OK
                              , TTSBaseComponent.COMMAND_PITCH, shouldFlush = true))
              letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/components/ChatSocketComponent.kt on lines 91..93

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

              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

                      if(LRPreferences.INSTANCE.internalSystemTTSMessagesEnabled.value)
                          sendText(TTSBaseComponent.TTSObject(TTSBaseComponent.TTS_DISCONNECTED
                              , TTSBaseComponent.COMMAND_PITCH, shouldFlush = true))
              letsrobotandroid-api/src/main/java/tv/letsrobot/android/api/components/ChatSocketComponent.kt on lines 80..82

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

              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

              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

              Severity
              Category
              Status
              Source
              Language