procrastinot-team/procrastinot

View on GitHub

Showing 17 of 117 total issues

Method handleResults has a Cognitive Complexity of 63 (exceeds 20 allowed). Consider refactoring.
Open

    private fun handleResults(task: Task<GoogleSignInAccount>) {
        if (task.isSuccessful) {
            val account: GoogleSignInAccount? = task.result
            if (account != null) {
                val credential = GoogleAuthProvider.getCredential(account.idToken, null)

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

@RequiresApi(Build.VERSION_CODES.O)
private fun saveHabit(
    context: Context, habitName: String, habitDays: List<DayOfWeek>,
    habitStartTime: MutableState<String>, habitEndTime: MutableState<String>,
    askingForCoach: MutableState<Boolean>

    Method registerUser has a Cognitive Complexity of 31 (exceeds 20 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()

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

        private fun handleResults(task: Task<GoogleSignInAccount>) {
            if (task.isSuccessful) {
                val account: GoogleSignInAccount? = task.result
                if (account != null) {
                    val credential = GoogleAuthProvider.getCredential(account.idToken, null)

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

              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)

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

                      Method getFirebaseCoachableHabitsFromPath has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                      Open

                          private fun getFirebaseCoachableHabitsFromPath(path: String) {
                              // Initialize Firebase database reference
                              habitsRef = FirebaseDatabase.getInstance().getReference(path)
                              habitsRef.addListenerForSingleValueEvent(object : ValueEventListener {
                                  override fun onDataChange(snapshot: DataSnapshot) {

                      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 saveHabit has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          context: Context, habitName: String, habitDays: List<DayOfWeek>,
                          habitStartTime: MutableState<String>, habitEndTime: MutableState<String>,
                          askingForCoach: MutableState<Boolean>

                        Avoid deeply nested control flow statements.
                        Open

                                                    if (uid == null || email == null || displayName == null) {
                                                        showToastMessage( R.string.user_data_error)
                                                    } else {
                                                        val users: MutableMap<String, UserEntity> = HashMap()
                                                        val u = UserEntity(uid,displayName,"username", email, ArrayList<HabitEntity>(), listOf(), listOf(), listOf())

                          Method onUploadButtonClick has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          private fun onUploadButtonClick(context: Context, coroutineScope: CoroutineScope, userId: String, habitId: String, image: Int) {

                            Method habitToWeekViewEvent has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                habit: HabitEntity,
                                eventId: Long,
                                color: Int,
                                date: LocalDateTime,
                                isTest: Boolean
                              Severity
                              Category
                              Status
                              Source
                              Language