Kynetics/uf-android-client

View on GitHub

Showing 61 of 95 total issues

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

        override fun onStatusUpdate(status: Int, percent: Float) { // i==status  v==percent
            Log.d(TAG, "status:$status")
            Log.d(TAG, "percent:$percent")
            val currentPhaseProgress = min(percent.toDouble(), 100.0)
            val newPhase = previousState != status

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

    /*
     * Copyright © 2017-2023  Kynetics  LLC
     * 
     * This program and the accompanying materials are made
     * available under the terms of the Eclipse Public License 2.0
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/communication/impl/CommunicationApiV1Impl.kt on lines 1..26

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

    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

    /*
     * Copyright © 2017-2023  Kynetics  LLC
     * 
     * This program and the accompanying materials are made
     * available under the terms of the Eclipse Public License 2.0
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/communication/impl/CommunicationApiV0_1Impl.kt on lines 1..26

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

    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 init has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        override fun init(haraClientData: HaraClientData,
                          directoryForArtifactsProvider: DirectoryForArtifactsProvider,
                          configDataProvider: ConfigDataProvider,
                          softDeploymentPermitProvider: DeploymentPermitProvider,
                          messageListeners: List<MessageListener>,

      Method onCreate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          override fun onCreate() {
              super.onCreate()
              AndroidLoggerAdapter.setLogTag("Update Factory Client")
              if(BuildConfig.DEBUG){
                  AndroidLoggerAdapter.setLogLevel(LogLevel.TRACE)

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

                /**
                 * Deserialize a [jsonContent] element into a corresponding object of type [UFServiceMessageV1].
                 * @throws [SerializationException] if given input can not be deserialized
                 * @throws [IllegalArgumentException] if given input isn't a UFServiceMessageV1 json serialization
                 */

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

              fun addSuccessMessageToRepor(vararg messages: String) {
                  val newDistReportSuccess = distributionReportSuccess.toMutableSet()
                  newDistReportSuccess.addAll(messages)
                  sharedPreferences.edit().putStringSet(APK_DISTRIBUTION_REPORT_SUCCESS_KEY, newDistReportSuccess).apply()
              }
          uf-client-service/src/main/kotlin/com/kynetics/uf/android/update/CurrentUpdateState.kt on lines 36..40

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

          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

              fun addErrorToRepor(vararg errors: String) {
                  val newDistReportError = distributionReportError.toMutableSet()
                  newDistReportError.addAll(errors)
                  sharedPreferences.edit().putStringSet(APK_DISTRIBUTION_REPORT_ERROR_KEY, newDistReportError).apply()
              }
          uf-client-service/src/main/kotlin/com/kynetics/uf/android/update/CurrentUpdateState.kt on lines 42..46

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

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

                  fun newInstance(
                      configurationHandler: ConfigurationHandler,
                      restartableClientService: RestartableClientService,
                      softDeploymentPermitProvider: AndroidDeploymentPermitProvider
                  ) :CommunicationApiStrategy{

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

                @Suppress("UNCHECKED_CAST")
                private fun moveSharedPreferences(sp1:SharedPreferences, sp2:SharedPreferences, moveTo:(Map.Entry<String, Any?>) -> Boolean){
                    sp2.edit().apply{
                        val sp1Editor = sp1.edit()
                        sp1.all.filter(moveTo).forEach{ entry ->

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

                  @Throws(IOException::class)
                  override fun intercept(chain: Interceptor.Chain): Response {
                      val originalRequest = chain.request()
                      val builder = originalRequest.newBuilder()
                      val isConfigDataRequest = originalRequest.url.toString().endsWith(CONFIG_DATA_ACTION)

                Method newUFClient has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        haraClientData: HaraClientData,
                        directoryForArtifactsProvider: DirectoryForArtifactsProvider,
                        configDataProvider: ConfigDataProvider,
                        deploymentPermitProvider: DeploymentPermitProvider,
                        messageListeners: List<MessageListener>,

                  Method newInstance has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                          haraClientData: HaraClientData,
                          directoryForArtifactsProvider: DirectoryForArtifactsProvider,
                          configDataProvider: ConfigDataProvider,
                          deploymentPermitProvider: DeploymentPermitProvider,
                          messageListeners: List<MessageListener>,

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

                        override fun registerOnSharedPreferenceChangeListener(listener: SharedPreferences.OnSharedPreferenceChangeListener?) {
                            if(listener != null){
                                secureSharedPreferences.registerOnSharedPreferenceChangeListener(listener)
                                sharedPreferencesWithObject.registerOnSharedPreferenceChangeListener(listener)
                            }
                    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 46..51

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

                    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

                        override fun unregisterOnSharedPreferenceChangeListener(listener: SharedPreferences.OnSharedPreferenceChangeListener?) {
                            if(listener != null){
                                secureSharedPreferences.unregisterOnSharedPreferenceChangeListener(listener)
                                sharedPreferencesWithObject.unregisterOnSharedPreferenceChangeListener(listener)
                            }
                    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 71..76

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

                    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 newHawkbitClient has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            haraClientData: HaraClientData,
                            directoryForArtifactsProvider: DirectoryForArtifactsProvider,
                            configDataProvider: ConfigDataProvider,
                            deploymentPermitProvider: DeploymentPermitProvider,
                            messageListeners: List<MessageListener>,

                      Method newInstance has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                              fun newInstance(context: Context,
                                              countDownLatch: CountDownLatch?,
                                              packageName: String?,
                                              packageVersion: Long?,
                                              artifact: Updater.SwModuleWithPath.Artifact?,

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

                                    if(this != null){
                                        Log.i(TAG, "Loaded new configuration from intent")
                                    } else {
                                        Log.i(TAG, "No configuration found in intent")
                                    }
                        uf-client-service/src/main/kotlin/com/kynetics/uf/android/configuration/ConfigurationLoaderFromIntent.kt on lines 39..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 77.

                        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

                                    if(this != null){
                                        Log.i(TAG, "Loaded new configuration from intent")
                                    } else {
                                        Log.i(TAG, "No configuration found in intent")
                                    }
                        uf-client-service/src/main/kotlin/com/kynetics/uf/android/configuration/ConfigurationHandler.kt on lines 56..60

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

                        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

                                    || startingSharedPreferences[getString(R.string.shared_preferences_controller_id_key)] != sp.getString(getString(R.string.shared_preferences_controller_id_key), null)
                        uf-client-service/src/main/kotlin/com/kynetics/uf/android/ui/fragment/UFPreferenceFragment.kt on lines 172..172
                        uf-client-service/src/main/kotlin/com/kynetics/uf/android/ui/fragment/UFPreferenceFragment.kt on lines 173..173

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

                        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