procrastinot-team/procrastinot

View on GitHub

Showing 73 of 117 total issues

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

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_coaching)
        super.onCreateDrawer()
        bottomNavView = findViewById(R.id.bottomNav)
app/src/main/java/com/github/mateo762/myapplication/habits/HabitsActivity.kt on lines 20..26
app/src/main/java/com/github/mateo762/myapplication/home/HomeActivity.kt on lines 19..27

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

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

    @RequiresApi(Build.VERSION_CODES.O)
    private fun setupWeekView() {
        weekView.setOnEventClickListener(this)
        weekView.eventLongPressListener = this
        weekView.emptyViewLongPressListener = this

    Method unfollowUser has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Confirmed

        override fun unfollowUser(currentUserId: String, targetUserId: String) {
            usersReference.child(currentUserId).child("followingPath")
                .addListenerForSingleValueEvent(object : ValueEventListener {
                    override fun onDataChange(snapshot: DataSnapshot) {
                        for (childSnapshot in snapshot.children) {

      Method onCreate has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          override fun onCreate(savedInstanceState: Bundle?) {
              super.onCreate(savedInstanceState)
              binding = ActivitySearchBinding.inflate(layoutInflater)
              setContentView(binding.root)
              super.onCreateDrawer()

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

            private fun registerUser(name:String, surname:String, email: String, password: String) {
        
                // add null check on text values
                if (name.isEmpty() || surname.isEmpty() || email.isEmpty() || password.isEmpty()) {
                    Toast.makeText(baseContext, R.string.error_empty_register, Toast.LENGTH_SHORT).show()

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

                      is State.Loading -> {
                          binding.infoTextView.visibility = View.VISIBLE
                          binding.ratingContainer.visibility = View.GONE
          
                          binding.infoTextView.text = context.getString(R.string.loading)
          app/src/main/java/com/github/mateo762/myapplication/coach_rating/CoachRatingView.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 117.

          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

                      is State.Failed -> {
                          binding.infoTextView.visibility = View.VISIBLE
                          binding.ratingContainer.visibility = View.GONE
          
                          binding.infoTextView.text = context.getString(R.string.fetch_coach_rating_error)
          app/src/main/java/com/github/mateo762/myapplication/coach_rating/CoachRatingView.kt on lines 53..58

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

          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

              override fun onCreateViewHolder(
                  parent: ViewGroup,
                  viewType: Int
              ): SearchItemViewHolder {
                  val binding =
          app/src/main/java/com/github/mateo762/myapplication/profile/ProfileGalleryAdapter.kt on lines 20..27
          app/src/main/java/com/github/mateo762/myapplication/profile/ProfileHabitsAdapter.kt on lines 17..21

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

          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

                  binding.earliestTextView.text = if (statsUiModel.earliestStart != "0") {
                      getString(R.string.earlystart, statsUiModel.earliestStart)
                  } else {
                      getString(R.string.na)
                  }
          app/src/main/java/com/github/mateo762/myapplication/profile/ProfileActivity.kt on lines 291..295

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

          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

                  binding.latestTextView.text = if (statsUiModel.earliestStart != "0") {
                      getString(R.string.lateend, statsUiModel.latestEnd)
                  } else {
                      getString(R.string.na)
                  }
          app/src/main/java/com/github/mateo762/myapplication/profile/ProfileActivity.kt on lines 286..290

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

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

          @RequiresApi(Build.VERSION_CODES.O)
          private fun scheduleHabit(context: Context, habit: HabitEntity) {
              val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
              val intent = Intent(context, HabitAlarmReceiver::class.java)
              intent.putExtra("habit_id", habit.id)

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

                fun stringToHabitEntity(data: String): List<HabitEntity> {
            /*        if (data == null) {
                        return Collections.emptyList()
                    }*/
                    val listType: Type = object : TypeToken<List<HabitEntity?>?>() {}.type
            app/src/main/java/com/github/mateo762/myapplication/room/HabitTypeConverter.kt on lines 34..40

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

            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

                fun stringToHabitDays(data: String): List<DayOfWeek>? {
                    /*if (data == null) {
                        return Collections.emptyList()
                    }*/
                    val listType: Type = object : TypeToken<List<DayOfWeek?>?>() {}.type
            app/src/main/java/com/github/mateo762/myapplication/room/HabitTypeConverter.kt on lines 15..21

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

            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

                                Text(
                                    text = stringResource(
                                        R.string.create_habit_end_time_text,
                                        habitEndTime.value
                                    ), modifier = Modifier
            app/src/main/java/com/github/mateo762/myapplication/ui/habits/CreateHabitScreen.kt on lines 127..134

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

            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

                                Text(
                                    text = stringResource(
                                        R.string.create_habit_start_time_text,
                                        habitStartTime.value
                                    ), modifier = Modifier
            app/src/main/java/com/github/mateo762/myapplication/ui/habits/CreateHabitScreen.kt on lines 148..155

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

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

                @RequiresApi(Build.VERSION_CODES.O)
                private fun uploadImage() {
                    if (imageData == null) {
                        showToast(getString(R.string.no_image_data))
                        startActivity(Intent(this, HomeActivity::class.java))

              Method getFirebaseHabitImagesFromPath has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  fun getFirebaseHabitImagesFromPath(path: String) {
                      imagesRef = FirebaseDatabase.getInstance()
                          .getReference(path)
              
                      imagesRef.addListenerForSingleValueEvent(object : ValueEventListener {

                Method setLiveDataObservers has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Confirmed

                    private fun setLiveDataObservers() {
                        profileViewModel.habitLiveData.observe(this) {
                            habitsAdapter.habits = it
                        }
                        profileViewModel.habitImagesLiveData.observe(this) {

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

                      private fun openFragmentSelected(fragment: Fragment): Int {
                          return supportFragmentManager.beginTransaction().replace(
                              R.id.navHostFragment, fragment
                          ).commit()
                      }
                  app/src/main/java/com/github/mateo762/myapplication/coaching/CoachingActivity.kt on lines 43..47
                  app/src/main/java/com/github/mateo762/myapplication/home/HomeActivity.kt on lines 46..50

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

                  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 3 locations. Consider refactoring.
                  Open

                      private fun openFragmentSelected(fragment: Fragment): Int {
                          return supportFragmentManager.beginTransaction().replace(
                              R.id.navHostFragment, fragment
                          ).commit()
                      }
                  app/src/main/java/com/github/mateo762/myapplication/habits/HabitsActivity.kt on lines 42..46
                  app/src/main/java/com/github/mateo762/myapplication/home/HomeActivity.kt on lines 46..50

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

                  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