Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Code coverage reports last curly brace as uncovered in Kotlin code #5523

Open
Rd4dev opened this issue Aug 26, 2024 · 0 comments
Open
Labels
bug End user-perceivable behaviors which are not desirable. Impact: Medium Moderate perceived user impact (non-blocking bugs and general improvements). Work: Low Solution is clear and broken into good-first-issue-sized chunks.

Comments

@Rd4dev
Copy link
Collaborator

Rd4dev commented Aug 26, 2024

Describe the bug

When generating code coverage reports using the code coverage tool for the Oppia Android, the last curly brace of some Kotlin functions is incorrectly marked as uncovered.

This issue has been observed in files: CpuPerformanceSnapshotter.kt, CommandExecutorImpl.kt, and TodoOpenCheck.kt.

It was suggested that there could be two potential causes:

  1. The code is not finishing execution in the test, which may require adding properly configured tests to ensure complete execution.
  2. Dead code is being generated by the Kotlin compiler, which would require further investigation and possibly bytecode analysis.

Steps To Reproduce

Code snippet from CpuPerformanceSnapshotter.kt:

    @OptIn(ObsoleteCoroutinesApi::class)
    private fun createCommandQueueActor(): SendChannel<CommandMessage> {
      return coroutineScope.actor(capacity = Channel.UNLIMITED) {
        for (message in channel) {
         ...
        }
-     }
    }

Generate code coverage report for the file CpuPerformanceSnapshotter.kt:

bazel run //scripts:run_coverage -- $(pwd) domain/src/main/java/org/oppia/android/domain/oppialogger/analytics/CpuPerformanceSnapshotter.kt

The generated report:

image

Similarly observed with

CommandExecutorImpl.kt

path: scripts/src/java/org/oppia/android/scripts/common/CommandExecutorImpl.kt

image

TodoOpenCheck.kt

path: scripts/src/java/org/oppia/android/scripts/todo/TodoOpenCheck.kt

image

Expected Behavior

The last curly brace should be marked as covered in the report if the function is fully executed in the tests.

Bazel Version

6.5.0

Additional context

Related issue: jacoco/jacoco#884

What device/emulator are you using?

No response

Which Android version is your device/emulator running?

No response

Which version of the Oppia Android app are you using?

No response

@Rd4dev Rd4dev added bug End user-perceivable behaviors which are not desirable. triage needed labels Aug 26, 2024
@adhiamboperes adhiamboperes added Impact: Medium Moderate perceived user impact (non-blocking bugs and general improvements). Work: Low Solution is clear and broken into good-first-issue-sized chunks. labels Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug End user-perceivable behaviors which are not desirable. Impact: Medium Moderate perceived user impact (non-blocking bugs and general improvements). Work: Low Solution is clear and broken into good-first-issue-sized chunks.
Development

No branches or pull requests

6 participants
@seanlip @adhiamboperes @Rd4dev and others