Showing 75 of 75 total issues

Method onSendButtonClicked has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
Open

  override fun onSendButtonClicked(feedback: Feedback?): Boolean {
    // Depending on your use case, you may add specific data in the feedback object returned,
    // and manipulate it accordingly
    feedback?.put("Email", mEmail?.text ?: "???")
    feedback?.put("My Extra Edit Text", mExtraEditText?.text ?: "")

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 onSendButtonClicked has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  override fun onSendButtonClicked(feedback: Feedback?): Boolean {
    // Depending on your use case, you may add specific data in the feedback object returned,
    // and manipulate it accordingly
    feedback?.put("Email", mEmail?.text ?: "???")
    feedback?.put("My Extra Edit Text", mExtraEditText?.text ?: "")

    Builder has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

        public static final class Builder {
    
            static final long READ_TIMEOUT_DEFAULT = 10;
            static final TimeUnit READ_TIMEOUT_UNIT_DEFAULT = TimeUnit.SECONDS;
            static final long CONNECT_TIMEOUT_DEFAULT = 10;

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

      /*
       * Copyright (c) 2017 Armel Soro
       *
       * Permission is hereby granted, free of charge, to any person obtaining a copy
       * of this software and associated documentation files (the "Software"), to deal
      callbacks/maoni-github/src/main/kotlin/org/rm3l/maoni/github/android/AndroidBasicAuthorization.kt on lines 1..37

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

      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

      /*
       * Copyright (c) 2017 Armel Soro
       *
       * Permission is hereby granted, free of charge, to any person obtaining a copy
       * of this software and associated documentation files (the "Software"), to deal
      callbacks/maoni-jira/src/main/kotlin/org/rm3l/maoni/jira/android/AndroidBasicAuthorization.kt on lines 1..37

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

      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 onSendButtonClicked has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          override fun onSendButtonClicked(feedback: Feedback?): Boolean {
              debug {"onSendButtonClicked"}
      
              val connectivityManager =
                      context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager

        Method validateAndSubmitForm has 65 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private void validateAndSubmitForm() {
                //Validate form
                if (this.validateForm(mRootView)) {
                    //TODO Check that device is actually connected to the internet prior to going any further
                    boolean includeScreenshot = false;
        Severity: Major
        Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java - About 2 hrs to fix

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

                  val deviceAndAppInfo = feedback
                          ?.deviceAndAppInfoAsHumanReadableMap
                          ?.filter { (_, value) -> value != null }
                          ?.map { (key,value) -> "- $key : $value" }
                          ?.joinToString (separator = "\n")
          callbacks/maoni-github/src/main/kotlin/org/rm3l/maoni/github/MaoniGithubListener.kt on lines 84..89
          callbacks/maoni-jira/src/main/kotlin/org/rm3l/maoni/jira/MaoniJiraListener.kt on lines 91..96

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

          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 3 locations. Consider refactoring.
          Open

                  val deviceAndAppInfo = feedback
                          ?.deviceAndAppInfoAsHumanReadableMap
                          ?.filter { (_, value) -> value != null }
                          ?.map { (key,value) -> "- $key : $value" }
                          ?.joinToString (separator = "\n")
          callbacks/maoni-jira/src/main/kotlin/org/rm3l/maoni/jira/MaoniJiraListener.kt on lines 91..96
          callbacks/maoni-slack/src/main/kotlin/org/rm3l/maoni/slack/MaoniSlackListener.kt on lines 104..109

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

          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 3 locations. Consider refactoring.
          Open

                  val deviceAndAppInfo = feedback
                          ?.deviceAndAppInfoAsHumanReadableMap
                          ?.filter { (_, value) -> value != null }
                          ?.map { (key,value) -> "- $key : $value" }
                          ?.joinToString (separator = "\n")
          callbacks/maoni-github/src/main/kotlin/org/rm3l/maoni/github/MaoniGithubListener.kt on lines 84..89
          callbacks/maoni-slack/src/main/kotlin/org/rm3l/maoni/slack/MaoniSlackListener.kt on lines 104..109

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

          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 getLogsToFile has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static void getLogsToFile(@NonNull final File outputFile) {
          
                  PrintWriter out = null;
                  BufferedReader bufferedReader = null;
                  InputStreamReader in = null;
          Severity: Minor
          Found in maoni/src/main/java/org/rm3l/maoni/utils/LogcatUtils.java - About 1 hr to fix

            Method buildImmutableMapView has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private Map<String, Object> buildImmutableMapView() {
                    final SortedMap<String, Object> output = new DeviceInfoSortedMap();
            
                    output.put(SDK_VERSION, sdkVersion);
            
            

              Method validateForm has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  private boolean validateForm(@NonNull View rootView) {
                      if (mContent != null) {
                          if (TextUtils.isEmpty(mContent.getText())) {
                              if (mContentInputLayout != null) {
                                  mContentInputLayout.setErrorEnabled(true);
              Severity: Minor
              Found in maoni/src/main/java/org/rm3l/maoni/ui/MaoniActivity.java - 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

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

                              when (statusCode) {
                                  in 100..399 -> context.longToast(successToastMessage)
                                  else -> {
                                      debug {"responseBody = $responseBody"}
                                      context.longToast("[$statusCode] $failureToastMessage : $responseBody")
              callbacks/maoni-github/src/main/kotlin/org/rm3l/maoni/github/MaoniGithubListener.kt on lines 124..130

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

              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

                              when (statusCode) {
                                  in 100..399 -> context.longToast(successToastMessage)
                                  else -> {
                                      debug {"responseBody = $responseBody"}
                                      context.longToast("[$statusCode] $failureToastMessage : $responseBody")
              callbacks/maoni-slack/src/main/kotlin/org/rm3l/maoni/slack/MaoniSlackListener.kt on lines 174..180

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

              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 getLogsAsString has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static String getLogsAsString() {
              
                      final StringBuilder builder = new StringBuilder();
              
                      InputStreamReader in = null;
              Severity: Minor
              Found in maoni/src/main/java/org/rm3l/maoni/utils/LogcatUtils.java - About 1 hr to fix

                Method buildMaoniEmailListener has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  private fun buildMaoniEmailListener(feedback: Feedback?): Listener {
                    val customSubject = context.defaultSharedPreferences.getString("maoni_email_subject", "")
                    val useCustomSubject = customSubject?.isNotBlank()
                    val customTo = context.defaultSharedPreferences.getString("maoni_email_to", "")
                            ?.split(",")

                  Method buildMaoniGithubListener has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    private fun buildMaoniGithubListener(): Listener {
                      val customUsername = context.defaultSharedPreferences.getString("maoni_github_username", "")
                      val useCustomUsername = customUsername?.isNotBlank()
                  
                      val customToken = context.defaultSharedPreferences.getString("maoni_github_token", "")

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

                      private fun buildMaoniJiraListener(): Listener {
                        val customApiEndpoint = context.defaultSharedPreferences.getString("maoni_jira_rest_base_url", "")
                        val useCustomApiEndpoint = customApiEndpoint?.isNotBlank()
                    
                        val customUsername = context.defaultSharedPreferences.getString("maoni_jira_username", "")

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

                          val customRepo = context.defaultSharedPreferences.getString("maoni_github_repo", "")
                                  ?.split("/")
                                  ?.map { it.trim() }
                                  ?: emptyList()
                      maoni-sample/src/main/kotlin/org/rm3l/maoni/sample/feedback/MaoniSampleCallbackHandler.kt on lines 168..171
                      maoni-sample/src/main/kotlin/org/rm3l/maoni/sample/feedback/MaoniSampleCallbackHandler.kt on lines 172..175
                      maoni-sample/src/main/kotlin/org/rm3l/maoni/sample/feedback/MaoniSampleCallbackHandler.kt on lines 176..179

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language