Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions codeflash/languages/java/build_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ def add_jacoco_plugin_to_pom(pom_path: Path) -> bool:
return False

# JaCoCo plugin XML to insert (indented for typical pom.xml format)
# Note: For multi-module projects where tests are in a separate module,
# we configure the report to look in multiple directories for classes
jacoco_plugin = """
<plugin>
<groupId>org.jacoco</groupId>
Expand All @@ -724,6 +726,12 @@ def add_jacoco_plugin_to_pom(pom_path: Path) -> bool:
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- For multi-module projects, include dependency classes -->
<includes>
<include>**/*.class</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>""".format(version=JACOCO_PLUGIN_VERSION)
Expand Down
20 changes: 12 additions & 8 deletions codeflash/result/critic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
MIN_TESTCASE_PASSED_THRESHOLD,
MIN_THROUGHPUT_IMPROVEMENT_THRESHOLD,
)
from codeflash.models.models import CoverageStatus
from codeflash.models.test_type import TestType

if TYPE_CHECKING:
Expand Down Expand Up @@ -206,14 +207,17 @@ def quantity_of_tests_critic(candidate_result: OptimizedCandidateResult | Origin
def coverage_critic(original_code_coverage: CoverageData | None) -> bool:
"""Check if the coverage meets the threshold.

For languages without coverage support (like JavaScript), returns True if no coverage data is available.
Java now uses JaCoCo for coverage collection and is subject to coverage threshold checks.
Returns True when:
- Coverage data exists, was parsed successfully, and meets the threshold, OR
- No coverage data is available (skip the check for languages/projects without coverage support), OR
- Coverage data exists but was NOT_FOUND (e.g., JaCoCo report not generated in multi-module projects)
"""
from codeflash.languages import is_javascript

if original_code_coverage:
# If coverage data was not found (e.g., JaCoCo report doesn't exist in multi-module projects),
# skip the coverage check instead of failing with 0% coverage
if original_code_coverage.status == CoverageStatus.NOT_FOUND:
return True
return original_code_coverage.coverage >= COVERAGE_THRESHOLD
# For JavaScript, coverage is not implemented yet, so skip the check
if is_javascript():
return True
return False
# When no coverage data is available (e.g., JavaScript, Java multi-module projects),
# skip the coverage check and allow optimization to proceed
return True
Loading