OrkestApp/sdp_2023

View on GitHub

Showing 109 of 109 total issues

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

    // This function is used to get the album cover image
    fun getAlbumCoverImageUrl(albumId: String, accessToken: String, testResponse: Response?): CompletableFuture<String> {

        val future = CompletableFuture<String>()
        val client = OkHttpClient()
app/src/main/java/com/github/orkest/data/SpotifyMultimedia.kt on lines 65..111

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

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

    // This function is used to get the artist image
    fun getArtistImage(artistId: String, accessToken: String, testResponse: Response?): CompletableFuture<String> {
        val future = CompletableFuture<String>()
        val client = OkHttpClient()

app/src/main/java/com/github/orkest/data/SpotifyMultimedia.kt on lines 17..63

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

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 SignIn has a Cognitive Complexity of 68 (exceeds 20 allowed). Consider refactoring.
Open

/**
 * The function that launches the call to firebase and the google api to sign in
 */
@Composable
fun SignIn (navController: NavController, viewModel: AuthViewModel) {
Severity: Minor
Found in app/src/main/java/com/github/orkest/ui/authentication/SignIn.kt - About 1 day 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

Method CreateNavigationBar has a Cognitive Complexity of 59 (exceeds 20 allowed). Consider refactoring.
Open

        @SuppressLint("UnrememberedMutableState")
        @Composable
        fun CreateNavigationBar(navController: NavHostController, currentUser: String, activity: MainActivity) {

            val context = LocalContext.current
Severity: Minor
Found in app/src/main/java/com/github/orkest/ui/NavigationBar.kt - About 6 hrs 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

Method ProfileTopInterface has a Cognitive Complexity of 59 (exceeds 20 allowed). Consider refactoring.
Open

/**
 * The top interface of the user's profile displaying the user's information
 * username, bio, number of followers, number of followings, profile picture
 */
@Composable
Severity: Minor
Found in app/src/main/java/com/github/orkest/ui/profile/ProfileTopInterface.kt - About 6 hrs 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

Method searchAsong has 168 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    override fun searchAsong(songName: String, artistName: String): String {
        Log.d("ENTER MOCK", songName)
        return "{\n" +
                "  \"data\": [\n" +
                "    {\n" +
Severity: Major
Found in app/src/main/java/com/github/orkest/domain/DeezerMockAPi.kt - About 6 hrs to fix

    Method WelcomeOperation has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
    Open

            /**
             * 1) Stores the access token along with the userName
             * 2) Fetch the user Id using the Deezer API
             * 3) Create a orkest Playlist then waits for the playlist ID
             * 4) Stores the playlist id back into the database
    Severity: Minor
    Found in app/src/main/java/com/github/orkest/ui/DeezerWelcomeActivity.kt - About 4 hrs 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

    Method createUI has a Cognitive Complexity of 46 (exceeds 20 allowed). Consider refactoring.
    Open

        @Composable
        fun createUI(bluetoothServiceManager: BluetoothInterface) {
            val recompose by rememberUpdatedState(update)
    
            //bluetoothServiceManager.acceptConnections()
    Severity: Minor
    Found in app/src/main/java/com/github/orkest/bluetooth/ui/BluetoothActivity.kt - About 4 hrs 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

    File FireStoreDatabaseAPI.kt has 339 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    package com.github.orkest.domain
    
    import android.content.ContentValues
    import android.content.ContentValues.TAG
    import android.content.Context
    Severity: Minor
    Found in app/src/main/java/com/github/orkest/domain/FireStoreDatabaseAPI.kt - About 4 hrs to fix

      Method SignIn has 92 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      /**
       * The function that launches the call to firebase and the google api to sign in
       */
      @Composable
      fun SignIn (navController: NavController, viewModel: AuthViewModel) {
      Severity: Major
      Found in app/src/main/java/com/github/orkest/ui/authentication/SignIn.kt - About 3 hrs to fix

        Method SearchUi has 85 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                /**
                 * @param viewModel use to communicate with the Backend
                 *
                 *This method display the search bar, and support the drawing of the future users that will
                 * be find in the database
        Severity: Major
        Found in app/src/main/java/com/github/orkest/ui/search/SearchUserView.kt - About 3 hrs to fix

          Method onCreate has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
          Open

              public override fun onCreate(savedInstanceState: Bundle?) {
                  super.onCreate(savedInstanceState)
                  setContent {
                      OrkestTheme {
                          // A surface container using the 'background' color from the theme
          Severity: Minor
          Found in app/src/main/java/com/github/orkest/ui/feed/CreatePost.kt - About 3 hrs 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

          Method createUI has 76 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @Composable
              fun createUI(bluetoothServiceManager: BluetoothInterface) {
                  val recompose by rememberUpdatedState(update)
          
                  //bluetoothServiceManager.acceptConnections()
          Severity: Major
          Found in app/src/main/java/com/github/orkest/bluetooth/ui/BluetoothActivity.kt - About 3 hrs to fix

            Method updateUserFollowers has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
            Open

                /**
                 * toFollow: Boolean = states whether we should add the current user or retrieve it from the user's followers' list
                 * Update the followers' list of the visited profile
                 * The multiple future.complete allow to reduce the complexity of the function and make sure to handle all the errors
                 */
            Severity: Minor
            Found in app/src/main/java/com/github/orkest/ui/profile/ProfileViewModel.kt - About 2 hrs 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

            Method updateCurrentUserFollowings has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
            Open

                /**
                 * toFollow: Boolean = states whether we should add the visited user or retrieve it from the current user's followings' list
                 * Update the followings' list of the current logged in user
                 */
                open fun updateCurrentUserFollowings(toFollow: Boolean): CompletableFuture<Boolean> {
            Severity: Minor
            Found in app/src/main/java/com/github/orkest/ui/profile/ProfileViewModel.kt - About 2 hrs 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

            Method ProfileTopInterface has 68 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            /**
             * The top interface of the user's profile displaying the user's information
             * username, bio, number of followers, number of followings, profile picture
             */
            @Composable
            Severity: Major
            Found in app/src/main/java/com/github/orkest/ui/profile/ProfileTopInterface.kt - About 2 hrs to fix

              Class FireStoreDatabaseAPI has 23 methods (exceeds 20 allowed). Consider refactoring.
              Open

              open class FireStoreDatabaseAPI {
              
                  companion object{
                      val db = Firebase.firestore
                      fun isOnline(context: Context): Boolean {
              Severity: Minor
              Found in app/src/main/java/com/github/orkest/domain/FireStoreDatabaseAPI.kt - About 2 hrs to fix

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

                        @SuppressLint("UnrememberedMutableState")
                        @Composable
                        fun CreateNavigationBar(navController: NavHostController, currentUser: String, activity: MainActivity) {
                
                            val context = LocalContext.current
                Severity: Major
                Found in app/src/main/java/com/github/orkest/ui/NavigationBar.kt - About 2 hrs to fix

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

                  // Define a type converter for the OrkestDate class
                  class OrkestDateConverter {
                      @TypeConverter
                      fun fromOrkestDate(date: OrkestDate?): String? {
                          val gson = Gson()
                  app/src/main/java/com/github/orkest/domain/persistence/AppEntities.kt on lines 64..77

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

                  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

                  // Define a type converter for the Song class
                  class SongConverter {
                      @TypeConverter
                      fun fromSong(song: Song?): String? {
                          val gson = Gson()
                  app/src/main/java/com/github/orkest/domain/persistence/AppEntities.kt on lines 80..93

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

                  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