Skip to content

Commit

Permalink
Enhanced coverage processing (qodo-ai#2)
Browse files Browse the repository at this point in the history
* While earlier PR[qodo-ai#230] managed to breakdown processing
  code into a class hierarechy, there wasnt any changes
  made to the code. This PR brings in enhancements to
  coverage processing where coverage data is stored by
  entity (Class or File).

* Coverage data is stored using a FQDN so that conflicts
  are taken care. This closes[qodo-ai#251]

* Earlier PR broke the behaviour of the agent that only
  target file coverage is considered if the global coverage
  flag is not set by the user, this PR fixes it to bring
  back the original behaviour.
  • Loading branch information
coderustic committed Jan 5, 2025
1 parent 3496069 commit eb95d4e
Show file tree
Hide file tree
Showing 7 changed files with 821 additions and 181 deletions.
1 change: 0 additions & 1 deletion cover_agent/UnitTestValidator.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,6 @@ def post_process_coverage_report(self, time_of_test_command: int):
report_path=self.code_coverage_report_path,
src_file_path=self.source_file_path,
is_global_coverage_enabled=self.use_report_coverage_feature_flag,
file_pattern=None,
diff_coverage_report_path=self.diff_cover_report_path,
)
self.logger.info(
Expand Down
255 changes: 118 additions & 137 deletions cover_agent/coverage/processor.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions sample-reports/jacocoTestReport.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
GROUP,PACKAGE,CLASS,INSTRUCTION_MISSED,INSTRUCTION_COVERED,BRANCH_MISSED,BRANCH_COVERED,LINE_MISSED,LINE_COVERED,COMPLEXITY_MISSED,COMPLEXITY_COVERED,METHOD_MISSED,METHOD_COVERED
cover-agent,com.davidparry.cover,User,12,0,0,0,5,0,2,0,2,0
cover-agent,com.davidparry.cover,SimpleMathOperations,34,11,4,0,7,3,5,3,3,3
108 changes: 108 additions & 0 deletions sample-reports/jacocoTestReport.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.1//EN" "report.dtd">
<report name="cover-agent">
<sessioninfo id="dhruv-901682b" start="1736034030672" dump="1736034033451" />
<package name="com/davidparry/cover">
<class name="com/davidparry/cover/User" sourcefilename="SimpleMathOperations.java">
<method name="&lt;init&gt;" desc="(Ljava/lang/String;I)V" line="5">
<counter type="INSTRUCTION" missed="9" covered="0" />
<counter type="LINE" missed="4" covered="0" />
<counter type="COMPLEXITY" missed="1" covered="0" />
<counter type="METHOD" missed="1" covered="0" />
</method>
<method name="getName" desc="()Ljava/lang/String;" line="10">
<counter type="INSTRUCTION" missed="3" covered="0" />
<counter type="LINE" missed="1" covered="0" />
<counter type="COMPLEXITY" missed="1" covered="0" />
<counter type="METHOD" missed="1" covered="0" />
</method>
<counter type="INSTRUCTION" missed="12" covered="0" />
<counter type="LINE" missed="5" covered="0" />
<counter type="COMPLEXITY" missed="2" covered="0" />
<counter type="METHOD" missed="2" covered="0" />
<counter type="CLASS" missed="1" covered="0" />
</class>
<class name="com/davidparry/cover/SimpleMathOperations"
sourcefilename="SimpleMathOperations.java">
<method name="&lt;init&gt;" desc="()V" line="13">
<counter type="INSTRUCTION" missed="0" covered="3" />
<counter type="LINE" missed="0" covered="1" />
<counter type="COMPLEXITY" missed="0" covered="1" />
<counter type="METHOD" missed="0" covered="1" />
</method>
<method name="add" desc="(II)I" line="16">
<counter type="INSTRUCTION" missed="0" covered="4" />
<counter type="LINE" missed="0" covered="1" />
<counter type="COMPLEXITY" missed="0" covered="1" />
<counter type="METHOD" missed="0" covered="1" />
</method>
<method name="subtract" desc="(II)I" line="20">
<counter type="INSTRUCTION" missed="0" covered="4" />
<counter type="LINE" missed="0" covered="1" />
<counter type="COMPLEXITY" missed="0" covered="1" />
<counter type="METHOD" missed="0" covered="1" />
</method>
<method name="multiply" desc="(II)I" line="24">
<counter type="INSTRUCTION" missed="4" covered="0" />
<counter type="LINE" missed="1" covered="0" />
<counter type="COMPLEXITY" missed="1" covered="0" />
<counter type="METHOD" missed="1" covered="0" />
</method>
<method name="divide" desc="(II)D" line="28">
<counter type="INSTRUCTION" missed="13" covered="0" />
<counter type="BRANCH" missed="2" covered="0" />
<counter type="LINE" missed="3" covered="0" />
<counter type="COMPLEXITY" missed="2" covered="0" />
<counter type="METHOD" missed="1" covered="0" />
</method>
<method name="fibonacci" desc="(I)I" line="35">
<counter type="INSTRUCTION" missed="17" covered="0" />
<counter type="BRANCH" missed="2" covered="0" />
<counter type="LINE" missed="3" covered="0" />
<counter type="COMPLEXITY" missed="2" covered="0" />
<counter type="METHOD" missed="1" covered="0" />
</method>
<counter type="INSTRUCTION" missed="34" covered="11" />
<counter type="BRANCH" missed="4" covered="0" />
<counter type="LINE" missed="7" covered="3" />
<counter type="COMPLEXITY" missed="5" covered="3" />
<counter type="METHOD" missed="3" covered="3" />
<counter type="CLASS" missed="0" covered="1" />
</class>
<sourcefile name="SimpleMathOperations.java">
<line nr="5" mi="2" ci="0" mb="0" cb="0" />
<line nr="6" mi="3" ci="0" mb="0" cb="0" />
<line nr="7" mi="3" ci="0" mb="0" cb="0" />
<line nr="8" mi="1" ci="0" mb="0" cb="0" />
<line nr="10" mi="3" ci="0" mb="0" cb="0" />
<line nr="13" mi="0" ci="3" mb="0" cb="0" />
<line nr="16" mi="0" ci="4" mb="0" cb="0" />
<line nr="20" mi="0" ci="4" mb="0" cb="0" />
<line nr="24" mi="4" ci="0" mb="0" cb="0" />
<line nr="28" mi="2" ci="0" mb="2" cb="0" />
<line nr="29" mi="5" ci="0" mb="0" cb="0" />
<line nr="31" mi="6" ci="0" mb="0" cb="0" />
<line nr="35" mi="3" ci="0" mb="2" cb="0" />
<line nr="36" mi="2" ci="0" mb="0" cb="0" />
<line nr="38" mi="12" ci="0" mb="0" cb="0" />
<counter type="INSTRUCTION" missed="46" covered="11" />
<counter type="BRANCH" missed="4" covered="0" />
<counter type="LINE" missed="12" covered="3" />
<counter type="COMPLEXITY" missed="7" covered="3" />
<counter type="METHOD" missed="5" covered="3" />
<counter type="CLASS" missed="1" covered="1" />
</sourcefile>
<counter type="INSTRUCTION" missed="46" covered="11" />
<counter type="BRANCH" missed="4" covered="0" />
<counter type="LINE" missed="12" covered="3" />
<counter type="COMPLEXITY" missed="7" covered="3" />
<counter type="METHOD" missed="5" covered="3" />
<counter type="CLASS" missed="1" covered="1" />
</package>
<counter type="INSTRUCTION" missed="46" covered="11" />
<counter type="BRANCH" missed="4" covered="0" />
<counter type="LINE" missed="12" covered="3" />
<counter type="COMPLEXITY" missed="7" covered="3" />
<counter type="METHOD" missed="5" covered="3" />
<counter type="CLASS" missed="1" covered="1" />
</report>
Loading

0 comments on commit eb95d4e

Please sign in to comment.