jacoco / jacoco/jacoco

Improve FinallyFilter

Open
#2,020 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

component: core.filters language: Java
Dominant language
Java
Stars
4.6k
Forks
1.2k
Avg merge
1d 9h
Merged PRs (30d)
23

Description

class Example {
	private static String example(int i) {
		try {
			switch (i) {
			case 0:
				return "case 0";
			case 1:
				return "case 1";
			}
		} finally {
			System.out.println(i == 0); // currently 1 of 4 branches missed
		}
		return "";
	}

	public static void main(String[] args) {
		example(0);
		example(1);
		example(2);
	}
}

switch

  • is last inside try-finally
  • without default
  • return in all cases

class Example {
	public static void main(String[] args) {
		loop: for (int i = 0; i <= 5; i++) {
			try {
				switch (i) {
				case 1:
					System.out.println("case 1");
					break;
				case 5:
					break loop;
				default:
					System.out.println("default");
					break;
				}
				System.out.println();
			} finally {
				System.out.println(i == 0); // currently 1 of 4 branches missed
			}
		}
	}
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading FinallyFilter and reproduce the two Java examples from the issue to understand which switch paths are reported as missed. Done means the filter handles the shown try-finally switch cases without incorrectly reporting the finally branch as missed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.