itachi1706/SingBuses

View on GitHub
app/src/main/java/com/itachi1706/busarrivalsg/NTUBusActivity.java

Summary

Maintainability
A
3 hrs
Test Coverage

Avoid deeply nested control flow statements.
Wontfix

                            if (r.getRoute().getCenter().length > 0)
                                centerOn = r.getRoute().getCenter()[0];
Severity: Major
Found in app/src/main/java/com/itachi1706/busarrivalsg/NTUBusActivity.java - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Wontfix

                                for (NTUBus.MapNodes node : r.getRoute().getNodes()) {
                                    if (node.is_stop_point()) {
                                        mMap.addMarker(new MarkerOptions().position(new LatLng(node.getLat(), node.getLon()))
                                                .title(node.getName())
                                                .snippet("Next Stop: " + node.getShort_direction())
    Severity: Major
    Found in app/src/main/java/com/itachi1706/busarrivalsg/NTUBusActivity.java - About 45 mins to fix

      Refactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed.
      Open

          private void getData(boolean refresh) {

      Cognitive Complexity is a measure of how hard the control flow of a method is to understand. Methods with high Cognitive Complexity will be difficult to maintain.

      See

      Remove this expression which always evaluates to "true"
      Open

              if (receiver != null) LocalBroadcastManager.getInstance(this).unregisterReceiver(receiver);

      If a boolean expression doesn't change the evaluation of the condition, then it is entirely unnecessary, and can be removed. If it is gratuitous because it does not match the programmer's intent, then it's a bug and the expression should be fixed.

      Noncompliant Code Example

      a = true;
      if (a) { // Noncompliant
        doSomething();
      }
      
      if (b && a) { // Noncompliant; "a" is always "true"
        doSomething();
      }
      
      if (c || !a) { // Noncompliant; "!a" is always "false"
        doSomething();
      }
      

      Compliant Solution

      a = true;
      if (foo(a)) {
        doSomething();
      }
      
      if (b) {
        doSomething();
      }
      
      if (c) {
        doSomething();
      }
      

      See

      Remove this expression which always evaluates to "true"
      Open

              if (publicBusReceiver != null) LocalBroadcastManager.getInstance(this).unregisterReceiver(publicBusReceiver);

      If a boolean expression doesn't change the evaluation of the condition, then it is entirely unnecessary, and can be removed. If it is gratuitous because it does not match the programmer's intent, then it's a bug and the expression should be fixed.

      Noncompliant Code Example

      a = true;
      if (a) { // Noncompliant
        doSomething();
      }
      
      if (b && a) { // Noncompliant; "a" is always "true"
        doSomething();
      }
      
      if (c || !a) { // Noncompliant; "!a" is always "false"
        doSomething();
      }
      

      Compliant Solution

      a = true;
      if (foo(a)) {
        doSomething();
      }
      
      if (b) {
        doSomething();
      }
      
      if (c) {
        doSomething();
      }
      

      See

      TODO found
      Confirmed

                      // TODO: Find a way to do the bearing lol

      This block of commented-out lines of code should be removed.
      Open

                      /*Bitmap arrow = busesUtil.vectorToBitmap(R.drawable.ic_chevron, getResources(), getRouteColor(r.getId()));

      Programmers should not comment out code as it bloats programs and reduces readability.

      Unused code should be deleted and can be retrieved from source control history if required.

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

          private void requestGpsPermission() {
              LogHelper.w(LocManager.TAG, "GPS permission is not granted. Requesting permission");
              final String[] permissions = new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION};
      
              if (!ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_COARSE_LOCATION)) {
      app/src/main/java/com/itachi1706/busarrivalsg/BusLocationMapsActivity.java on lines 170..182

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

      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

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

          private void checkIfYouHaveGpsPermissionForThis() {
              int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION);
              if (rc == PackageManager.PERMISSION_GRANTED) {
                  mMap.setMyLocationEnabled(true);
              } else {
      app/src/main/java/com/itachi1706/busarrivalsg/BusLocationMapsActivity.java on lines 161..168

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

      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

                      try {
                          tmpJSON = gson.fromJson(data, BusStopJSON[].class);
                      }catch (JsonSyntaxException e) {
                          Toast.makeText(context, "An error occurred parsing public bus stops. Please try again later", Toast.LENGTH_LONG).show();
                          return;
      app/src/main/java/com/itachi1706/busarrivalsg/NTUBusActivity.java on lines 414..419
      app/src/main/java/com/itachi1706/busarrivalsg/NTUBusActivity.java on lines 581..586

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

      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

                      try {
                          busObjsArr = gson.fromJson(data, BusArrivalMain[].class);
                      } catch (JsonSyntaxException e) {
                          Toast.makeText(context, "An error occurred parsing public buses. Please try again later", Toast.LENGTH_LONG).show();
                          return;
      app/src/main/java/com/itachi1706/busarrivalsg/NTUBusActivity.java on lines 414..419
      app/src/main/java/com/itachi1706/busarrivalsg/NTUBusActivity.java on lines 550..555

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

      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

                  try {
                      busObj = gson.fromJson(data, NTUBus.class);
                  } catch (JsonSyntaxException e) {
                      Toast.makeText(context, "An error occurred. Please try again later", Toast.LENGTH_LONG).show();
                      return;
      app/src/main/java/com/itachi1706/busarrivalsg/NTUBusActivity.java on lines 581..586
      app/src/main/java/com/itachi1706/busarrivalsg/NTUBusActivity.java on lines 550..555

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

      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

      There are no issues that match your filters.

      Category
      Status