commit ddced31a9140c5540b49332d9209d0606eb6ea8b from: Sergey Bronnikov date: Fri Dec 15 19:43:27 2017 UTC Update XML structs commit - 5c3f51c09ac0514b520f33fcafeef84f13226f41 commit + ddced31a9140c5540b49332d9209d0606eb6ea8b blob - 5cace18bf4b2a76810f3366d4c64f042f220fbec blob + 32a206a7539114b54117e7d5acb6bb555a99ea45 --- parser/cobertura.go +++ parser/cobertura.go @@ -6,18 +6,21 @@ import ( "io/ioutil" ) -type CoberturaReport struct { - XMLName xml.Name `xml:"coverage,attr,omitempty"` - LinesValid int `xml:"lines-valid,attr,omitempty"` - LinesCovered int `xml:"lines-covered,attr,omitempty"` - LineRate int `xml:"line-rate,attr,omitempty"` - BranchesValid int `xml:"branches-valid,attr,omitempty"` - BranchesCovered int `xml:"branches-covered,attr,omitempty"` - Timestamp int `xml:"timstamp,attr,omitempty"` - Complexity int `xml:complexity,attr,omitempty` - Version int `xml:version,attr,omitempty` - //Sources []Source `xml:"source"` - //Packages []Package `xml:"package"` +type Coverage struct { + XMLName xml.Name `xml:"coverage"` + Name string `xml:"name,attr"` + LinesValid int `xml:"lines-valid,attr,omitempty"` + LinesCovered int `xml:"lines-covered,attr,omitempty"` + LineRate float64 `xml:"line-rate,attr,omitempty"` + BranchesValid int `xml:"branches-valid,attr,omitempty"` + BranchesCovered int `xml:"branches-covered,attr,omitempty"` + BranchRate float64 `xml:"branch-rate,attr,omitempty"` + Timestamp int `xml:"timstamp,attr,omitempty"` + Complexity float64 `xml:complexity,attr,omitempty` + Version int `xml:version,attr,omitempty` + + Sources []Source `xml:"source->source"` + Packages []Package `xml:"package->package"` } type Source struct { @@ -27,45 +30,58 @@ type Source struct { type Package struct { XMLName xml.Name `xml:"package"` - Name int `xml:"name,attr,omitempty"` - LineRate int `xml:"line-rate,attr,omitempty"` - BranchRate int `xml:"branch-rate,attr,omitempty"` - Classes []Class `xml:"class"` + Name string `xml:"name,attr,omitempty"` + LineRate float64 `xml:"line-rate,attr,omitempty"` + BranchRate float64 `xml:"branch-rate,attr,omitempty"` + Complexity float64 `xml:complexity,attr,omitempty` + Classes []Class `xml:"class->class"` } type Class struct { - XMLName xml.Name `xml:"package"` - // TODO: class properties + XMLName xml.Name `xml:"class"` Name string `xml:"attr,name,omitempty"` Filename string `xml:"attr,filename,omitempty"` - LineRate int `xml:"attr,line-rate,omitempty"` - BranchRate int `xml:"attr,branch-rate,omitempty"` - Methods []Method `xml:"method"` - Lines []Line `xml:"line"` + LineRate float64 `xml:"attr,line-rate,omitempty"` + BranchRate float64 `xml:"attr,branch-rate,omitempty"` + Complexity float64 `xml:"complexity,attr,omitempty"` + Methods []Method `xml:"methods->method"` + Lines []Line `xml:"lines->line"` } type Line struct { - XMLName xml.Name `xml:"property"` - Number int `xml:"attr,number"` - Hits int `xml:"attr,hits"` - Branch bool `xml:"attr,branch"` + XMLName xml.Name `xml:"line"` + Number int `xml:"number,attr"` + Hits int `xml:"hits,attr"` + Branch bool `xml:"branch,attr"` + ConditionCoverage string `xml:"condition-coverage,attr"` + Conditions []Condition `xml:"conditions->condition"` } type Method struct { - XMLName xml.Name `xml:"property"` - Name string `xml:"attr,name"` - Hits int `xml:"attr,name"` - Signature string `xml:"attr,name"` - Lines []Line `xml:"lines"` + XMLName xml.Name `xml:"method"` + Name string `xml:"name,attr,omitempty"` + Hits int `xml:"hits,attr,omitempty"` + Signature string `xml:"signature,attr,omitempty"` + BranchRate float64 `xml:"branch-rate,attr,omitempty"` + LineRate float64 `xml:"line-rate,attr,omitempty"` + Lines []Line `xml:"lines->line"` } +type Condition struct { + XMLName xml.Name `xml:"condition"` + + Number int `xml:"number,attr,omitempty"` + Type string `xml:"type,attr,omitempty"` + Coverage string `xml:"coverage,attr,omitempty"` +} + type InnerResult struct { Value string `xml:",innerxml"` } -func NewParser(r io.Reader) (*CoberturaReport, error) { +func NewParser(r io.Reader) (*Coverage, error) { - var report = new(CoberturaReport) + var report = new(Coverage) buf, err := ioutil.ReadAll(r) if err != nil {