danger-jacoco 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/Guardfile +19 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +23 -0
- data/danger-jacoco.gemspec +50 -0
- data/lib/danger_jacoco.rb +1 -0
- data/lib/danger_plugin.rb +11 -0
- data/lib/jacoco/dom_parser.rb +21 -0
- data/lib/jacoco/gem_version.rb +3 -0
- data/lib/jacoco/model/class.rb +17 -0
- data/lib/jacoco/model/counter.rb +14 -0
- data/lib/jacoco/model/group.rb +18 -0
- data/lib/jacoco/model/line.rb +18 -0
- data/lib/jacoco/model/method.rb +16 -0
- data/lib/jacoco/model/package.rb +17 -0
- data/lib/jacoco/model/report.rb +17 -0
- data/lib/jacoco/model/session_info.rb +14 -0
- data/lib/jacoco/model/sourcefile.rb +14 -0
- data/lib/jacoco/plugin.rb +73 -0
- data/lib/jacoco/sax_parser.rb +59 -0
- data/spec/fixtures/output_a.xml +41 -0
- data/spec/jacoco_spec.rb +13 -0
- data/spec/spec_helper.rb +59 -0
- metadata +227 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9e48d8a789b7b83aaab205fcfee219ff8eea8e40
|
4
|
+
data.tar.gz: 423e3a0bb6826e155b0c31633124732aca1b3291
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 75e6f3fdbe33d66f66e2426b3caff0f9b02d1484b01a31341ebfa68162f6df8c9a6cd62befb06a734c45471c2d3f9fd65063831d6ee04f36b0dd0934b0ffd3eb
|
7
|
+
data.tar.gz: c4fb8b5f74e93ff51b3ddfead408180d9f9d74dcdbfb8120bbc96496826ca88904bd9ba5162bc189de256cbf449a22e9ca932479f49e4542002a209937a42133
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# A guardfile for making Danger Plugins
|
2
|
+
# For more info see https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
# To run, use `bundle exec guard`.
|
5
|
+
|
6
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
7
|
+
require 'guard/rspec/dsl'
|
8
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
9
|
+
|
10
|
+
# RSpec files
|
11
|
+
rspec = dsl.rspec
|
12
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
13
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
14
|
+
watch(rspec.spec_files)
|
15
|
+
|
16
|
+
# Ruby files
|
17
|
+
ruby = dsl.ruby
|
18
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
19
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Anton Malinskiy <anton@malinskiy.com>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# danger-jacoco
|
2
|
+
|
3
|
+
**danger-jacoco** is the [Danger](https://github.com/danger/danger) plugin of
|
4
|
+
to validate the code coverage of the files changed
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
```
|
9
|
+
sudo gem install danger-jacoco
|
10
|
+
```
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
Add
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
jacoco.minimum_coverage_percentage=80
|
18
|
+
jacoco.report "path/to/jacoco.xml"
|
19
|
+
```
|
20
|
+
|
21
|
+
to your `Dangerfile`
|
22
|
+
|
23
|
+
## Development
|
24
|
+
|
25
|
+
1. Clone this repo
|
26
|
+
2. Run `bundle install` to setup dependencies.
|
27
|
+
3. Run `bundle exec rake spec` to run the tests.
|
28
|
+
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
29
|
+
5. Make your changes.
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:specs)
|
6
|
+
|
7
|
+
task default: :specs
|
8
|
+
|
9
|
+
task :spec do
|
10
|
+
Rake::Task['specs'].invoke
|
11
|
+
Rake::Task['rubocop'].invoke
|
12
|
+
Rake::Task['spec_docs'].invoke
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Run RuboCop on the lib/specs directory'
|
16
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
17
|
+
task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Ensure that the plugin passes `danger plugins lint`'
|
21
|
+
task :spec_docs do
|
22
|
+
sh 'bundle exec danger plugins lint'
|
23
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jacoco/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'danger-jacoco'
|
8
|
+
spec.version = Jacoco::VERSION
|
9
|
+
spec.authors = ['Anton Malinskiy']
|
10
|
+
spec.email = ['anton@malinskiy.com']
|
11
|
+
spec.description = %q{A short description of danger-jacoco.}
|
12
|
+
spec.summary = %q{A longer description of danger-jacoco.}
|
13
|
+
spec.homepage = 'https://github.com/Malinskiy/danger-jacoco'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
|
22
|
+
spec.add_runtime_dependency 'nokogiri-happymapper', '~> 0.5'
|
23
|
+
|
24
|
+
# General ruby development
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
26
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
27
|
+
|
28
|
+
# Testing support
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
30
|
+
|
31
|
+
# Linting code and docs
|
32
|
+
spec.add_development_dependency "rubocop", "~> 0.41"
|
33
|
+
spec.add_development_dependency "yard", "~> 0.8"
|
34
|
+
|
35
|
+
# Makes testing easy via `bundle exec guard`
|
36
|
+
spec.add_development_dependency 'guard', '~> 2.14'
|
37
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
38
|
+
|
39
|
+
# If you want to work on older builds of ruby
|
40
|
+
spec.add_development_dependency 'listen', '3.0.7'
|
41
|
+
|
42
|
+
# This gives you the chance to run a REPL inside your tests
|
43
|
+
# via:
|
44
|
+
#
|
45
|
+
# require 'pry'
|
46
|
+
# binding.pry
|
47
|
+
#
|
48
|
+
# This will stop test execution and let you inspect the results
|
49
|
+
spec.add_development_dependency 'pry'
|
50
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'jacoco/gem_version'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'jacoco/plugin'
|
2
|
+
|
3
|
+
require 'jacoco/dom_parser'
|
4
|
+
require 'jacoco/model/class'
|
5
|
+
require 'jacoco/model/counter'
|
6
|
+
require 'jacoco/model/group'
|
7
|
+
require 'jacoco/model/method'
|
8
|
+
require 'jacoco/model/package'
|
9
|
+
require 'jacoco/model/report'
|
10
|
+
require 'jacoco/model/session_info'
|
11
|
+
require 'jacoco/model/sourcefile'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Jacoco
|
2
|
+
# DOM parser for Jacoco report
|
3
|
+
class DOMParser
|
4
|
+
def self.read_path(path)
|
5
|
+
DOMParser.new.read_path(path)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.read_string(string)
|
9
|
+
DOMParser.new.read_string(string)
|
10
|
+
end
|
11
|
+
|
12
|
+
def read_path(path)
|
13
|
+
file = File.read(path)
|
14
|
+
read_string(file)
|
15
|
+
end
|
16
|
+
|
17
|
+
def read_string(string)
|
18
|
+
Report.parse(string)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'happymapper'
|
2
|
+
require 'jacoco/model/counter'
|
3
|
+
require 'jacoco/model/method'
|
4
|
+
|
5
|
+
module Jacoco
|
6
|
+
# Jacoco Class model
|
7
|
+
class Class
|
8
|
+
include HappyMapper
|
9
|
+
|
10
|
+
tag 'class'
|
11
|
+
|
12
|
+
attribute :name, String
|
13
|
+
|
14
|
+
has_many :methods, Jacoco::Method, xpath: '.'
|
15
|
+
has_many :counters, Jacoco::Counter, xpath: '.'
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'happymapper'
|
2
|
+
require 'jacoco/model/group'
|
3
|
+
require 'jacoco/model/package'
|
4
|
+
require 'jacoco/model/counter'
|
5
|
+
|
6
|
+
module Jacoco
|
7
|
+
# Jacoco group model
|
8
|
+
class Group
|
9
|
+
include HappyMapper
|
10
|
+
|
11
|
+
tag 'group'
|
12
|
+
|
13
|
+
attribute :name, String
|
14
|
+
has_many :groups, Jacoco::Group, xpath: '.'
|
15
|
+
has_many :packages, Jacoco::Package, xpath: '.'
|
16
|
+
has_many :counters, Jacoco::Counter, xpath: '.'
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'happymapper'
|
2
|
+
require 'jacoco/model/counter'
|
3
|
+
require 'jacoco/model/method'
|
4
|
+
|
5
|
+
module Jacoco
|
6
|
+
# Jacoco line model
|
7
|
+
class Line
|
8
|
+
include HappyMapper
|
9
|
+
|
10
|
+
tag 'line'
|
11
|
+
|
12
|
+
attribute :line_number, Integer, tag: 'nr'
|
13
|
+
attribute :missed_instructions, Integer, tag: 'mi'
|
14
|
+
attribute :covered_instructions, Integer, tag: 'ci'
|
15
|
+
attribute :missed_branches, Integer, tag: 'mb'
|
16
|
+
attribute :covered_branches, Integer, tag: 'cb'
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'happymapper'
|
2
|
+
require 'jacoco/model/counter'
|
3
|
+
|
4
|
+
module Jacoco
|
5
|
+
# Jacoco method model
|
6
|
+
class Method
|
7
|
+
include HappyMapper
|
8
|
+
|
9
|
+
tag 'method'
|
10
|
+
attribute :name, String
|
11
|
+
attribute :desc, String
|
12
|
+
attribute :line, Integer
|
13
|
+
|
14
|
+
has_many :counters, Jacoco::Counter, xpath: '.'
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'happymapper'
|
2
|
+
require 'jacoco/model/class'
|
3
|
+
require 'jacoco/model/sourcefile'
|
4
|
+
|
5
|
+
module Jacoco
|
6
|
+
# Jacoco package model
|
7
|
+
class Package
|
8
|
+
include HappyMapper
|
9
|
+
|
10
|
+
tag 'package'
|
11
|
+
|
12
|
+
attribute :name, String
|
13
|
+
has_many :sourcefiles, Jacoco::Sourcefile, xpath: '.'
|
14
|
+
has_many :class_names, Jacoco::Class, xpath: '.'
|
15
|
+
has_many :counters, Jacoco::Counter, xpath: '.'
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'happymapper'
|
2
|
+
require 'jacoco/model/session_info'
|
3
|
+
|
4
|
+
module Jacoco
|
5
|
+
# Jacoco report model
|
6
|
+
class Report
|
7
|
+
include HappyMapper
|
8
|
+
|
9
|
+
tag 'report'
|
10
|
+
attribute :name, String
|
11
|
+
|
12
|
+
has_many :session_infos, Jacoco::SessionInfo, xpath: '.'
|
13
|
+
has_many :groups, Jacoco::Group, xpath: '.'
|
14
|
+
has_many :packages, Jacoco::Package, xpath: '.'
|
15
|
+
has_many :counters, Jacoco::Counter, xpath: '.'
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'jacoco/sax_parser'
|
2
|
+
|
3
|
+
module Danger
|
4
|
+
#
|
5
|
+
# @see Anton Malinskiy/danger-jacoco
|
6
|
+
# @tags jacoco, coverage, java, android
|
7
|
+
#
|
8
|
+
class DangerJacoco < Plugin
|
9
|
+
attr_accessor :minimum_coverage_percentage
|
10
|
+
|
11
|
+
# Parses the xml output of jacoco to Ruby model classes
|
12
|
+
# This is slow since it's basically DOM parsing
|
13
|
+
#
|
14
|
+
# @path path to the xml output of jacoco
|
15
|
+
#
|
16
|
+
def parse(path)
|
17
|
+
Jacoco::DOMParser.read_path(path)
|
18
|
+
end
|
19
|
+
|
20
|
+
# This is a fast report based on SAX parser
|
21
|
+
#
|
22
|
+
# @path path to the xml output of jacoco
|
23
|
+
# @delimiter git.modified_files returns full paths to the
|
24
|
+
# changed files. We need to get the java class from this path to check the
|
25
|
+
# Jacoco report,
|
26
|
+
#
|
27
|
+
# e.g. src/java/com/example/SomeClass.java -> com/example/SomeClass
|
28
|
+
#
|
29
|
+
# The default value supposes that you're using gradle structure,
|
30
|
+
# that is your path to java source files is something like
|
31
|
+
#
|
32
|
+
# blah/blah/java/slashed_package/Source.java
|
33
|
+
#
|
34
|
+
def report(path, delimiter = '/java/')
|
35
|
+
classes = @dangerfile.git
|
36
|
+
.modified_files
|
37
|
+
.select { |file| file.end_with? '.java' }
|
38
|
+
.map { |file| extract_class(file, delimiter) }
|
39
|
+
|
40
|
+
parser = Jacoco::SAXParser.new(classes)
|
41
|
+
Nokogiri::XML::SAX::Parser.new(parser).parse(File.open(path))
|
42
|
+
|
43
|
+
parser.classes.each do |jacoco_class|
|
44
|
+
# Check which metrics are available
|
45
|
+
report_class(jacoco_class)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def report_class(jacoco_class)
|
50
|
+
counters = jacoco_class.counters
|
51
|
+
branch_counter = counters.detect { |e| e.type.eql? 'BRANCH' }
|
52
|
+
line_counter = counters.detect { |e| e.type.eql? 'LINE' }
|
53
|
+
counter = branch_counter.nil? ? line_counter : branch_counter
|
54
|
+
|
55
|
+
report_counter(counter, jacoco_class)
|
56
|
+
end
|
57
|
+
|
58
|
+
def report_counter(counter, jacoco_class)
|
59
|
+
covered = counter.covered
|
60
|
+
missed = counter.missed
|
61
|
+
coverage = (covered.fdiv(covered + missed) * 100).floor
|
62
|
+
|
63
|
+
return unless coverage < minimum_coverage_percentage
|
64
|
+
|
65
|
+
raise "#{jacoco_class.name} has coverage of #{coverage}%. " \
|
66
|
+
"Improve this to at least #{minimum_coverage_percentage}%"
|
67
|
+
end
|
68
|
+
|
69
|
+
def extract_class(file, java_path_delimiter)
|
70
|
+
file[0, file.length - 5].split(java_path_delimiter)[1]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module Jacoco
|
4
|
+
# Sax parser for quickly finding class elements in Jacoco report
|
5
|
+
class SAXParser < Nokogiri::XML::SAX::Document
|
6
|
+
attr_accessor :class_names
|
7
|
+
attr_accessor :classes
|
8
|
+
|
9
|
+
def initialize(classes)
|
10
|
+
@class_names = classes
|
11
|
+
@classes = []
|
12
|
+
@current_class = nil
|
13
|
+
@subelement_index = 0
|
14
|
+
end
|
15
|
+
|
16
|
+
def start_element(name, attrs = [])
|
17
|
+
case name
|
18
|
+
when 'class'
|
19
|
+
start_class(attrs)
|
20
|
+
when 'counter'
|
21
|
+
start_counter(attrs)
|
22
|
+
end
|
23
|
+
|
24
|
+
@subelement_index += 1
|
25
|
+
end
|
26
|
+
|
27
|
+
def start_counter(attrs)
|
28
|
+
return unless !@current_class.nil? && @subelement_index == 1
|
29
|
+
|
30
|
+
counter = Jacoco::Counter.new
|
31
|
+
counter.type = Hash[attrs]['type']
|
32
|
+
counter.missed = Hash[attrs]['missed'].to_i
|
33
|
+
counter.covered = Hash[attrs]['covered'].to_i
|
34
|
+
|
35
|
+
@current_class.counters.push(counter)
|
36
|
+
end
|
37
|
+
|
38
|
+
def start_class(attrs)
|
39
|
+
@subelement_index = 0
|
40
|
+
|
41
|
+
if @class_names.include?(Hash[attrs]['name'])
|
42
|
+
c = Jacoco::Class.new
|
43
|
+
c.name = Hash[attrs]['name']
|
44
|
+
c.counters = []
|
45
|
+
@current_class = c
|
46
|
+
@classes.push c
|
47
|
+
elsif @current_class.nil?
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def characters(string)
|
52
|
+
end
|
53
|
+
|
54
|
+
def end_element(name)
|
55
|
+
@subelement_index -= 1
|
56
|
+
@current_class = nil if name.eql? 'class'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN"
|
2
|
+
"report.dtd">
|
3
|
+
<report name="test_report">
|
4
|
+
<sessioninfo id="test-id" start="1480057517395" dump="1480057526412"/>
|
5
|
+
<package name="com/example">
|
6
|
+
<class name="com/example/MemoryCache">
|
7
|
+
<method name="<init>" desc="()V" line="17">
|
8
|
+
<counter type="INSTRUCTION" missed="0" covered="11"/>
|
9
|
+
<counter type="LINE" missed="0" covered="5"/>
|
10
|
+
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
11
|
+
<counter type="METHOD" missed="0" covered="1"/>
|
12
|
+
</method>
|
13
|
+
<counter type="INSTRUCTION" missed="0" covered="46"/>
|
14
|
+
<counter type="LINE" missed="0" covered="14"/>
|
15
|
+
<counter type="COMPLEXITY" missed="0" covered="7"/>
|
16
|
+
<counter type="METHOD" missed="0" covered="7"/>
|
17
|
+
<counter type="CLASS" missed="0" covered="1"/>
|
18
|
+
</class>
|
19
|
+
<sourcefile name="CachedRepository.java">
|
20
|
+
<line nr="16" mi="0" ci="2" mb="0" cb="0"/>
|
21
|
+
<line nr="17" mi="0" ci="3" mb="0" cb="0"/>
|
22
|
+
<counter type="INSTRUCTION" missed="0" covered="98"/>
|
23
|
+
<counter type="LINE" missed="0" covered="19"/>
|
24
|
+
<counter type="COMPLEXITY" missed="0" covered="11"/>
|
25
|
+
<counter type="METHOD" missed="0" covered="11"/>
|
26
|
+
<counter type="CLASS" missed="0" covered="4"/>
|
27
|
+
</sourcefile>
|
28
|
+
<counter type="INSTRUCTION" missed="80" covered="324"/>
|
29
|
+
<counter type="BRANCH" missed="4" covered="4"/>
|
30
|
+
<counter type="LINE" missed="24" covered="68"/>
|
31
|
+
<counter type="COMPLEXITY" missed="11" covered="39"/>
|
32
|
+
<counter type="METHOD" missed="9" covered="37"/>
|
33
|
+
<counter type="CLASS" missed="2" covered="10"/>
|
34
|
+
</package>
|
35
|
+
<counter type="INSTRUCTION" missed="39399" covered="19321"/>
|
36
|
+
<counter type="BRANCH" missed="3463" covered="1039"/>
|
37
|
+
<counter type="LINE" missed="9611" covered="3974"/>
|
38
|
+
<counter type="COMPLEXITY" missed="5517" covered="1444"/>
|
39
|
+
<counter type="METHOD" missed="3382" covered="1120"/>
|
40
|
+
<counter type="CLASS" missed="491" covered="370"/>
|
41
|
+
</report>
|
data/spec/jacoco_spec.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
module Jacoco
|
4
|
+
describe Jacoco::DOMParser do
|
5
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
6
|
+
|
7
|
+
describe 'read xml' do
|
8
|
+
it 'reads report' do
|
9
|
+
Jacoco::DOMParser.read_path(path_a)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
|
3
|
+
$LOAD_PATH.unshift((ROOT + 'lib').to_s)
|
4
|
+
$LOAD_PATH.unshift((ROOT + 'spec').to_s)
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'pry'
|
8
|
+
|
9
|
+
require 'rspec'
|
10
|
+
require 'danger'
|
11
|
+
|
12
|
+
# Use coloured output, it's the best.
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.filter_gems_from_backtrace 'bundler'
|
15
|
+
config.color = true
|
16
|
+
config.tty = true
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'danger_plugin'
|
20
|
+
|
21
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
22
|
+
# If you are expanding these files, see if it's already been done ^.
|
23
|
+
|
24
|
+
# A silent version of the user interface,
|
25
|
+
# it comes with an extra function `.string` which will
|
26
|
+
# strip all ANSI colours from the string.
|
27
|
+
|
28
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
29
|
+
def testing_ui
|
30
|
+
@output = StringIO.new
|
31
|
+
def @output.winsize
|
32
|
+
[20, 9999]
|
33
|
+
end
|
34
|
+
|
35
|
+
cork = Cork::Board.new(out: @output)
|
36
|
+
def cork.string
|
37
|
+
out.string.gsub(/\e\[([;\d]+)?m/, '')
|
38
|
+
end
|
39
|
+
cork
|
40
|
+
end
|
41
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
42
|
+
|
43
|
+
# Example environment (ENV) that would come from
|
44
|
+
# running a PR on TravisCI
|
45
|
+
def testing_env
|
46
|
+
{
|
47
|
+
'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
|
48
|
+
'TRAVIS_PULL_REQUEST' => '800',
|
49
|
+
'TRAVIS_REPO_SLUG' => 'artsy/eigen',
|
50
|
+
'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
|
51
|
+
'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# A stubbed out Dangerfile for use in tests
|
56
|
+
def testing_dangerfile
|
57
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
58
|
+
Danger::Dangerfile.new(env, testing_ui)
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: danger-jacoco
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anton Malinskiy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-11-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: danger-plugin-api
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri-happymapper
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.5'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.4'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.4'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.41'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.41'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: yard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.8'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.8'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.14'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '2.14'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: guard-rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '4.7'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '4.7'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: listen
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 3.0.7
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 3.0.7
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: pry
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
description: A short description of danger-jacoco.
|
168
|
+
email:
|
169
|
+
- anton@malinskiy.com
|
170
|
+
executables: []
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- ".gitignore"
|
175
|
+
- ".travis.yml"
|
176
|
+
- Gemfile
|
177
|
+
- Guardfile
|
178
|
+
- LICENSE.txt
|
179
|
+
- README.md
|
180
|
+
- Rakefile
|
181
|
+
- danger-jacoco.gemspec
|
182
|
+
- lib/danger_jacoco.rb
|
183
|
+
- lib/danger_plugin.rb
|
184
|
+
- lib/jacoco/dom_parser.rb
|
185
|
+
- lib/jacoco/gem_version.rb
|
186
|
+
- lib/jacoco/model/class.rb
|
187
|
+
- lib/jacoco/model/counter.rb
|
188
|
+
- lib/jacoco/model/group.rb
|
189
|
+
- lib/jacoco/model/line.rb
|
190
|
+
- lib/jacoco/model/method.rb
|
191
|
+
- lib/jacoco/model/package.rb
|
192
|
+
- lib/jacoco/model/report.rb
|
193
|
+
- lib/jacoco/model/session_info.rb
|
194
|
+
- lib/jacoco/model/sourcefile.rb
|
195
|
+
- lib/jacoco/plugin.rb
|
196
|
+
- lib/jacoco/sax_parser.rb
|
197
|
+
- spec/fixtures/output_a.xml
|
198
|
+
- spec/jacoco_spec.rb
|
199
|
+
- spec/spec_helper.rb
|
200
|
+
homepage: https://github.com/Malinskiy/danger-jacoco
|
201
|
+
licenses:
|
202
|
+
- MIT
|
203
|
+
metadata: {}
|
204
|
+
post_install_message:
|
205
|
+
rdoc_options: []
|
206
|
+
require_paths:
|
207
|
+
- lib
|
208
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
209
|
+
requirements:
|
210
|
+
- - ">="
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '0'
|
213
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
|
+
requirements:
|
215
|
+
- - ">="
|
216
|
+
- !ruby/object:Gem::Version
|
217
|
+
version: '0'
|
218
|
+
requirements: []
|
219
|
+
rubyforge_project:
|
220
|
+
rubygems_version: 2.5.1
|
221
|
+
signing_key:
|
222
|
+
specification_version: 4
|
223
|
+
summary: A longer description of danger-jacoco.
|
224
|
+
test_files:
|
225
|
+
- spec/fixtures/output_a.xml
|
226
|
+
- spec/jacoco_spec.rb
|
227
|
+
- spec/spec_helper.rb
|