AChep/literaryclock

View on GitHub

Showing 32 of 32 total issues

Method createDependencies has 230 lines of code (exceeds 25 allowed). Consider refactoring.
Open

fun createDependencies(module: Module): List<Dependency> {
    val kotlinStdlib = Dependency(
        "Kotlin StdLib",
        KOTLIN_VERSION,
        "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$KOTLIN_VERSION",
Severity: Major
Found in buildSrc/src/main/kotlin/DependencyFactory.kt - About 1 day to fix

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

        override fun logQuoteOpen(quote: QuoteItem) {
            val bundle = bundleOf(
                FirebaseAnalytics.Param.ITEM_CATEGORY to FirebaseAnalyticsContract.VIEW_ITEM_CATEGORY_QUOTE,
                FirebaseAnalytics.Param.ITEM_ID to quote.asin,
                FirebaseAnalytics.Param.ITEM_NAME to quote.title
    app/src/main/java/com/artemchep/literaryclock/analytics/firebase/FirebaseAnalyticsMain.kt on lines 24..31

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

    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 logQuoteShare(quote: QuoteItem) {
            val bundle = bundleOf(
                FirebaseAnalytics.Param.CONTENT_TYPE to FirebaseAnalyticsContract.SHARE_CATEGORY_QUOTE,
                FirebaseAnalytics.Param.ITEM_ID to quote.asin,
                FirebaseAnalytics.Param.METHOD to FirebaseAnalyticsContract.SHARE_METHOD_SYSTEM
    app/src/main/java/com/artemchep/literaryclock/analytics/firebase/FirebaseAnalyticsMain.kt on lines 15..22

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

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

        override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
            super.onViewCreated(view, savedInstanceState)
            viewBinding.topAppBar.setNavigationOnClickListener {
                findNavController().navigateUp()
            }

      Method showAnalogTime has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private fun showAnalogTime(time: Time) {
              // Cancel previous animation if it
              // existed.
              analogClockAnimator?.cancel()
      
      

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

            override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
                super.onViewCreated(view, savedInstanceState)
                setOnApplyWindowInsetsListener { insets ->
                    fun Float.asPixelsPlusInsetBottom() =
                        insets.systemWindowInsetBottom +

          Method showAnalogTime has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
          Open

              private fun showAnalogTime(time: Time) {
                  // Cancel previous animation if it
                  // existed.
                  analogClockAnimator?.cancel()
          
          

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

              override fun onCreate(savedInstanceState: Bundle?) {
                  super.onCreate(savedInstanceState)
                  setContentView(R.layout.activity_main)
          
                  window.decorView.systemUiVisibility =

            Method showProducts has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private fun showProducts(products: Loader<Inventory.Products>) {
                    when(products) {
                        is Loader.Ok -> {
                            viewBinding.errorView.isVisible = false
                            viewBinding.progressView.isVisible = false

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

                          val i = Intent(Intent.ACTION_SEND).apply {
                              type = "description/plain"
                              putExtra(Intent.EXTRA_SUBJECT, subject)
                              putExtra(Intent.EXTRA_TEXT, text)
                          }
              app/src/main/java/com/artemchep/literaryclock/ui/fragments/AboutFragment.kt on lines 84..88

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

              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

                              val i = Intent(Intent.ACTION_SEND).apply {
                                  type = "description/plain"
                                  putExtra(Intent.EXTRA_SUBJECT, subject)
                                  putExtra(Intent.EXTRA_TEXT, text)
                              }
              app/src/main/java/com/artemchep/literaryclock/ui/fragments/MainFragment.kt on lines 136..140

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

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

              fun Fragment.wrapInStatusBarView(child: View): View {
                  return LinearLayout(context).apply {
                      orientation = LinearLayout.VERTICAL
                      layoutParams = FrameLayout.LayoutParams(
                          FrameLayout.LayoutParams.MATCH_PARENT,
              Severity: Minor
              Found in app/src/main/java/com/artemchep/literaryclock/utils/InsetsHelper.kt - About 1 hr to fix

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

                    private fun showMoment(moment: MomentItem) {
                        adapter.apply {
                            models.apply {
                                clear()
                                addAll(moment.quotes)
                app/src/main/java/com/artemchep/literaryclock/ui/fragments/DonateQuoteFragment.kt on lines 99..108

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

                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 fun showMoment(moment: MomentItem) {
                        adapter.apply {
                            models.apply {
                                clear()
                                addAll(moment.quotes)
                app/src/main/java/com/artemchep/literaryclock/ui/fragments/MainFragment.kt on lines 154..163

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

                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

                    /**
                     * You should only call [UiCheckout] specific methods from
                     * the `with` methods.
                     */
                    @UiThread
                app/src/main/java/com/artemchep/literaryclock/checkout/FlexCheckout.kt on lines 21..31

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

                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

                    /**
                     * You should only call [UiCheckout] specific methods from
                     * the `with` methods.
                     */
                    @UiThread
                app/src/main/java/com/artemchep/literaryclock/checkout/FlexCheckout.kt on lines 33..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 85.

                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

                        viewBinding.recyclerView.adapter = QuoteAdapter()
                            .also(::adapter::set)
                            .apply {
                                // Listen to the on click events
                                onItemClickListener = this@MainFragment
                app/src/main/java/com/artemchep/literaryclock/ui/fragments/AboutFragment.kt on lines 54..59

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

                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

                        viewBinding.depsRecyclerView.adapter = DependencyAdapter()
                            .also(::adapter::set)
                            .apply {
                                // Listen to the on click events
                                onItemClickListener = this@AboutFragment
                app/src/main/java/com/artemchep/literaryclock/ui/fragments/MainFragment.kt on lines 121..126

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

                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

                            }.let { quotes ->
                                val offset = currentTime.time - range.start.time
                                return@let quotes[offset]
                            }
                app/src/main/java/com/artemchep/literaryclock/logic/live/MomentLiveData.kt on lines 56..59

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

                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

                        }.let { moments ->
                            val offset = time.time - range.start.time
                            return@let moments[offset]
                        }
                app/src/main/java/com/artemchep/literaryclock/widget/LiteraryWidgetUpdater.kt on lines 70..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 69.

                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