Kynetics/uf-android-client

View on GitHub

Showing 61 of 95 total issues

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

    override fun sync(messenger: Messenger?) {
        Log.i(tag, "received sync request")

        if (messenger == null) {
            Log.i(tag, "command ignored because field replyTo is null")
uf-client-service/src/main/kotlin/com/kynetics/uf/android/communication/impl/CommunicationApiV1_1Impl.kt on lines 61..83

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

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 sync(messenger: Messenger?) {
        Log.i(TAG, "received sync request")

        if (messenger == null) {
            Log.i(TAG, "command ignored because field replyTo is null")
uf-client-service/src/main/kotlin/com/kynetics/uf/android/communication/impl/AbstractCommunicationApi.kt on lines 51..73

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

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

Class CurrentUpdateState has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

// todo refactor
class CurrentUpdateState(context: Context) {

    private val sharedPreferences: SharedPreferences

    Method install has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        override fun install(
            artifact: Updater.SwModuleWithPath.Artifact,
            currentUpdateState: CurrentUpdateState,
            messenger: Updater.Messenger,
            context: Context

      File ABOtaInstaller.kt has 268 lines of code (exceeds 250 allowed). 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

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

                    /**
                     * Class to build a message to add target attributes
                     *
                     * @property targetAttributesWithPolicy, a Map of target attributes with an aggregation policy
                     */
        uf-client-service/uf-client-service-api/src/main/kotlin/com/kynetics/uf/android/api/Communication.kt on lines 167..194

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

        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

                    /**
                     * Class to build a message to configure the service.
                     * When the new configuration can be applied live, a [UFServiceMessageV1.Event.ConfigurationUpdated] is notified.
                     * When the new configuration requires a restart of the service, a [UFServiceMessageV1.Event.Stopped] and a
                     * [UFServiceMessageV1.Event.Started] are notified.
        uf-client-service/uf-client-service-api/src/main/kotlin/com/kynetics/uf/android/api/Communication.kt on lines 284..308

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

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

                fun build(
                    configurationHandler: ConfigurationHandler,
                    mNotificationManager: NotificationManager,
                    service: UpdateFactoryService
                ): AndroidDeploymentPermitProvider {

          Method installationResult has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private fun installationResult(
                  updateStatus: CompletableFuture<Int>,
                  messenger: Updater.Messenger,
                  artifact: Updater.SwModuleWithPath.Artifact
              ): CurrentUpdateState.InstallationResult {

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

                    if (configurationHandler.needReboot(currentConf)) {
                        ufService.restartService(configurationHandler)
                        Log.i(tag, "configuration updated - restarting service")
                    } else {
                        MessengerHandler.notifyMessage(UFServiceMessageV1.Event.ConfigurationUpdated(configurationHandler.getCurrentConfiguration()))
            uf-client-service/src/main/kotlin/com/kynetics/uf/android/communication/impl/CommunicationApiV1_1Impl.kt on lines 45..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 142.

            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 (configurationHandler.needReboot(currentConf)) {
                        ufService.restartService(configurationHandler)
                        Log.i(TAG, "configuration updated - restarting service")
                    } else {
                        MessengerHandler.notifyMessage(UFServiceMessageV1.Event.Started(configurationHandler.getSecureConfiguration()))
            uf-client-service/src/main/kotlin/com/kynetics/uf/android/communication/impl/AbstractCommunicationApi.kt on lines 90..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 142.

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

                override fun applyUpdate(
                    modules: Set<Updater.SwModuleWithPath>,
                    messenger: Updater.Messenger
                ): Updater.UpdateResult {
                    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {

              Method updatePreference has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private fun updatePreference(preference: Preference?, key: String, sharedPrefs: SharedPreferences) {
                      if (preference == null || preference is SwitchPreferenceCompat) {
                          return
                      }
              
              

                Method install has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
                    override fun install(
                        artifact: Updater.SwModuleWithPath.Artifact,
                        currentUpdateState: CurrentUpdateState,
                        messenger: Updater.Messenger,

                  Method schedule has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      fun schedule(tag:String,
                                   timeWindows: UFServiceConfigurationV2.TimeWindows,
                                   action:()->Unit):Status{
                          with(ExecutionTime.forCron(HaraCronParser.parse(timeWindows.cronExpression))){
                              val now: ZonedDateTime = ZonedDateTime.now()

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

                                    override fun downloadAllowed(): Deferred<Boolean> {
                                        val currentUpdateState = CurrentUpdateState(service)
                                        return if (currentUpdateState.isAllFileDownloaded()) {
                                            CompletableDeferred(true)
                                        } else {
                    uf-client-service/src/main/kotlin/com/kynetics/uf/android/configuration/AndroidDeploymentPermitProvider.kt on lines 72..79

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

                    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 updateAllowed(): Deferred<Boolean> {
                                        val currentUpdateState = CurrentUpdateState(service)
                                        return if(currentUpdateState.isUpdateStart()){
                                            CompletableDeferred(true)
                                        } else {
                    uf-client-service/src/main/kotlin/com/kynetics/uf/android/configuration/AndroidDeploymentPermitProvider.kt on lines 63..70

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

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

                        override fun onReceive(context: Context, intent: Intent) {
                            if (PackageInstallerBRHandler.ACTION_INSTALL_COMPLETE != intent.action) {
                                return
                            }
                    
                    

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

                                      is UFServiceMessageV1.Event.Stopped, is UFServiceMessageV1.Event.Started, is UFServiceMessageV1.Event.CantBeStopped, is UFServiceMessageV1.Event.ConfigurationUpdated, is UFServiceMessageV1.Event.NewTargetTokenReceived -> null
                      uf-client-service/src/main/kotlin/com/kynetics/uf/android/communication/messenger/MessageHandler.kt on lines 139..139

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

                      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

                                      is UFServiceMessageV1.Event.Stopped, is UFServiceMessageV1.Event.Started, is UFServiceMessageV1.Event.CantBeStopped, is UFServiceMessageV1.Event.ConfigurationUpdated, is UFServiceMessageV1.Event.NewTargetTokenReceived -> null
                      uf-client-service/src/main/kotlin/com/kynetics/uf/android/communication/messenger/MessageHandler.kt on lines 129..129

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

                      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