Kynetics/uf-android-client

View on GitHub
uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt

Summary

Maintainability
A
2 hrs
Test Coverage

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

    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

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

            override fun putFloat(key: String?, value: Float): SharedPreferences.Editor  = selectEditor(key).putFloat(key, value)
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 131..131
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 134..134
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 138..138

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

    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 4 locations. Consider refactoring.
    Invalid

            override fun putBoolean(key: String?, value: Boolean): SharedPreferences.Editor = selectEditor(key).putBoolean(key, value)
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 131..131
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 134..134
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 144..144

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

    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 4 locations. Consider refactoring.
    Invalid

            override fun putLong(key: String?, value: Long): SharedPreferences.Editor = selectEditor(key).putLong(key, value)
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 134..134
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 138..138
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 144..144

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

    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 4 locations. Consider refactoring.
    Invalid

            override fun putInt(key: String?, value: Int): SharedPreferences.Editor  = selectEditor(key).putInt(key, value)
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 131..131
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 138..138
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 144..144

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

    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 4 locations. Consider refactoring.
    Invalid

        override fun getLong(key: String?, defValue: Long): Long = selectSP(key).getLong(key, defValue)
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 44..44
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 53..53
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 67..67

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

    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 4 locations. Consider refactoring.
    Invalid

        override fun getFloat(key: String?, defValue: Float): Float = selectSP(key).getFloat(key, defValue)
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 44..44
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 53..53
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 65..65

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

    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 4 locations. Consider refactoring.
    Invalid

        override fun getInt(key: String?, defValue: Int): Int  = selectSP(key).getInt(key, defValue)
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 44..44
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 65..65
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 67..67

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

    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 4 locations. Consider refactoring.
    Invalid

        override fun getBoolean(key: String?, defValue: Boolean): Boolean = selectSP(key).getBoolean(key, defValue)
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 53..53
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 65..65
    uf-client-service/src/main/kotlin/com/kynetics/uf/android/content/UFSharedPreferences.kt on lines 67..67

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

    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