LEuLuDyHa/app

View on GitHub

Showing 22 of 85 total issues

Method ReadingStateControl has a Cognitive Complexity of 89 (exceeds 20 allowed). Consider refactoring.
Confirmed

/**
 * On the book details page of a work, allow a user to set if they :
 * - are interested in reading the book
 * - are currently reading the book
 * - have finished reading the book

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 NavGraph has a Cognitive Complexity of 75 (exceeds 20 allowed). Consider refactoring.
Confirmed

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun NavGraph(navController: NavHostController) {
    Scaffold(
        bottomBar = { BottomToolbar(navController) }

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

Class LibraryDao has 54 methods (exceeds 20 allowed). Consider refactoring.
Confirmed

/**
 * Library local DAO.
 */
@Dao
interface LibraryDao {
Severity: Major
Found in data/src/main/java/com/github/leuludyha/data/db/LibraryDao.kt - About 7 hrs to fix

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

            if (recursive) {
                val authors = edition.authors.firstOrNull()
                authors?.forEach { insert(context, bmpProvider, it, false) }
                val editionAuthorCrossRefs = authors?.map { EditionAuthorCrossRef.from(edition, it) }
    
    
    data/src/main/java/com/github/leuludyha/data/db/LibraryDao.kt on lines 300..311

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

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

            if(recursive) {
                val authors = work.authors.firstOrNull()
                authors?.forEach { insert(context, bmpProvider, it, false) }
                val workAuthorCrossRefs = authors?.map { WorkAuthorCrossRef.from(work, it) }
    
    
    data/src/main/java/com/github/leuludyha/data/db/LibraryDao.kt on lines 334..345

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

    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 NavGraph has 87 lines of code (exceeds 25 allowed). Consider refactoring.
    Confirmed

    @OptIn(ExperimentalMaterial3Api::class)
    @Composable
    fun NavGraph(navController: NavHostController) {
        Scaffold(
            bottomBar = { BottomToolbar(navController) }

      Method ReadingStateControl has 86 lines of code (exceeds 25 allowed). Consider refactoring.
      Confirmed

      /**
       * On the book details page of a work, allow a user to set if they :
       * - are interested in reading the book
       * - are currently reading the book
       * - have finished reading the book

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

        package com.github.leuludyha.domain.useCase
        
        import android.content.Context
        import com.github.leuludyha.domain.model.library.Result
        import com.github.leuludyha.domain.repository.LibraryRepository
        domain/src/main/java/com/github/leuludyha/domain/useCase/GetAuthorRemotelyUseCase.kt on lines 1..23
        domain/src/main/java/com/github/leuludyha/domain/useCase/GetEditionRemotelyUseCase.kt on lines 1..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 193.

        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

        package com.github.leuludyha.domain.useCase
        
        import android.content.Context
        import com.github.leuludyha.domain.model.library.Result
        import com.github.leuludyha.domain.repository.LibraryRepository
        domain/src/main/java/com/github/leuludyha/domain/useCase/GetAuthorRemotelyUseCase.kt on lines 1..23
        domain/src/main/java/com/github/leuludyha/domain/useCase/GetEditionByISBNRemotelyUseCase.kt on lines 1..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 193.

        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

        package com.github.leuludyha.domain.useCase
        
        import android.content.Context
        import com.github.leuludyha.domain.model.library.Result
        import com.github.leuludyha.domain.repository.LibraryRepository
        domain/src/main/java/com/github/leuludyha/domain/useCase/GetEditionByISBNRemotelyUseCase.kt on lines 1..22
        domain/src/main/java/com/github/leuludyha/domain/useCase/GetEditionRemotelyUseCase.kt on lines 1..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 193.

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

                    composable(
                        route = Screen.AuthorDetails.route,
                        arguments = listOf(navArgument(Constant.AUTHOR_DETAILS_ARGUMENT_KEY) {
                            type = NavType.StringType
                        })
        app/src/main/java/com/github/leuludyha/ibdb/presentation/navigation/NavGraph.kt on lines 60..73
        app/src/main/java/com/github/leuludyha/ibdb/presentation/navigation/NavGraph.kt on lines 98..107

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

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

                    composable(
                        route = Screen.Share.route,
                        arguments = listOf(navArgument(Constant.SHARE_BOOK_ID_ARGUMENT_KEY) {
                            type = NavType.StringType
                        })
        app/src/main/java/com/github/leuludyha/ibdb/presentation/navigation/NavGraph.kt on lines 60..73
        app/src/main/java/com/github/leuludyha/ibdb/presentation/navigation/NavGraph.kt on lines 74..85

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

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

                    composable(
                        route = Screen.BookDetails.route,
                        arguments = listOf(navArgument(Constant.BOOK_DETAILS_ARGUMENT_KEY) {
                            type = NavType.StringType
                        })
        app/src/main/java/com/github/leuludyha/ibdb/presentation/navigation/NavGraph.kt on lines 74..85
        app/src/main/java/com/github/leuludyha/ibdb/presentation/navigation/NavGraph.kt on lines 98..107

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

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

            /**
             * Find all contacts of the user, and map them to either a phone number or an email
             * "Copy-pasted" from https://stackoverflow.com/questions/12562151/android-get-all-contacts
             */
            @SuppressLint("Range")

          Method insert has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
          Confirmed

              /**
               * Inserts the given [Work] in the database.
               *
               * It includes inserting the corresponding [WorkEntity], all its [Cover]s and `Subject`s
               * and – if [recursive] – all its authors and editions.
          Severity: Minor
          Found in data/src/main/java/com/github/leuludyha/data/db/LibraryDao.kt - 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

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

                      try {
                          Log.i("Auth", "Failed sign in, begin sign up")
                          val signUpResult = oneTapClient.beginSignIn(signUpRequest).await()
                          Log.i("Auth", "Finished sign up")
                          Result.Success(signUpResult)
          data/src/main/java/com/github/leuludyha/data/repository/AuthRepositoryImpl.kt on lines 30..35

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

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

                  return try {
                      Log.i("Auth", "Begin sign in...")
                      val signInResult = oneTapClient.beginSignIn(signInRequest).await()
                      Log.i("Auth", "Finished sign in...")
                      Result.Success(signInResult)
          data/src/main/java/com/github/leuludyha/data/repository/AuthRepositoryImpl.kt on lines 36..41

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

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

              override fun toModel(libraryApi: LibraryApi): Author? {
                  val id = extractIdFromKey(key, "/authors/")
                  if (id == null || error != null)
                      return null
          
          
          Severity: Minor
          Found in data/src/main/java/com/github/leuludyha/data/api/RawAuthor.kt - About 1 hr to fix

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

                /**
                 * @param user User to get the neighbours of
                 * @param distance Distance to use to get the neighbours
                 * @param n Number of nearest neighbours to return
                 * @return a sorted list of [User], ranked from smallest distance to largest distance
            data/src/main/java/com/github/leuludyha/data/repository/datasource/UserDataSource.kt on lines 7..13

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

            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

                /**
                 * @param user User to get the neighbours of
                 * @param distance Distance to use to get the neighbours
                 * @param n Number of nearest neighbours to return
                 * @return a sorted list of [User], ranked from smallest distance to largest distance
            domain/src/main/java/com/github/leuludyha/domain/repository/UserRepository.kt on lines 25..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 84.

            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