danger-cobertura 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.rubocop.yml +152 -0
- data/.travis.yml +19 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +6 -0
- data/Guardfile +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +84 -0
- data/Rakefile +25 -0
- data/danger-cobertura.gemspec +52 -0
- data/lib/cobertura/coverage_item.rb +27 -0
- data/lib/cobertura/gem_version.rb +5 -0
- data/lib/cobertura/plugin.rb +97 -0
- data/lib/danger_cobertura.rb +3 -0
- data/lib/danger_plugin.rb +3 -0
- data/spec/assets/coverage.xml +283 -0
- data/spec/cobertura_spec.rb +90 -0
- data/spec/spec_helper.rb +69 -0
- metadata +234 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 82b28e2ecb8f0383f89f977bc3a1b073b0be37076a3e5f97e66679abd8790102
|
4
|
+
data.tar.gz: b44ee503e7b9588a4d385f008cd26a293f32075f34a4ee726053d2dee659b518
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4616f102f79dbe73922f317efc478cadb10fa5c8584f5d0f214d1b1ae3d869eb2e89163b198d05f883b3f36c885e8f3cb8ac9c6f0410acd4b32f7b8f057fee1b
|
7
|
+
data.tar.gz: 047a27612a80b13e93410a422574c2b32e39c186eec49b095710cbfaa8d9b8884fec0ef7d0b8e73383d3b8e77bef1a393ab493e35710aa90f3a341bcbfb4cf13
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
# Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
|
2
|
+
|
3
|
+
# If you don't like these settings, just delete this file :)
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 2.5
|
7
|
+
|
8
|
+
Style/StringLiterals:
|
9
|
+
EnforcedStyle: double_quotes
|
10
|
+
Enabled: true
|
11
|
+
|
12
|
+
# kind_of? is a good way to check a type
|
13
|
+
Style/ClassCheck:
|
14
|
+
EnforcedStyle: kind_of?
|
15
|
+
|
16
|
+
# It's better to be more explicit about the type
|
17
|
+
Style/BracesAroundHashParameters:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
# specs sometimes have useless assignments, which is fine
|
21
|
+
Lint/UselessAssignment:
|
22
|
+
Exclude:
|
23
|
+
- '**/spec/**/*'
|
24
|
+
|
25
|
+
# We could potentially enable the 2 below:
|
26
|
+
Layout/IndentHash:
|
27
|
+
Enabled: false
|
28
|
+
|
29
|
+
Layout/AlignHash:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
# HoundCI doesn't like this rule
|
33
|
+
Layout/DotPosition:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
# We allow !! as it's an easy way to convert ot boolean
|
37
|
+
Style/DoubleNegation:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
# Cop supports --auto-correct.
|
41
|
+
Lint/UnusedBlockArgument:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
# We want to allow class Fastlane::Class
|
45
|
+
Style/ClassAndModuleChildren:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
Metrics/AbcSize:
|
49
|
+
Max: 60
|
50
|
+
|
51
|
+
# The %w might be confusing for new users
|
52
|
+
Style/WordArray:
|
53
|
+
MinSize: 19
|
54
|
+
|
55
|
+
# raise and fail are both okay
|
56
|
+
Style/SignalException:
|
57
|
+
Enabled: false
|
58
|
+
|
59
|
+
# Better too much 'return' than one missing
|
60
|
+
Style/RedundantReturn:
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
# Having if in the same line might not always be good
|
64
|
+
Style/IfUnlessModifier:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
# and and or is okay
|
68
|
+
Style/AndOr:
|
69
|
+
Enabled: false
|
70
|
+
|
71
|
+
# Configuration parameters: CountComments.
|
72
|
+
Metrics/ClassLength:
|
73
|
+
Max: 350
|
74
|
+
|
75
|
+
Metrics/CyclomaticComplexity:
|
76
|
+
Max: 17
|
77
|
+
|
78
|
+
# Configuration parameters: AllowURI, URISchemes.
|
79
|
+
Metrics/LineLength:
|
80
|
+
Max: 370
|
81
|
+
|
82
|
+
# Configuration parameters: CountKeywordArgs.
|
83
|
+
Metrics/ParameterLists:
|
84
|
+
Max: 10
|
85
|
+
|
86
|
+
Metrics/PerceivedComplexity:
|
87
|
+
Max: 18
|
88
|
+
|
89
|
+
# Sometimes it's easier to read without guards
|
90
|
+
Style/GuardClause:
|
91
|
+
Enabled: false
|
92
|
+
|
93
|
+
# something = if something_else
|
94
|
+
# that's confusing
|
95
|
+
Style/ConditionalAssignment:
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
# Better to have too much self than missing a self
|
99
|
+
Style/RedundantSelf:
|
100
|
+
Enabled: false
|
101
|
+
|
102
|
+
Metrics/MethodLength:
|
103
|
+
Max: 60
|
104
|
+
|
105
|
+
# We're not there yet
|
106
|
+
Style/Documentation:
|
107
|
+
Enabled: false
|
108
|
+
|
109
|
+
# Adds complexity
|
110
|
+
Style/IfInsideElse:
|
111
|
+
Enabled: false
|
112
|
+
|
113
|
+
# danger specific
|
114
|
+
|
115
|
+
Style/BlockComments:
|
116
|
+
Enabled: false
|
117
|
+
|
118
|
+
Layout/MultilineMethodCallIndentation:
|
119
|
+
EnforcedStyle: indented
|
120
|
+
|
121
|
+
# FIXME: 25
|
122
|
+
Metrics/BlockLength:
|
123
|
+
Max: 345
|
124
|
+
Exclude:
|
125
|
+
- "**/*_spec.rb"
|
126
|
+
|
127
|
+
Style/MixinGrouping:
|
128
|
+
Enabled: false
|
129
|
+
|
130
|
+
Style/FileName:
|
131
|
+
Enabled: false
|
132
|
+
|
133
|
+
Layout/IndentHeredoc:
|
134
|
+
Enabled: false
|
135
|
+
|
136
|
+
Style/SpecialGlobalVars:
|
137
|
+
Enabled: false
|
138
|
+
|
139
|
+
PercentLiteralDelimiters:
|
140
|
+
PreferredDelimiters:
|
141
|
+
"%": ()
|
142
|
+
"%i": ()
|
143
|
+
"%q": ()
|
144
|
+
"%Q": ()
|
145
|
+
"%r": "{}"
|
146
|
+
"%s": ()
|
147
|
+
"%w": ()
|
148
|
+
"%W": ()
|
149
|
+
"%x": ()
|
150
|
+
|
151
|
+
Security/YAMLLoad:
|
152
|
+
Enabled: false
|
data/.travis.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
cache:
|
4
|
+
directories:
|
5
|
+
- bundle
|
6
|
+
|
7
|
+
rvm:
|
8
|
+
- 2.5.2
|
9
|
+
|
10
|
+
script:
|
11
|
+
- bundle exec rake spec
|
12
|
+
|
13
|
+
deploy:
|
14
|
+
provider: rubygems
|
15
|
+
api_key:
|
16
|
+
secure: N+QJ0e6CW/m5zVxKYBZNSShZYghGH7TVgsoDbNndawGe0/A5Q8iSURliqO1Sykbc7xPwnewfNpcVSB+6LjQPOfUn62ZtxuDQQx5orVwcn0ul3wHG7MD9CoJqUD/xbsJNFjBMSI+zYlfg9uI9BrB55ctdra77HcvOsayS3ByL6pB+GoB1HgXwNZQjLL+0Hpy0sO3Vvr7LiAE4nv4CikSQy169hQ7Q70K0bxfhdGYxWX2FW2NxfvxatkBAZrHlN5Vg4NV4ZAKQBMgI3kFRupZOoQkTy08CZCueuac9jl8I/FaIsugKVjgba+JJ79WnqC/9pPSWedcy9kgvl8/mKu8KUEhBFjF0/ib40+KG9ioaHUDr+ddWD1FEm7qFpipamH7mcznmcfSaEqvILz8V36q8bRCjgHksY1TR9rJBa4RFzGvzyUclbtkvqm1KNN9VqEREKFKjw1JtBfPeSqcm+ciYmREl0r/RgI14Z7XyghJi9CxRdggcQonCfQSDcNfuvasJAd+prRmAUue/MRqbtgyS5rfUiEX5U4H5Futi9ri4vhVUc6seNYGPuxcf42/KGUFspkDJwW7nKSNRkf+diV7OfGLLR75YU4r5T6jFx/Jl+cTN++xCGhBGYa97FwI8+NMQCnACERC1hVXADuVGCQGvh68xpuPgFdOwtdLEONol94g=
|
17
|
+
gem: danger-cobertura
|
18
|
+
on:
|
19
|
+
branch: master
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [1.0.0] - 2018-11-25
|
10
|
+
### Added
|
11
|
+
- Initial release.
|
12
|
+
- Add `show_coverage` method to display a markdown table with coverage information of all modified and added files.
|
13
|
+
- Add `warn_if_file_less_than(percentage:)` method to display a warning for each file which does not achieve the minimum coverage given.
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A guardfile for making Danger Plugins
|
4
|
+
# For more info see https://github.com/guard/guard#readme
|
5
|
+
|
6
|
+
# To run, use `bundle exec guard`.
|
7
|
+
|
8
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
9
|
+
require "guard/rspec/dsl"
|
10
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
11
|
+
|
12
|
+
# RSpec files
|
13
|
+
rspec = dsl.rspec
|
14
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
15
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
16
|
+
watch(rspec.spec_files)
|
17
|
+
|
18
|
+
# Ruby files
|
19
|
+
ruby = dsl.ruby
|
20
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
21
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2018 Kyaak <kyaak.dev@gmail.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,84 @@
|
|
1
|
+
# danger-cobertura
|
2
|
+
|
3
|
+
A [cobertura](http://cobertura.github.io/cobertura/) report plugin for [danger](https://danger.systems/ruby).
|
4
|
+
|
5
|
+
This plugin allows parsing of an xml coverage report generated by __cobertura__ and displays desired metrics.
|
6
|
+
|
7
|
+
_It inspects only modified and added files, deleted ones are not considered useful for this report._
|
8
|
+
|
9
|
+
## How it looks like
|
10
|
+
### Warnings about file coverage
|
11
|
+
<table>
|
12
|
+
<thead>
|
13
|
+
<tr>
|
14
|
+
<th width="50"></th>
|
15
|
+
<th width="100%">
|
16
|
+
1 Warnings
|
17
|
+
</th>
|
18
|
+
</tr>
|
19
|
+
</thead>
|
20
|
+
<tbody>
|
21
|
+
<tr>
|
22
|
+
<td><g-emoji alias="warning" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/26a0.png">⚠️</g-emoji></td>
|
23
|
+
<td>example.py has less than 50% coverage</td>
|
24
|
+
</tr>
|
25
|
+
</tbody>
|
26
|
+
</table>
|
27
|
+
|
28
|
+
### Coverage report
|
29
|
+
|
30
|
+
File | Coverage
|
31
|
+
-----|-----
|
32
|
+
example_one.py | 50.00
|
33
|
+
example_two.py | 35.60
|
34
|
+
example_three.py | 10.48
|
35
|
+
|
36
|
+
|
37
|
+
## Installation
|
38
|
+
|
39
|
+
$ gem install danger-cobertura
|
40
|
+
|
41
|
+
## Usage
|
42
|
+
|
43
|
+
Methods and attributes from this plugin are available in
|
44
|
+
your `Dangerfile` under the `cobertura` namespace.
|
45
|
+
|
46
|
+
<blockquote>Warn files with a coverage less than 50%
|
47
|
+
<pre>
|
48
|
+
cobertura.report = build/reports/coverage.xml
|
49
|
+
cobertura.warn_if_file_less_than(percentage: 50.0)
|
50
|
+
</pre>
|
51
|
+
</blockquote>
|
52
|
+
|
53
|
+
<blockquote>Show coverage of all files
|
54
|
+
<pre>
|
55
|
+
cobertura.report = build/reports/coverage.xml
|
56
|
+
cobertura.show_coverage
|
57
|
+
</pre>
|
58
|
+
</blockquote>
|
59
|
+
|
60
|
+
<blockquote>Combine all reports
|
61
|
+
<pre>
|
62
|
+
cobertura.report = build/reports/coverage.xml
|
63
|
+
cobertura.warn_if_file_less_than(percentage: 50.0)
|
64
|
+
cobertura.show_coverage
|
65
|
+
</pre>
|
66
|
+
</blockquote>
|
67
|
+
|
68
|
+
## Attributes
|
69
|
+
|
70
|
+
__`report`__ - Path to the cobertura xml report, e.g. `build/reports/coverage.xml`
|
71
|
+
|
72
|
+
## Methods
|
73
|
+
|
74
|
+
__`warn_if_file_less_than(percentage:)`__ - Add a danger warning for each file with a lower total coverage as given.
|
75
|
+
|
76
|
+
__`show_coverage`__ - Show a markdown table including the coverage for all (modified / added) files.
|
77
|
+
|
78
|
+
## Development
|
79
|
+
|
80
|
+
1. Clone this repo
|
81
|
+
2. Run `bundle install` to setup dependencies.
|
82
|
+
3. Run `bundle exec rake spec` to run the tests.
|
83
|
+
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
84
|
+
5. Make your changes.
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require "rubocop/rake_task"
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:specs)
|
8
|
+
|
9
|
+
task default: :specs
|
10
|
+
|
11
|
+
task :spec do
|
12
|
+
Rake::Task["specs"].invoke
|
13
|
+
Rake::Task["rubocop"].invoke
|
14
|
+
Rake::Task["spec_docs"].invoke
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run RuboCop on the lib/specs directory"
|
18
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
19
|
+
task.patterns = %w(lib/**/*.rb spec/**/*.rb)
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Ensure that the plugin passes `danger plugins lint`"
|
23
|
+
task :spec_docs do
|
24
|
+
sh "bundle exec danger plugins lint"
|
25
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "cobertura/gem_version.rb"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "danger-cobertura"
|
9
|
+
spec.version = Cobertura::VERSION
|
10
|
+
spec.authors = ["Kyaak"]
|
11
|
+
spec.email = ["kyaak.dev@gmail.com"]
|
12
|
+
spec.description = "A cobertura report plugin for danger."
|
13
|
+
spec.summary = "This plugin allows parsing of an xml coverage report generated by cobertura and displays desired metrics."
|
14
|
+
spec.homepage = "https://github.com/Kyaak/danger-cobertura"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_runtime_dependency "danger-plugin-api", "~> 1.0"
|
23
|
+
spec.add_runtime_dependency "oga", "~> 2.15"
|
24
|
+
|
25
|
+
# General ruby development
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
|
29
|
+
# Testing support
|
30
|
+
spec.add_development_dependency "mocha", "~> 1.2"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
32
|
+
|
33
|
+
# Linting code and docs
|
34
|
+
spec.add_development_dependency "rubocop", "~> 0.6"
|
35
|
+
spec.add_development_dependency "yard", "~> 0.9"
|
36
|
+
|
37
|
+
# Makes testing easy via `bundle exec guard`
|
38
|
+
spec.add_development_dependency "guard", "~> 2.14"
|
39
|
+
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
40
|
+
|
41
|
+
# If you want to work on older builds of ruby
|
42
|
+
spec.add_development_dependency "listen", "3.0.7"
|
43
|
+
|
44
|
+
# This gives you the chance to run a REPL inside your tests
|
45
|
+
# via:
|
46
|
+
#
|
47
|
+
# require 'pry'
|
48
|
+
# binding.pry
|
49
|
+
#
|
50
|
+
# This will stop test execution and let you inspect the results
|
51
|
+
spec.add_development_dependency "pry"
|
52
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CoverageItem
|
4
|
+
def initialize(node)
|
5
|
+
@node = node
|
6
|
+
end
|
7
|
+
|
8
|
+
def total_percentage
|
9
|
+
@total_percentage ||= ((branch_rate + line_rate) / 2) * 100
|
10
|
+
end
|
11
|
+
|
12
|
+
def branch_rate
|
13
|
+
@branch_rate ||= @node.attribute("branch-rate").value.to_f
|
14
|
+
end
|
15
|
+
|
16
|
+
def line_rate
|
17
|
+
@line_rate ||= @node.attribute("line-rate").value.to_f
|
18
|
+
end
|
19
|
+
|
20
|
+
def file_name
|
21
|
+
@file_name ||= @node.attribute("filename").value.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def name
|
25
|
+
@name ||= @node.attribute("name").value.to_s
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Danger
|
4
|
+
# Show code coverage of modified and added files.
|
5
|
+
# Add warnings if minimum file coverage is not achieved.
|
6
|
+
#
|
7
|
+
# @example Warn on minimum file coverage of 30% and show all modified files coverage.
|
8
|
+
# cobertura.report = "path/to/my/report.xml"
|
9
|
+
# cobertura.warn_if_file_less_than(percentage: 30)
|
10
|
+
# cobertura.show_coverage
|
11
|
+
#
|
12
|
+
# @see Kyaak/danger-cobertura
|
13
|
+
# @tags cobertura, coverage
|
14
|
+
#
|
15
|
+
class DangerCobertura < Plugin
|
16
|
+
require_relative "./coverage_item"
|
17
|
+
ERROR_FILE_NOT_SET = "Cobertura file not set. Use 'cobertura.file = \"path/to/my/report.xml\"'."
|
18
|
+
ERROR_FILE_NOT_FOUND = "No file found at %s"
|
19
|
+
|
20
|
+
# Path to the xml formatted cobertura report.
|
21
|
+
#
|
22
|
+
# @return [String]
|
23
|
+
attr_accessor :report
|
24
|
+
|
25
|
+
# Warn if a modified file has a lower total coverage than defined.
|
26
|
+
#
|
27
|
+
# @param percentage [Float] The minimum code coverage required for a file.
|
28
|
+
# @return [Array<String>]
|
29
|
+
def warn_if_file_less_than(percentage:)
|
30
|
+
filtered_items.each do |item|
|
31
|
+
next unless item.total_percentage < percentage
|
32
|
+
|
33
|
+
warn "#{item.name} has less than #{percentage}% coverage"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Show markdown table of modified and added files.
|
38
|
+
#
|
39
|
+
# @return [Array<String>]
|
40
|
+
def show_coverage
|
41
|
+
return if filtered_items.empty?
|
42
|
+
|
43
|
+
line = +"## Code coverage\n"
|
44
|
+
line << "File | Coverage\n"
|
45
|
+
line << "-----|-----\n"
|
46
|
+
filtered_items.each do |item|
|
47
|
+
line << "#{item.name} | #{format('%.2f', item.total_percentage)}\n"
|
48
|
+
end
|
49
|
+
markdown line
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
# Getter for coverage items of targeted files.
|
55
|
+
#
|
56
|
+
# @return [Array<CoverageItem>]
|
57
|
+
def filtered_items
|
58
|
+
@filtered_items ||= coverage_items.select do |item|
|
59
|
+
target_files.include? item.file_name
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# A getter for current updated files.
|
64
|
+
#
|
65
|
+
# @return [Array<String>]
|
66
|
+
def target_files
|
67
|
+
@target_files ||= git.modified_files + git.added_files
|
68
|
+
end
|
69
|
+
|
70
|
+
# Parse the defined coverage report file.
|
71
|
+
#
|
72
|
+
# @return [Oga::XML::Document]
|
73
|
+
def parse
|
74
|
+
require "oga"
|
75
|
+
raise ERROR_FILE_NOT_SET if report.nil? || report.empty?
|
76
|
+
raise format(ERROR_FILE_NOT_FOUND, report) unless File.exist?(report)
|
77
|
+
|
78
|
+
Oga.parse_xml(File.read(report))
|
79
|
+
end
|
80
|
+
|
81
|
+
# Get the xml cobertura report.
|
82
|
+
#
|
83
|
+
# @return [Oga::XML::Document]
|
84
|
+
def xml_report
|
85
|
+
@xml_report ||= parse
|
86
|
+
end
|
87
|
+
|
88
|
+
# Getter for all coverage data.
|
89
|
+
#
|
90
|
+
# @return [Array<CoverageItem>]
|
91
|
+
def coverage_items
|
92
|
+
@coverage_items ||= xml_report.xpath("//class").map do |node|
|
93
|
+
CoverageItem.new(node)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,283 @@
|
|
1
|
+
<?xml version="1.0" ?>
|
2
|
+
<coverage branch-rate="0.6257" branches-covered="423" branches-valid="676" complexity="0" line-rate="0.8255" lines-covered="3279" lines-valid="3972" timestamp="1543096490494" version="4.5.1">
|
3
|
+
<!-- Generated by coverage.py: https://coverage.readthedocs.io -->
|
4
|
+
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
|
5
|
+
<sources>
|
6
|
+
<source>/path/to/my/project/sourcs</source>
|
7
|
+
</sources>
|
8
|
+
<packages>
|
9
|
+
<package branch-rate="1" complexity="0" line-rate="0.9903" name=".">
|
10
|
+
<classes>
|
11
|
+
<class branch-rate="1" complexity="0" filename="top_level_one.py" line-rate="1" name="top_level_one.py">
|
12
|
+
<methods/>
|
13
|
+
<lines>
|
14
|
+
<line hits="1" number="16"/>
|
15
|
+
<line hits="1" number="20"/>
|
16
|
+
<line hits="1" number="21"/>
|
17
|
+
<line hits="1" number="22"/>
|
18
|
+
<line hits="1" number="23"/>
|
19
|
+
<line hits="1" number="24"/>
|
20
|
+
<line hits="1" number="25"/>
|
21
|
+
<line hits="1" number="26"/>
|
22
|
+
<line hits="1" number="27"/>
|
23
|
+
<line hits="1" number="28"/>
|
24
|
+
<line hits="1" number="30"/>
|
25
|
+
<line hits="1" number="31"/>
|
26
|
+
<line hits="1" number="32"/>
|
27
|
+
<line hits="1" number="33"/>
|
28
|
+
<line hits="1" number="34"/>
|
29
|
+
<line hits="1" number="35"/>
|
30
|
+
<line hits="1" number="36"/>
|
31
|
+
<line hits="1" number="37"/>
|
32
|
+
<line hits="1" number="38"/>
|
33
|
+
<line hits="1" number="39"/>
|
34
|
+
<line hits="1" number="40"/>
|
35
|
+
<line hits="1" number="41"/>
|
36
|
+
<line hits="1" number="42"/>
|
37
|
+
<line hits="1" number="43"/>
|
38
|
+
<line hits="1" number="44"/>
|
39
|
+
<line hits="1" number="45"/>
|
40
|
+
<line hits="1" number="46"/>
|
41
|
+
</lines>
|
42
|
+
</class>
|
43
|
+
<class branch-rate="1" complexity="0" filename="top_level_two.py" line-rate="0.9868" name="top_level_two.py">
|
44
|
+
<methods/>
|
45
|
+
<lines>
|
46
|
+
<line hits="1" number="14"/>
|
47
|
+
<line hits="1" number="18"/>
|
48
|
+
<line hits="1" number="19"/>
|
49
|
+
<line hits="1" number="20"/>
|
50
|
+
<line hits="1" number="21"/>
|
51
|
+
<line hits="1" number="22"/>
|
52
|
+
<line hits="1" number="23"/>
|
53
|
+
<line hits="1" number="24"/>
|
54
|
+
<line hits="1" number="25"/>
|
55
|
+
<line hits="1" number="26"/>
|
56
|
+
<line hits="1" number="27"/>
|
57
|
+
<line hits="1" number="28"/>
|
58
|
+
<line hits="1" number="29"/>
|
59
|
+
<line hits="1" number="30"/>
|
60
|
+
<line hits="1" number="31"/>
|
61
|
+
<line hits="1" number="32"/>
|
62
|
+
<line hits="1" number="34"/>
|
63
|
+
<line hits="1" number="35"/>
|
64
|
+
<line hits="1" number="36"/>
|
65
|
+
<line hits="1" number="37"/>
|
66
|
+
<line hits="1" number="39"/>
|
67
|
+
<line hits="1" number="40"/>
|
68
|
+
<line hits="1" number="45"/>
|
69
|
+
<line hits="1" number="48"/>
|
70
|
+
<line hits="1" number="54"/>
|
71
|
+
<line hits="1" number="55"/>
|
72
|
+
<line hits="1" number="56"/>
|
73
|
+
<line hits="1" number="57"/>
|
74
|
+
<line hits="1" number="58"/>
|
75
|
+
<line hits="1" number="59"/>
|
76
|
+
<line hits="1" number="60"/>
|
77
|
+
<line hits="1" number="61"/>
|
78
|
+
<line hits="1" number="62"/>
|
79
|
+
<line hits="1" number="63"/>
|
80
|
+
<line hits="1" number="64"/>
|
81
|
+
<line hits="1" number="66"/>
|
82
|
+
<line hits="1" number="68"/>
|
83
|
+
<line hits="1" number="69"/>
|
84
|
+
<line hits="1" number="71"/>
|
85
|
+
<line hits="1" number="72"/>
|
86
|
+
<line hits="1" number="74"/>
|
87
|
+
<line hits="1" number="75"/>
|
88
|
+
<line hits="1" number="76"/>
|
89
|
+
<line hits="1" number="77"/>
|
90
|
+
<line hits="1" number="78"/>
|
91
|
+
<line hits="1" number="82"/>
|
92
|
+
<line hits="1" number="83"/>
|
93
|
+
<line hits="1" number="84"/>
|
94
|
+
<line hits="1" number="85"/>
|
95
|
+
<line hits="1" number="86"/>
|
96
|
+
<line hits="1" number="87"/>
|
97
|
+
<line hits="1" number="88"/>
|
98
|
+
<line hits="1" number="89"/>
|
99
|
+
<line hits="1" number="90"/>
|
100
|
+
<line hits="1" number="92"/>
|
101
|
+
<line hits="1" number="93"/>
|
102
|
+
<line hits="1" number="95"/>
|
103
|
+
<line hits="1" number="96"/>
|
104
|
+
<line hits="1" number="98"/>
|
105
|
+
<line hits="1" number="99"/>
|
106
|
+
<line hits="1" number="100"/>
|
107
|
+
<line hits="1" number="102"/>
|
108
|
+
<line hits="1" number="103"/>
|
109
|
+
<line hits="1" number="110"/>
|
110
|
+
<line hits="1" number="112"/>
|
111
|
+
<line hits="1" number="113"/>
|
112
|
+
<line hits="1" number="120"/>
|
113
|
+
<line hits="1" number="123"/>
|
114
|
+
<line hits="1" number="127"/>
|
115
|
+
<line hits="1" number="128"/>
|
116
|
+
<line hits="1" number="129"/>
|
117
|
+
<line hits="1" number="130"/>
|
118
|
+
<line hits="1" number="131"/>
|
119
|
+
<line hits="1" number="133"/>
|
120
|
+
<line hits="1" number="134"/>
|
121
|
+
<line hits="0" number="140"/>
|
122
|
+
</lines>
|
123
|
+
</class>
|
124
|
+
</classes>
|
125
|
+
</package>
|
126
|
+
<package branch-rate="0.6719" complexity="0" line-rate="0.8438" name="sub_folder">
|
127
|
+
<classes>
|
128
|
+
<class branch-rate="0.6552" complexity="0" filename="sub_folder/sub_one.py" line-rate="0.783" name="sub_one.py">
|
129
|
+
<methods/>
|
130
|
+
<lines>
|
131
|
+
<line hits="1" number="12"/>
|
132
|
+
<line hits="1" number="13"/>
|
133
|
+
<line hits="1" number="14"/>
|
134
|
+
<line hits="1" number="17"/>
|
135
|
+
<line hits="1" number="22"/>
|
136
|
+
<line hits="1" number="23"/>
|
137
|
+
<line hits="1" number="24"/>
|
138
|
+
<line hits="1" number="26"/>
|
139
|
+
<line hits="1" number="27"/>
|
140
|
+
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="29" number="28"/>
|
141
|
+
<line hits="0" number="29"/>
|
142
|
+
<line hits="1" number="30"/>
|
143
|
+
<line hits="1" number="32"/>
|
144
|
+
<line hits="1" number="38"/>
|
145
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="39"/>
|
146
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="40"/>
|
147
|
+
<line hits="1" number="41"/>
|
148
|
+
<line hits="1" number="42"/>
|
149
|
+
<line hits="1" number="44"/>
|
150
|
+
<line hits="1" number="49"/>
|
151
|
+
<line hits="1" number="51"/>
|
152
|
+
<line hits="1" number="56"/>
|
153
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="57"/>
|
154
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="58"/>
|
155
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="59"/>
|
156
|
+
<line hits="1" number="60"/>
|
157
|
+
<line hits="1" number="61"/>
|
158
|
+
<line hits="1" number="63"/>
|
159
|
+
<line hits="1" number="69"/>
|
160
|
+
<line hits="1" number="71"/>
|
161
|
+
<line hits="1" number="76"/>
|
162
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="77"/>
|
163
|
+
<line hits="1" number="78"/>
|
164
|
+
<line hits="1" number="79"/>
|
165
|
+
<line hits="1" number="81"/>
|
166
|
+
<line hits="1" number="87"/>
|
167
|
+
<line hits="1" number="89"/>
|
168
|
+
<line hits="0" number="96"/>
|
169
|
+
<line branch="true" condition-coverage="0% (0/2)" hits="0" missing-branches="98,102" number="97"/>
|
170
|
+
<line branch="true" condition-coverage="0% (0/2)" hits="0" missing-branches="97,99" number="98"/>
|
171
|
+
<line branch="true" condition-coverage="0% (0/2)" hits="0" missing-branches="98,100" number="99"/>
|
172
|
+
<line hits="0" number="100"/>
|
173
|
+
<line hits="0" number="101"/>
|
174
|
+
<line hits="0" number="102"/>
|
175
|
+
<line hits="1" number="104"/>
|
176
|
+
<line hits="1" number="109"/>
|
177
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="110"/>
|
178
|
+
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="112" number="111"/>
|
179
|
+
<line hits="0" number="112"/>
|
180
|
+
<line hits="0" number="113"/>
|
181
|
+
<line hits="1" number="114"/>
|
182
|
+
<line hits="1" number="116"/>
|
183
|
+
<line hits="1" number="121"/>
|
184
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="122"/>
|
185
|
+
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="125" number="123"/>
|
186
|
+
<line hits="0" number="125"/>
|
187
|
+
<line hits="0" number="126"/>
|
188
|
+
<line hits="1" number="127"/>
|
189
|
+
<line hits="1" number="129"/>
|
190
|
+
<line hits="1" number="134"/>
|
191
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="135"/>
|
192
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="136"/>
|
193
|
+
<line hits="1" number="137"/>
|
194
|
+
<line hits="1" number="138"/>
|
195
|
+
<line hits="1" number="139"/>
|
196
|
+
<line hits="1" number="141"/>
|
197
|
+
<line hits="0" number="146"/>
|
198
|
+
<line branch="true" condition-coverage="0% (0/2)" hits="0" missing-branches="148,151" number="147"/>
|
199
|
+
<line branch="true" condition-coverage="0% (0/2)" hits="0" missing-branches="147,149" number="148"/>
|
200
|
+
<line hits="0" number="149"/>
|
201
|
+
<line hits="0" number="150"/>
|
202
|
+
<line hits="0" number="151"/>
|
203
|
+
<line hits="1" number="153"/>
|
204
|
+
<line hits="1" number="158"/>
|
205
|
+
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="163" number="159"/>
|
206
|
+
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="159" number="160"/>
|
207
|
+
<line hits="1" number="161"/>
|
208
|
+
<line hits="1" number="162"/>
|
209
|
+
<line hits="1" number="163"/>
|
210
|
+
<line hits="1" number="165"/>
|
211
|
+
<line hits="1" number="170"/>
|
212
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="171"/>
|
213
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="172"/>
|
214
|
+
<line hits="1" number="173"/>
|
215
|
+
<line hits="1" number="174"/>
|
216
|
+
<line hits="1" number="175"/>
|
217
|
+
<line hits="1" number="177"/>
|
218
|
+
<line hits="1" number="183"/>
|
219
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="184"/>
|
220
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="185"/>
|
221
|
+
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="187" number="186"/>
|
222
|
+
<line hits="0" number="187"/>
|
223
|
+
<line hits="1" number="188"/>
|
224
|
+
<line hits="1" number="190"/>
|
225
|
+
<line hits="1" number="191"/>
|
226
|
+
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="193" number="192"/>
|
227
|
+
<line hits="0" number="193"/>
|
228
|
+
<line branch="true" condition-coverage="0% (0/2)" hits="0" missing-branches="195,196" number="194"/>
|
229
|
+
<line hits="0" number="195"/>
|
230
|
+
<line hits="1" number="196"/>
|
231
|
+
<line hits="1" number="198"/>
|
232
|
+
<line hits="1" number="203"/>
|
233
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="204"/>
|
234
|
+
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="206" number="205"/>
|
235
|
+
<line hits="0" number="206"/>
|
236
|
+
<line hits="1" number="207"/>
|
237
|
+
</lines>
|
238
|
+
</class>
|
239
|
+
<class branch-rate="0.75" complexity="0" filename="sub_folder/sub_two.py" line-rate="0.9333" name="sub_two.py">
|
240
|
+
<methods/>
|
241
|
+
<lines>
|
242
|
+
<line hits="1" number="13"/>
|
243
|
+
<line hits="1" number="14"/>
|
244
|
+
<line hits="1" number="17"/>
|
245
|
+
<line hits="1" number="22"/>
|
246
|
+
<line hits="1" number="23"/>
|
247
|
+
<line hits="1" number="24"/>
|
248
|
+
<line hits="1" number="25"/>
|
249
|
+
<line hits="1" number="26"/>
|
250
|
+
<line hits="1" number="27"/>
|
251
|
+
<line hits="1" number="28"/>
|
252
|
+
<line hits="1" number="30"/>
|
253
|
+
<line hits="1" number="35"/>
|
254
|
+
<line hits="1" number="37"/>
|
255
|
+
<line hits="1" number="42"/>
|
256
|
+
<line hits="1" number="44"/>
|
257
|
+
<line hits="0" number="49"/>
|
258
|
+
<line hits="1" number="51"/>
|
259
|
+
<line hits="1" number="56"/>
|
260
|
+
<line branch="true" condition-coverage="50% (1/2)" hits="1" missing-branches="58" number="57"/>
|
261
|
+
<line hits="0" number="58"/>
|
262
|
+
<line hits="1" number="59"/>
|
263
|
+
<line hits="1" number="61"/>
|
264
|
+
<line hits="1" number="66"/>
|
265
|
+
<line hits="1" number="68"/>
|
266
|
+
<line hits="1" number="73"/>
|
267
|
+
<line branch="true" condition-coverage="100% (2/2)" hits="1" number="74"/>
|
268
|
+
<line hits="1" number="75"/>
|
269
|
+
<line hits="1" number="76"/>
|
270
|
+
<line hits="1" number="78"/>
|
271
|
+
<line hits="1" number="83"/>
|
272
|
+
</lines>
|
273
|
+
</class>
|
274
|
+
<class branch-rate="0" complexity="0" filename="sub_folder/sub_three.py" line-rate="0" name="sub_three.py">
|
275
|
+
<methods/>
|
276
|
+
<lines>
|
277
|
+
<line branch="true" condition-coverage="0% (0/2)" hits="0" number="88"/>
|
278
|
+
</lines>
|
279
|
+
</class>
|
280
|
+
</classes>
|
281
|
+
</package>
|
282
|
+
</packages>
|
283
|
+
</coverage>
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path("spec_helper", __dir__)
|
4
|
+
|
5
|
+
module Danger
|
6
|
+
describe Danger::DangerCobertura do
|
7
|
+
it "should be a plugin" do
|
8
|
+
expect(Danger::DangerCobertura.new(nil)).to be_a Danger::Plugin
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "with Dangerfile" do
|
12
|
+
before do
|
13
|
+
@dangerfile = testing_dangerfile
|
14
|
+
@my_plugin = @dangerfile.cobertura
|
15
|
+
@my_plugin.report = "#{File.dirname(__FILE__)}/assets/coverage.xml"
|
16
|
+
@dangerfile.git.stubs(:modified_files).returns([])
|
17
|
+
@dangerfile.git.stubs(:added_files).returns([])
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "warn_if_file_less_than" do
|
21
|
+
it "raises error if file attribute is nil" do
|
22
|
+
@my_plugin.report = nil
|
23
|
+
expect do
|
24
|
+
@my_plugin.warn_if_file_less_than(percentage: 50.0)
|
25
|
+
end.to raise_error(DangerCobertura::ERROR_FILE_NOT_SET)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "raises error if file attribute is empty" do
|
29
|
+
@my_plugin.report = ""
|
30
|
+
expect do
|
31
|
+
@my_plugin.warn_if_file_less_than(percentage: 50.0)
|
32
|
+
end.to raise_error(DangerCobertura::ERROR_FILE_NOT_SET)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "raises error if file is not found" do
|
36
|
+
@my_plugin.report = "cant/find/my/file.xml"
|
37
|
+
expect do
|
38
|
+
@my_plugin.warn_if_file_less_than(percentage: 50.0)
|
39
|
+
end.to raise_error(/#{@my_plugin.report}/)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "adds warn if total coverage lower than given" do
|
43
|
+
@dangerfile.git.stubs(:modified_files).returns(%w(sub_folder/sub_two.py top_level_one.py))
|
44
|
+
@my_plugin.warn_if_file_less_than(percentage: 90.0)
|
45
|
+
|
46
|
+
expect(@dangerfile.status_report[:warnings]).to include("sub_two.py has less than 90.0% coverage")
|
47
|
+
expect(@dangerfile.status_report[:warnings]).not_to include("top_level_one.py has less than 90.0% coverage")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "does not add warn if coverage not" do
|
51
|
+
@dangerfile.git.stubs(:modified_files).returns(["sub_folder/sub_two.py"])
|
52
|
+
@my_plugin.warn_if_file_less_than(percentage: 10.0)
|
53
|
+
|
54
|
+
expect(@dangerfile.status_report[:warnings]).to be_empty
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "show_coverage" do
|
59
|
+
it "raises error if file attribute is nil" do
|
60
|
+
@my_plugin.report = nil
|
61
|
+
expect do
|
62
|
+
@my_plugin.show_coverage
|
63
|
+
end.to raise_error(DangerCobertura::ERROR_FILE_NOT_SET)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "raises error if file attribute is empty" do
|
67
|
+
@my_plugin.report = ""
|
68
|
+
expect do
|
69
|
+
@my_plugin.show_coverage
|
70
|
+
end.to raise_error(DangerCobertura::ERROR_FILE_NOT_SET)
|
71
|
+
end
|
72
|
+
|
73
|
+
it "raises error if file is not found" do
|
74
|
+
@my_plugin.report = "cant/find/my/file.xml"
|
75
|
+
expect do
|
76
|
+
@my_plugin.show_coverage
|
77
|
+
end.to raise_error(/#{@my_plugin.report}/)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "prints coverage" do
|
81
|
+
@dangerfile.git.stubs(:modified_files).returns(["sub_folder/sub_three.py"])
|
82
|
+
@my_plugin.show_coverage
|
83
|
+
|
84
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include("sub_three.py")
|
85
|
+
expect(@dangerfile.status_report[:markdowns][0].message).to include("0.00")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
ROOT = Pathname.new(File.expand_path("..", __dir__))
|
5
|
+
$:.unshift((ROOT + "lib").to_s)
|
6
|
+
$:.unshift((ROOT + "spec").to_s)
|
7
|
+
|
8
|
+
require "bundler/setup"
|
9
|
+
require "pry"
|
10
|
+
|
11
|
+
require "rspec"
|
12
|
+
require "danger"
|
13
|
+
require "mocha"
|
14
|
+
|
15
|
+
if `git remote -v` == ""
|
16
|
+
puts "You cannot run tests without setting a local git remote on this repo"
|
17
|
+
puts "It's a weird side-effect of Danger's internals."
|
18
|
+
exit(0)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Use coloured output, it's the best.
|
22
|
+
RSpec.configure do |config|
|
23
|
+
config.filter_gems_from_backtrace "bundler"
|
24
|
+
config.color = true
|
25
|
+
config.tty = true
|
26
|
+
config.mock_with :mocha
|
27
|
+
end
|
28
|
+
|
29
|
+
require "danger_plugin"
|
30
|
+
|
31
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
32
|
+
# If you are expanding these files, see if it's already been done ^.
|
33
|
+
|
34
|
+
# A silent version of the user interface,
|
35
|
+
# it comes with an extra function `.string` which will
|
36
|
+
# strip all ANSI colours from the string.
|
37
|
+
|
38
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
39
|
+
def testing_ui
|
40
|
+
@output = StringIO.new
|
41
|
+
def @output.winsize
|
42
|
+
[20, 9999]
|
43
|
+
end
|
44
|
+
|
45
|
+
cork = Cork::Board.new(out: @output)
|
46
|
+
def cork.string
|
47
|
+
out.string.gsub(/\e\[([;\d]+)?m/, "")
|
48
|
+
end
|
49
|
+
cork
|
50
|
+
end
|
51
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
52
|
+
|
53
|
+
# Example environment (ENV) that would come from
|
54
|
+
# running a PR on TravisCI
|
55
|
+
def testing_env
|
56
|
+
{
|
57
|
+
"HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
|
58
|
+
"TRAVIS_PULL_REQUEST" => "800",
|
59
|
+
"TRAVIS_REPO_SLUG" => "artsy/eigen",
|
60
|
+
"TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
|
61
|
+
"DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
# A stubbed out Dangerfile for use in tests
|
66
|
+
def testing_dangerfile
|
67
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
68
|
+
Danger::Dangerfile.new(env, testing_ui)
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,234 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: danger-cobertura
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kyaak
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-25 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: oga
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.15'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.15'
|
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: mocha
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.2'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.4'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.6'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.6'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: yard
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.9'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.9'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: guard
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.14'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.14'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: guard-rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '4.7'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '4.7'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: listen
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 3.0.7
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 3.0.7
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: pry
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
description: A cobertura report plugin for danger.
|
182
|
+
email:
|
183
|
+
- kyaak.dev@gmail.com
|
184
|
+
executables: []
|
185
|
+
extensions: []
|
186
|
+
extra_rdoc_files: []
|
187
|
+
files:
|
188
|
+
- ".gitignore"
|
189
|
+
- ".rubocop.yml"
|
190
|
+
- ".travis.yml"
|
191
|
+
- CHANGELOG.md
|
192
|
+
- Gemfile
|
193
|
+
- Guardfile
|
194
|
+
- LICENSE.txt
|
195
|
+
- README.md
|
196
|
+
- Rakefile
|
197
|
+
- danger-cobertura.gemspec
|
198
|
+
- lib/cobertura/coverage_item.rb
|
199
|
+
- lib/cobertura/gem_version.rb
|
200
|
+
- lib/cobertura/plugin.rb
|
201
|
+
- lib/danger_cobertura.rb
|
202
|
+
- lib/danger_plugin.rb
|
203
|
+
- spec/assets/coverage.xml
|
204
|
+
- spec/cobertura_spec.rb
|
205
|
+
- spec/spec_helper.rb
|
206
|
+
homepage: https://github.com/Kyaak/danger-cobertura
|
207
|
+
licenses:
|
208
|
+
- MIT
|
209
|
+
metadata: {}
|
210
|
+
post_install_message:
|
211
|
+
rdoc_options: []
|
212
|
+
require_paths:
|
213
|
+
- lib
|
214
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ">="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - ">="
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0'
|
224
|
+
requirements: []
|
225
|
+
rubyforge_project:
|
226
|
+
rubygems_version: 2.7.8
|
227
|
+
signing_key:
|
228
|
+
specification_version: 4
|
229
|
+
summary: This plugin allows parsing of an xml coverage report generated by cobertura
|
230
|
+
and displays desired metrics.
|
231
|
+
test_files:
|
232
|
+
- spec/assets/coverage.xml
|
233
|
+
- spec/cobertura_spec.rb
|
234
|
+
- spec/spec_helper.rb
|