StudyDistractor/sdp

View on GitHub

Showing 42 of 43 total issues

Method FriendsScreen has a Cognitive Complexity of 67 (exceeds 10 allowed). Consider refactoring.
Open

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun  FriendsScreen(friendsViewModel: FriendsViewModel) {
    fun showFailureToast(context: Context, message: String) {
        Toast.makeText(context, "Failure: $message", Toast.LENGTH_SHORT)
Severity: Minor
Found in app/src/main/java/com/github/studydistractor/sdp/ui/FriendsScreen.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 MapsScreen has a Cognitive Complexity of 33 (exceeds 10 allowed). Consider refactoring.
Open

@Composable
fun MapsScreen(
    mapViewModel: MapViewModel,
    onDistractionClick: (Distraction) -> Unit,
    onEventClick: (Event) -> Unit
Severity: Minor
Found in app/src/main/java/com/github/studydistractor/sdp/ui/MapsScreen.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 FriendsScreen has 127 lines of code (exceeds 50 allowed). Consider refactoring.
Open

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun  FriendsScreen(friendsViewModel: FriendsViewModel) {
    fun showFailureToast(context: Context, message: String) {
        Toast.makeText(context, "Failure: $message", Toast.LENGTH_SHORT)
Severity: Major
Found in app/src/main/java/com/github/studydistractor/sdp/ui/FriendsScreen.kt - About 4 hrs to fix

    Method ListedDistraction has a Cognitive Complexity of 31 (exceeds 10 allowed). Consider refactoring.
    Open

    /**
     * Screens that represents how one distraction is displayed in the list of distraction
     */
    @OptIn(ExperimentalMaterial3Api::class)
    @Composable

    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 RegisterScreen has a Cognitive Complexity of 26 (exceeds 10 allowed). Consider refactoring.
    Open

    @OptIn(ExperimentalMaterial3Api::class)
    @Composable
    fun RegisterScreen(
        onSuccess: () -> Unit,
        registerViewModel: RegisterViewModel
    Severity: Minor
    Found in app/src/main/java/com/github/studydistractor/sdp/ui/RegisterScreen.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 observeHistory has a Cognitive Complexity of 26 (exceeds 10 allowed). Consider refactoring.
    Open

        override fun observeHistory(userId: String, onHistoryChange: (List<Event>) -> Unit) {
            if(currentHistoryListener.isPresent) eventParticipantsDatabaseRef.removeEventListener(currentHistoryListener.get())
    
            currentHistoryListener = Optional.of(eventParticipantsDatabaseRef.addValueEventListener(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 DistractionListScreen has a Cognitive Complexity of 24 (exceeds 10 allowed). Consider refactoring.
    Open

    /**
     * Screens that represent a list of scrollable distraction that we can then filter
     */
    @Composable
    fun DistractionListScreen(

    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 ListedEvent has a Cognitive Complexity of 24 (exceeds 10 allowed). Consider refactoring.
    Open

    @OptIn(ExperimentalMaterial3Api::class)
    @Composable
    fun ListedEvent(
        event: Event,
        countPeople: Int,

    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 RegisterScreen has 84 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    @OptIn(ExperimentalMaterial3Api::class)
    @Composable
    fun RegisterScreen(
        onSuccess: () -> Unit,
        registerViewModel: RegisterViewModel
    Severity: Major
    Found in app/src/main/java/com/github/studydistractor/sdp/ui/RegisterScreen.kt - About 2 hrs to fix

      Method LoginScreen has 80 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      /**
       * Author: Bluedrack and AdrienBouquet
       */
      @OptIn(ExperimentalMaterial3Api::class)
      @Composable
      Severity: Major
      Found in app/src/main/java/com/github/studydistractor/sdp/ui/LoginScreen.kt - About 2 hrs to fix

        Method ListedEvent has 75 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        @OptIn(ExperimentalMaterial3Api::class)
        @Composable
        fun ListedEvent(
            event: Event,
            countPeople: Int,

          Method onDataChange has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
          Open

                      override fun onDataChange(snapshot: DataSnapshot) {
                          participationsCache.clear()
                          snapshot.children.forEach {eventParticipantsRaw ->
                              val eventParticipants = eventParticipantsRaw.value as Map<String, Boolean>
                              Log.d("evhi", eventParticipants.toString())

          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 ListedDistraction has 59 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          /**
           * Screens that represents how one distraction is displayed in the list of distraction
           */
          @OptIn(ExperimentalMaterial3Api::class)
          @Composable

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

                    _distractionStatModel.fetchDistractionTags(_uiState.value.did).continueWith { t ->
                        _uiState.update { it.copy(tags = t.result) }
                    }
            app/src/main/java/com/github/studydistractor/sdp/distractionStat/DistractionStatViewModel.kt on lines 50..52
            app/src/main/java/com/github/studydistractor/sdp/distractionStat/DistractionStatViewModel.kt on lines 56..60
            app/src/main/java/com/github/studydistractor/sdp/distractionStat/DistractionStatViewModel.kt on lines 61..64

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

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

                    _distractionStatModel.fetchLikeCount(_uiState.value.did).continueWith{ t ->
                        _uiState.update {
                            it.copy(likes = t.result)
                        }
                    }
            app/src/main/java/com/github/studydistractor/sdp/distractionStat/DistractionStatViewModel.kt on lines 50..52
            app/src/main/java/com/github/studydistractor/sdp/distractionStat/DistractionStatViewModel.kt on lines 53..55
            app/src/main/java/com/github/studydistractor/sdp/distractionStat/DistractionStatViewModel.kt on lines 61..64

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

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

                    _distractionStatModel.fetchDistractionFeedback(_uiState.value.did).continueWith{
                            t-> _uiState.update { it.copy(feedbacks = t.result) }
                    }
            app/src/main/java/com/github/studydistractor/sdp/distractionStat/DistractionStatViewModel.kt on lines 53..55
            app/src/main/java/com/github/studydistractor/sdp/distractionStat/DistractionStatViewModel.kt on lines 56..60
            app/src/main/java/com/github/studydistractor/sdp/distractionStat/DistractionStatViewModel.kt on lines 61..64

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

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

                    _distractionStatModel.fetchDislikeCount(_uiState.value.did).continueWith{
                        t ->
                        _uiState.update { it.copy(dislikes = t.result) }
                    }
            app/src/main/java/com/github/studydistractor/sdp/distractionStat/DistractionStatViewModel.kt on lines 50..52
            app/src/main/java/com/github/studydistractor/sdp/distractionStat/DistractionStatViewModel.kt on lines 53..55
            app/src/main/java/com/github/studydistractor/sdp/distractionStat/DistractionStatViewModel.kt on lines 56..60

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

            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 observeHistory has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
            Open

                override fun observeHistory(userId: String, onHistoryChange: (List<Event>) -> Unit) {
                    Log.d("DEBUG", "IS CALLED")
                    service.observeHistory(userId){
                        if(OnlineStatus().isOnline(connectivityManager)){
                            val h = it.map{it.toEventEntity()}

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

                    if (!checkPhoneFormat(uiState.value.phoneNumber)) {
                        return Tasks.forException(Exception("phoneNumber is invalid"))
                    }
            app/src/main/java/com/github/studydistractor/sdp/createUser/CreateUserViewModel.kt on lines 114..116
            app/src/main/java/com/github/studydistractor/sdp/createUser/CreateUserViewModel.kt on lines 118..120

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

            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

                    if (!checkNameFormat(uiState.value.firstname)) {
                        return Tasks.forException(Exception("firstname is invalid"))
                    }
            app/src/main/java/com/github/studydistractor/sdp/createUser/CreateUserViewModel.kt on lines 118..120
            app/src/main/java/com/github/studydistractor/sdp/createUser/CreateUserViewModel.kt on lines 122..124

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

            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