-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for Clover PHP parser (clover.xml files) (#99)
- Loading branch information
Showing
8 changed files
with
430 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
require "../../spec_helper" | ||
|
||
Spectator.describe CoverageReporter::CloverParser do | ||
subject { described_class.new(base_path) } | ||
|
||
let(base_path) { nil } | ||
|
||
describe "#globs" do | ||
it "finds all cobertura files" do | ||
expect(Dir[subject.globs]).to contain( | ||
"spec/fixtures/clover/clover.xml", | ||
) | ||
end | ||
end | ||
|
||
describe "#matches?" do | ||
it "matches correct filenames" do | ||
expect(subject.matches?("spec/fixtures/clover/clover-phpcsutils.xml")).to eq true | ||
expect(subject.matches?("spec/fixtures/clover/clover-unleash.xml")).to eq true | ||
|
||
expect(subject.matches?("spec/fixtures/cobertura/cobertura.xml")).to eq false | ||
expect(subject.matches?("spec/fixtures/cobertura/cobertura-oneline.xml")).to eq false | ||
expect(subject.matches?("spec/fixtures/jacoco/jacoco-report.xml")).to eq false | ||
expect(subject.matches?("spec/fixtures/jacoco/jacoco-oneline-report.xml")).to eq false | ||
end | ||
end | ||
|
||
describe "#parse" do | ||
context "with clover-phpcsutils.xml" do | ||
let(filename) { "spec/fixtures/clover/clover-phpcsutils.xml" } | ||
|
||
it "parses the data correctly" do | ||
reports = subject.parse(filename) | ||
|
||
expect(reports.size).to eq 2 | ||
expect(reports[0].name).to match /.*AbstractArrayDeclarationSniff.php/ | ||
expect(reports[0].branches).to eq [] of UInt64? | ||
end | ||
end | ||
|
||
context "with clover-unleash.xml" do | ||
let(filename) { "spec/fixtures/clover/clover-unleash.xml" } | ||
|
||
it "parses the data correctly" do | ||
reports = subject.parse(filename) | ||
|
||
expect(reports.size).to eq 2 | ||
expect(reports[0].name).to eq("home/jaanus/Git/unleash/src/lib/create-config.ts") | ||
|
||
with_branches = reports.find! do |report| | ||
report.name == "home/jaanus/Git/unleash/src/lib/create-config.ts" | ||
end | ||
|
||
# <line num="1" count="1" type="stmt"/> | ||
expect(with_branches.coverage[0]).to eq 1 | ||
|
||
# no line | ||
expect(with_branches.coverage[3]).to eq nil | ||
|
||
# <line num="58" count="22" type="stmt"/> | ||
expect(with_branches.coverage[57]).to eq 22 | ||
|
||
# <line num="217" count="2" type="cond" truecount="0" falsecount="1"/> | ||
expect(with_branches.coverage[216]).to eq 2 | ||
|
||
# last line number | ||
# <line num="501" count="1" type="stmt"/> | ||
expect(with_branches.coverage.size).to eq 501 | ||
|
||
branches = with_branches.branches | ||
unless branches.nil? | ||
expect((branches.size / 4).to_i).to eq 35 | ||
|
||
# <line num="48" count="1" type="cond" truecount="1" falsecount="1"/> | ||
expect(branches[0]).to eq 48 | ||
expect(branches[1]).to eq 1 | ||
|
||
# <line num="54" count="1" type="cond" truecount="2" falsecount="0"/> | ||
expect(branches[4]).to eq 54 | ||
expect(branches[5]).to eq 2 | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<coverage generated="1693391816"> | ||
<project timestamp="1693391816"> | ||
<file name="/home/yu/projects/PHPCSUtils/PHPCSUtils/AbstractSniffs/AbstractArrayDeclarationSniff.php"> | ||
<class name="PHPCSUtils\AbstractSniffs\AbstractArrayDeclarationSniff" namespace="global"> | ||
<metrics complexity="44" methods="3" coveredmethods="3" conditionals="0" coveredconditionals="0" statements="79" coveredstatements="79" elements="82" coveredelements="82"/> | ||
</class> | ||
<line num="178" type="method" name="process" visibility="public" complexity="4" crap="4" count="13"/> | ||
<line num="181" type="stmt" count="13"/> | ||
<line num="182" type="stmt" count="1"/> | ||
<line num="184" type="stmt" count="1"/> | ||
<line num="187" type="stmt" count="12"/> | ||
<line num="188" type="stmt" count="12"/> | ||
<line num="190" type="stmt" count="1"/> | ||
<line num="193" type="stmt" count="11"/> | ||
<line num="194" type="stmt" count="11"/> | ||
<line num="195" type="stmt" count="11"/> | ||
<line num="196" type="stmt" count="11"/> | ||
<line num="197" type="stmt" count="11"/> | ||
<line num="199" type="stmt" count="11"/> | ||
<line num="200" type="stmt" count="11"/> | ||
<line num="201" type="stmt" count="2"/> | ||
<line num="204" type="stmt" count="11"/> | ||
<line num="207" type="stmt" count="11"/> | ||
<line num="208" type="stmt" count="11"/> | ||
<line num="236" type="method" name="processArray" visibility="public" complexity="14" crap="14" count="11"/> | ||
<line num="238" type="stmt" count="11"/> | ||
<line num="239" type="stmt" count="1"/> | ||
<line num="242" type="stmt" count="10"/> | ||
<line num="243" type="stmt" count="1"/> | ||
<line num="246" type="stmt" count="9"/> | ||
<line num="248" type="stmt" count="9"/> | ||
<line num="249" type="stmt" count="1"/> | ||
<line num="251" type="stmt" count="1"/> | ||
<line num="254" type="stmt" count="9"/> | ||
<line num="255" type="stmt" count="5"/> | ||
<line num="256" type="stmt" count="1"/> | ||
<line num="259" type="stmt" count="4"/> | ||
<line num="260" type="stmt" count="1"/> | ||
<line num="263" type="stmt" count="3"/> | ||
<line num="264" type="stmt" count="3"/> | ||
<line num="267" type="stmt" count="8"/> | ||
<line num="268" type="stmt" count="1"/> | ||
<line num="271" type="stmt" count="7"/> | ||
<line num="272" type="stmt" count="1"/> | ||
<line num="276" type="stmt" count="7"/> | ||
<line num="277" type="stmt" count="7"/> | ||
<line num="278" type="stmt" count="7"/> | ||
<line num="279" type="stmt" count="1"/> | ||
<line num="461" type="method" name="getActualArrayKey" visibility="public" complexity="18" crap="18" count="7"/> | ||
<line num="466" type="stmt" count="7"/> | ||
<line num="467" type="stmt" count="7"/> | ||
<line num="469" type="stmt" count="7"/> | ||
<line num="471" type="stmt" count="7"/> | ||
<line num="472" type="stmt" count="7"/> | ||
<line num="473" type="stmt" count="1"/> | ||
<line num="476" type="stmt" count="7"/> | ||
<line num="477" type="stmt" count="5"/> | ||
<line num="478" type="stmt" count="5"/> | ||
<line num="481" type="stmt" count="7"/> | ||
<line num="483" type="stmt" count="1"/> | ||
<line num="487" type="stmt" count="7"/> | ||
<line num="488" type="stmt" count="3"/> | ||
<line num="489" type="stmt" count="3"/> | ||
<line num="490" type="stmt" count="3"/> | ||
<line num="491" type="stmt" count="3"/> | ||
<line num="495" type="stmt" count="7"/> | ||
<line num="496" type="stmt" count="3"/> | ||
<line num="499" type="stmt" count="3"/> | ||
<line num="500" type="stmt" count="1"/> | ||
<line num="503" type="stmt" count="2"/> | ||
<line num="504" type="stmt" count="2"/> | ||
<line num="507" type="stmt" count="2"/> | ||
<line num="508" type="stmt" count="2"/> | ||
<line num="511" type="stmt" count="5"/> | ||
<line num="515" type="stmt" count="6"/> | ||
<line num="522" type="stmt" count="6"/> | ||
<line num="523" type="stmt" count="6"/> | ||
<line num="525" type="stmt" count="1"/> | ||
<line num="527" type="stmt" count="6"/> | ||
<line num="528" type="stmt" count="2"/> | ||
<line num="530" type="stmt" count="6"/> | ||
<line num="531" type="stmt" count="3"/> | ||
<line num="533" type="stmt" count="6"/> | ||
<line num="534" type="stmt" count="3"/> | ||
<line num="536" type="stmt" count="6"/> | ||
<line num="537" type="stmt" count="6"/> | ||
<line num="538" type="stmt" count="3"/> | ||
<line num="541" type="stmt" count="3"/> | ||
<metrics loc="552" ncloc="237" classes="1" methods="3" coveredmethods="3" conditionals="0" coveredconditionals="0" statements="79" coveredstatements="79" elements="82" coveredelements="82"/> | ||
</file> | ||
<file name="/home/yu/projects/PHPCSUtils/PHPCSUtils/BackCompat/BCFile.php"> | ||
<class name="PHPCSUtils\BackCompat\BCFile" namespace="global"> | ||
<metrics complexity="96" methods="13" coveredmethods="13" conditionals="0" coveredconditionals="0" statements="244" coveredstatements="244" elements="257" coveredelements="257"/> | ||
</class> | ||
<line num="99" type="method" name="getDeclarationName" visibility="public" complexity="15" crap="15" count="34"/> | ||
<metrics loc="858" ncloc="400" classes="1" methods="13" coveredmethods="13" conditionals="0" coveredconditionals="0" statements="244" coveredstatements="244" elements="257" coveredelements="257"/> | ||
</file> | ||
<metrics files="37" loc="11201" ncloc="5558" classes="36" methods="182" coveredmethods="163" conditionals="0" coveredconditionals="0" statements="2420" coveredstatements="2376" elements="2602" coveredelements="2539"/> | ||
</project> | ||
</coverage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<coverage generated="1676462812802" clover="3.2.0"> | ||
<project timestamp="1676462812803" name="All files"> | ||
<metrics statements="1446" coveredstatements="634" conditionals="401" coveredconditionals="103" methods="598" coveredmethods="86" elements="2445" coveredelements="823" complexity="0" loc="1446" ncloc="1446" packages="10" files="82" classes="82"/> | ||
<package name="lib"> | ||
<metrics statements="152" coveredstatements="119" conditionals="103" coveredconditionals="68" methods="31" coveredmethods="23"/> | ||
<file name="create-config.ts" path="/home/jaanus/Git/unleash/src/lib/create-config.ts"> | ||
<metrics statements="132" coveredstatements="107" conditionals="99" coveredconditionals="66" methods="23" coveredmethods="18"/> | ||
<line num="1" count="1" type="stmt"/> | ||
<line num="2" count="1" type="stmt"/> | ||
<line num="3" count="1" type="stmt"/> | ||
<line num="21" count="1" type="stmt"/> | ||
<line num="22" count="1" type="stmt"/> | ||
<line num="23" count="1" type="stmt"/> | ||
<line num="24" count="1" type="stmt"/> | ||
<line num="25" count="1" type="stmt"/> | ||
<line num="26" count="1" type="stmt"/> | ||
<line num="31" count="1" type="stmt"/> | ||
<line num="36" count="1" type="stmt"/> | ||
<line num="40" count="1" type="stmt"/> | ||
<line num="44" count="1" type="stmt"/> | ||
<line num="45" count="1" type="stmt"/> | ||
<line num="46" count="1" type="stmt"/> | ||
<line num="48" count="1" type="cond" truecount="1" falsecount="1"/> | ||
<line num="50" count="0" type="stmt"/> | ||
<line num="54" count="1" type="cond" truecount="2" falsecount="0"/> | ||
<line num="58" count="22" type="stmt"/> | ||
<line num="62" count="1" type="stmt"/> | ||
<line num="72" count="1" type="stmt"/> | ||
<line num="80" count="1" type="stmt"/> | ||
<line num="81" count="1" type="cond" truecount="0" falsecount="1"/> | ||
<line num="82" count="0" type="stmt"/> | ||
<line num="87" count="1" type="cond" truecount="0" falsecount="1"/> | ||
<line num="88" count="0" type="stmt"/> | ||
<line num="94" count="1" type="stmt"/> | ||
<line num="102" count="1" type="cond" truecount="2" falsecount="0"/> | ||
<line num="103" count="1" type="stmt"/> | ||
<line num="107" count="1" type="stmt"/> | ||
<line num="110" count="1" type="stmt"/> | ||
<line num="113" count="1" type="stmt"/> | ||
<line num="114" count="0" type="stmt"/> | ||
<line num="115" count="0" type="stmt"/> | ||
<line num="119" count="1" type="stmt"/> | ||
<line num="149" count="1" type="stmt"/> | ||
<line num="159" count="1" type="stmt"/> | ||
<line num="185" count="1" type="stmt"/> | ||
<line num="190" count="1" type="stmt"/> | ||
<line num="198" count="1" type="stmt"/> | ||
<line num="207" count="1" type="stmt"/> | ||
<line num="216" count="1" type="stmt"/> | ||
<line num="217" count="2" type="cond" truecount="0" falsecount="1"/> | ||
<line num="219" count="0" type="stmt"/> | ||
<line num="221" count="2" type="stmt"/> | ||
<line num="224" count="1" type="stmt"/> | ||
<line num="225" count="1" type="stmt"/> | ||
<line num="226" count="2" type="cond" truecount="1" falsecount="0"/> | ||
<line num="228" count="2" type="stmt"/> | ||
<line num="229" count="2" type="stmt"/> | ||
<line num="231" count="0" type="stmt"/> | ||
<line num="234" count="1" type="stmt"/> | ||
<line num="237" count="1" type="cond" truecount="0" falsecount="1"/> | ||
<line num="238" count="0" type="stmt"/> | ||
<line num="244" count="1" type="stmt"/> | ||
<line num="252" count="1" type="stmt"/> | ||
<line num="253" count="3" type="cond" truecount="1" falsecount="0"/> | ||
<line num="254" count="3" type="stmt"/> | ||
<line num="256" count="0" type="stmt"/> | ||
<line num="257" count="0" type="stmt"/> | ||
<line num="258" count="0" type="cond" truecount="0" falsecount="1"/> | ||
<line num="259" count="0" type="cond" truecount="0" falsecount="1"/> | ||
<line num="260" count="0" type="stmt"/> | ||
<line num="268" count="0" type="stmt"/> | ||
<line num="269" count="0" type="stmt"/> | ||
<line num="271" count="0" type="stmt"/> | ||
<line num="274" count="1" type="stmt"/> | ||
<line num="275" count="1" type="stmt"/> | ||
<line num="291" count="1" type="stmt"/> | ||
<line num="292" count="1" type="stmt"/> | ||
<line num="293" count="1" type="cond" truecount="0" falsecount="1"/> | ||
<line num="294" count="0" type="stmt"/> | ||
<line num="296" count="1" type="stmt"/> | ||
<line num="299" count="1" type="stmt"/> | ||
<line num="302" count="1" type="cond" truecount="1" falsecount="0"/> | ||
<line num="303" count="1" type="stmt"/> | ||
<line num="306" count="0" type="stmt"/> | ||
<line num="315" count="1" type="stmt"/> | ||
<line num="316" count="1" type="cond" truecount="2" falsecount="0"/> | ||
<line num="317" count="1" type="cond" truecount="2" falsecount="0"/> | ||
<line num="318" count="1" type="cond" truecount="2" falsecount="0"/> | ||
<line num="319" count="1" type="cond" truecount="2" falsecount="0"/> | ||
<line num="320" count="1" type="cond" truecount="2" falsecount="0"/> | ||
<line num="321" count="1" type="stmt"/> | ||
<line num="330" count="1" type="stmt"/> | ||
<line num="331" count="1" type="stmt"/> | ||
<line num="336" count="1" type="stmt"/> | ||
<line num="337" count="1" type="cond" truecount="0" falsecount="1"/> | ||
<line num="338" count="0" type="stmt"/> | ||
<line num="341" count="1" type="stmt"/> | ||
<line num="344" count="0" type="stmt"/> | ||
<line num="345" count="1" type="stmt"/> | ||
<line num="347" count="1" type="cond" truecount="1" falsecount="1"/> | ||
<line num="348" count="0" type="stmt"/> | ||
<line num="349" count="1" type="cond" truecount="0" falsecount="1"/> | ||
<line num="350" count="0" type="stmt"/> | ||
<line num="352" count="1" type="stmt"/> | ||
<line num="353" count="1" type="cond" truecount="2" falsecount="2"/> | ||
<line num="354" count="0" type="stmt"/> | ||
<line num="357" count="1" type="cond" truecount="0" falsecount="1"/> | ||
<line num="361" count="0" type="stmt"/> | ||
<line num="365" count="1" type="stmt"/> | ||
<line num="372" count="1" type="stmt"/> | ||
<line num="378" count="1" type="cond" truecount="3" falsecount="0"/> | ||
<line num="379" count="1" type="cond" truecount="1" falsecount="1"/> | ||
<line num="380" count="1" type="stmt"/> | ||
<line num="382" count="1" type="stmt"/> | ||
<line num="387" count="1" type="stmt"/> | ||
<line num="392" count="1" type="stmt"/> | ||
<line num="394" count="1" type="stmt"/> | ||
<line num="402" count="1" type="stmt"/> | ||
<line num="404" count="1" type="stmt"/> | ||
<line num="409" count="1" type="stmt"/> | ||
<line num="410" count="1" type="stmt"/> | ||
<line num="412" count="1" type="stmt"/> | ||
<line num="414" count="1" type="stmt"/> | ||
<line num="417" count="1" type="cond" truecount="1" falsecount="1"/> | ||
<line num="418" count="0" type="stmt"/> | ||
<line num="420" count="1" type="cond" truecount="2" falsecount="0"/> | ||
<line num="423" count="1" type="cond" truecount="2" falsecount="0"/> | ||
<line num="431" count="1" type="cond" truecount="2" falsecount="0"/> | ||
<line num="435" count="1" type="cond" truecount="1" falsecount="1"/> | ||
<line num="438" count="1" type="cond" truecount="2" falsecount="0"/> | ||
<line num="442" count="1" type="cond" truecount="2" falsecount="0"/> | ||
<line num="446" count="1" type="cond" truecount="1" falsecount="1"/> | ||
<line num="450" count="1" type="stmt"/> | ||
<line num="455" count="1" type="stmt"/> | ||
<line num="460" count="1" type="cond" truecount="1" falsecount="1"/> | ||
<line num="464" count="1" type="stmt"/> | ||
<line num="466" count="1" type="cond" truecount="2" falsecount="0"/> | ||
<line num="467" count="1" type="stmt"/> | ||
<line num="501" count="1" type="stmt"/> | ||
</file> | ||
<file name="default-custom-auth-deny-all.ts" path="/home/jaanus/Git/unleash/src/lib/default-custom-auth-deny-all.ts"> | ||
<metrics statements="6" coveredstatements="2" conditionals="0" coveredconditionals="0" methods="2" coveredmethods="1"/> | ||
<line num="4" count="1" type="stmt"/> | ||
<line num="6" count="1" type="stmt"/> | ||
<line num="11" count="0" type="stmt"/> | ||
<line num="12" count="0" type="stmt"/> | ||
<line num="13" count="0" type="stmt"/> | ||
<line num="14" count="0" type="stmt"/> | ||
</file> | ||
</package> | ||
</project> | ||
</coverage> | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.