rspec-sonarqube-formatter 1.0.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d03dc70a76120bbde342dc6f56331c72ae5248387f708e38536f9004e001bce0
4
- data.tar.gz: 13d4cea8db2682c5bc4f5746d623d96e263ea1fb497be01f8cc74ecf5963d8f7
3
+ metadata.gz: 43dd43071c1162c5b6bb3c3395d22b03827928849d068b8ffca4164931ec39d0
4
+ data.tar.gz: e4d0f3225f626a658cd056557820cf3a27eac84e2b19c29cf71f9511b3afafd2
5
5
  SHA512:
6
- metadata.gz: ab2aca3efd4faf359b44f2cd72de0577aaf36e107e0225cb8b0ab1ad87b61a8662a2793d15abe5729a5e5166c62e6f6e98cd77e5da01cafe139e39422e2ff970
7
- data.tar.gz: 49264403b0ba4672af8e300745d16a62c57dc97304fd6f2483d481104394dde1ba7e39fe09276f44ad1cadb1123a1d73789584a0b4148b5ffaba8958e5ea12ac
6
+ metadata.gz: 4f9ad887a94fd832854c2141f437e344f42f964a4cc8ee30f6b01089d60405a12150f5e472bd8a255156b44c33e7979af457b73baa2ad5188afe62e564e57281
7
+ data.tar.gz: d6ee9483c963ee66665a39e87b7cfba4ae5b8bb6bbb787760d16d4878a6501111923969ab0b705ec49beef359aee89d5185331ec52615aebb6c0287471e8ba88
@@ -1,7 +1,5 @@
1
1
  version: "2"
2
2
  plugins:
3
- git-legal:
4
- enabled: true
5
3
  fixme:
6
4
  enabled: true
7
5
  bundler-audit:
@@ -10,4 +8,3 @@ plugins:
10
8
  enabled: true
11
9
  rubocop:
12
10
  enabled: true
13
-
data/.gitignore CHANGED
@@ -35,3 +35,4 @@ rubocop.json
35
35
  *.gem
36
36
  .bundle/
37
37
  cc-test-reporter
38
+ pkg/*
@@ -5,7 +5,7 @@ AllCops:
5
5
  - rake
6
6
  DisplayStyleGuide: true
7
7
  ExtraDetails: true
8
- TargetRubyVersion: ~
8
+ TargetRubyVersion: 2.4
9
9
  Exclude:
10
10
  - 'vendor/**/*'
11
11
  - 'bin/**/*'
@@ -70,7 +70,3 @@ Layout/HashAlignment:
70
70
  # Align arguments with the same indentation level
71
71
  Layout/ArgumentAlignment:
72
72
  EnforcedStyle: with_fixed_indentation
73
-
74
- # Allow braces around hash parameters, context dependent
75
- Style/BracesAroundHashParameters:
76
- EnforcedStyle: context_dependent
@@ -9,10 +9,10 @@ env:
9
9
  - GIT_COMMITTED_AT=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then git log -1 --pretty=format:%ct; else git log -1 --skip 1 --pretty=format:%ct; fi)
10
10
 
11
11
  rvm:
12
- - 2.3
13
12
  - 2.4
14
13
  - 2.5
15
14
  - 2.6
15
+ - 2.7
16
16
 
17
17
  before_install: gem install bundler
18
18
 
@@ -42,19 +42,19 @@ notifications:
42
42
 
43
43
  deploy:
44
44
  - provider: rubygems
45
- skip_cleanup: true
45
+ cleanup: false
46
46
  api_key:
47
47
  secure: fThOZtHGWfz6JCETpxPtY5/Q/2JwuRMPdtnkUH+591p8ymLfCPW/1UlmJiETvKVVScFh5tLnCKp7bFPhi3/U3Ld1A1c/sG7A+ibpi4kWegiz4V99aAl8Rn/GxL/Bfzx/JTFKXtdgVig5m2vvhSiOHnN/8go18YUXsMKdC9s9pRQBNnv+reVUgiGj88W0NjhtPrBGNtKqk/eekGdjEvdwAYlAAgQ6ZeXgepKtbA3ZU1EwvMsl7RyjLtJ+Bk/nafFWYASbt9RDo2quGYEpSdviIPT8T4ssYT+GNbxOoJ0DVPF/xPreruue58Xa2bvClCU/kb4JUXKIrVbPT4sYJTKZl8LQ/AkjO6NAvsc+MM5wjcJMDLiSgLNa3FMsO58mLYpwS+UG8n09qHD9kSaILyWhhg3A4uXODuL5y942tvEkMt0ZmkVl1i2Ey/5RD7AfFCqz2j+/iJdbUsMBZtZ1iT5h4/W3FGDd5neXTgZJ5qVsxxbt0GyPkg9Du3hgPYpUX9T/CX4FcAKJiilhayw+NDR4wO3Q9ILL+JZwojpNUv0A4EKTDzJ6xeU0iEqyKTtYqiWvHdgCjBXk1RLmLugmAt3391Rjty5wgIiawoTGvNv26tOPk94Iic6Xo4P9vZRtu3YDjXZ4JofFRGOhUazWgVfH9JRYHsT7XOBOPuOMx8aK83w=
48
48
  gem: rspec-sonarqube-formatter
49
49
  on:
50
50
  tags: true
51
- rvm: 2.6
51
+ rvm: 2.7
52
52
  - provider: releases
53
53
  file_glob: true
54
54
  api_key:
55
55
  secure: Qfkej2Tk4iyZS/yzL+g1TMHi+K+8TSCUtYENW3w9daR+0iejicwVHTT01wQT77zUaJ+n5i5B6lXfYIjqA7MivBHf27qJy+6cf4iFZB0kU7KGNv9bXZlXW9T5GZQ8jx1QsIefdqNqmu7Eqjuq9EhrhqrR3dfAeaBXdMX2HiIOEYzhjckJBtGrwPB96SNGTbSnVwwHa8+aHe58DrAvuh6WYBGu8NLJYKpyj8LY7iOBpm15+nx0Lkofj8p0jtUWXCFMOEoWJICY7+Rzqf9badTQJVvcIyJsr9I5GsOkrzrW07DrCsDC1EZHYep2LDjdI5LVU3i8uIfY6MBhvRzATrka7Ho1HDKxTSSLuK7vUxERlb/uf19MYbcV9SniMRwspds2/r+W6YRwM9Yrk0sfo6ZVg3qXs7Ll3jbs7nUjBq8yVIIXLVgwQ7JgmnPgsMQ05PcSc1GZG5rJ+sgbapbTLhss3ygsXPpJg7Tfu3JzJ6zAHrPc/I3HWVvYV2mz7rqhKiXVHKEDN9yULDGIBKgrNZmvyinJhPQay1a1h/jLfX5hp0wSjUeiyZKmdKYOu/6a4myrq+GHaUwtGyWcAk1DzX0d1sMptSKKmj56vjAiLZtGawVazkMdYzMZ5szOCI2wz1ps2A+3h28TL8UOSGCjZgx3dyuXBY9QHweEAJqDy7FlFN8=
56
56
  file: "*.gem"
57
- skip_cleanup: true
57
+ cleanup: false
58
58
  on:
59
59
  tags: true
60
- rvm: 2.6
60
+ rvm: 2.7
@@ -1,13 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-sonarqube-formatter (1.0.0)
4
+ rspec-sonarqube-formatter (1.0.0.pre.local)
5
+ htmlentities (~> 4.3.3)
5
6
  rspec (~> 3.0)
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
- ast (2.4.0)
11
+ ast (2.4.1)
11
12
  coveralls (0.8.23)
12
13
  json (>= 1.8, < 3)
13
14
  simplecov (~> 0.16.1)
@@ -16,13 +17,15 @@ GEM
16
17
  tins (~> 1.6)
17
18
  diff-lcs (1.3)
18
19
  docile (1.3.2)
19
- jaro_winkler (1.5.4)
20
- json (2.2.0)
21
- parallel (1.19.1)
22
- parser (2.6.5.0)
23
- ast (~> 2.4.0)
20
+ htmlentities (4.3.4)
21
+ json (2.3.0)
22
+ parallel (1.19.2)
23
+ parser (2.7.2.0)
24
+ ast (~> 2.4.1)
24
25
  rainbow (3.0.0)
25
26
  rake (13.0.1)
27
+ regexp_parser (1.8.2)
28
+ rexml (3.2.4)
26
29
  rspec (3.9.0)
27
30
  rspec-core (~> 3.9.0)
28
31
  rspec-expectations (~> 3.9.0)
@@ -36,37 +39,41 @@ GEM
36
39
  diff-lcs (>= 1.2.0, < 2.0)
37
40
  rspec-support (~> 3.9.0)
38
41
  rspec-support (3.9.0)
39
- rubocop (0.77.0)
40
- jaro_winkler (~> 1.5.1)
42
+ rubocop (1.0.0)
41
43
  parallel (~> 1.10)
42
- parser (>= 2.6)
44
+ parser (>= 2.7.1.5)
43
45
  rainbow (>= 2.2.2, < 4.0)
46
+ regexp_parser (>= 1.8)
47
+ rexml
48
+ rubocop-ast (>= 0.6.0)
44
49
  ruby-progressbar (~> 1.7)
45
- unicode-display_width (>= 1.4.0, < 1.7)
50
+ unicode-display_width (>= 1.4.0, < 2.0)
51
+ rubocop-ast (0.8.0)
52
+ parser (>= 2.7.1.5)
46
53
  ruby-progressbar (1.10.1)
47
54
  simplecov (0.16.1)
48
55
  docile (~> 1.1)
49
56
  json (>= 1.8, < 3)
50
57
  simplecov-html (~> 0.10.0)
51
58
  simplecov-html (0.10.2)
52
- simplecov-json (0.2)
59
+ simplecov-json (0.2.1)
53
60
  json
54
61
  simplecov
55
62
  term-ansicolor (1.7.1)
56
63
  tins (~> 1.0)
57
64
  thor (0.20.3)
58
65
  tins (1.22.2)
59
- unicode-display_width (1.6.0)
66
+ unicode-display_width (1.7.0)
60
67
 
61
68
  PLATFORMS
62
69
  ruby
63
70
 
64
71
  DEPENDENCIES
65
- bundler (~> 2.0.2)
72
+ bundler (~> 2.1.0)
66
73
  coveralls (~> 0.8.23)
67
74
  rake (~> 13.0.1)
68
75
  rspec-sonarqube-formatter!
69
- rubocop (~> 0.77.0)
76
+ rubocop (~> 1.0.0)
70
77
  simplecov (~> 0.16.1)
71
78
  simplecov-json (~> 0.2.0)
72
79
 
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # RSpec SonarQube Formatter
2
2
 
3
- Rspec formatter to generates an xml file for SonarQube, using the generec-test-data format,
3
+ [RSpec 3](https://rspec.info/) formatter that generates an XML file for [SonarQube](https://www.sonarqube.org/) 6.2+, using
4
+ the [Generic Test Data](https://docs.sonarqube.org/latest/analysis/generic-test/) format.
4
5
 
5
6
  [![Gem Version](https://img.shields.io/gem/v/rspec-sonarqube-formatter)][rubygems]
6
7
  [![Downloads](https://img.shields.io/gem/dt/rspec-sonarqube-formatter)][rubygems]
@@ -19,12 +20,87 @@ Rspec formatter to generates an xml file for SonarQube, using the generec-test-d
19
20
  [sonarqube]: https://sonarcloud.io/dashboard?id=otherguy_rspec-sonarqube-formatter
20
21
  [license]: https://github.com/otherguy/rspec-sonarqube-formatter/blob/master/LICENSE.md
21
22
 
23
+ ## Features 🌈
22
24
 
23
- ## Development
25
+ This formatter generates an XML report that can be read by [SonarQube](https://www.sonarqube.org/) 6.2+.
26
+ Out of the box, SonarQube 6.2+ supports generic formats for test coverage and test execution import. Using the XML file
27
+ generated by this gem, you get an overview of test executions (`passed`, `skipped`, `failed`)
28
+ and the time in milliseconds it took to execute these.
24
29
 
30
+ [![Sonarcloud.io](documentation/sonarcloud.png)][sonarqube]️
31
+
32
+ ## Installation 🚀
33
+
34
+ Add the gem to your application's `Gemfile`:
35
+
36
+ ```ruby
37
+ # RSpec formatters
38
+ gem 'rspec-sonarqube-formatter', '~> 1.4', require: false
39
+ ```
40
+
41
+ Then, update your bundle:
42
+
43
+ $ bundle install
44
+
45
+ Or install it manually using:
46
+
47
+ $ gem install rspec-sonarqube-formatter
48
+
49
+
50
+ ## Usage 🛠
51
+
52
+ Add the following code to your `spec_helper.rb`:
53
+
54
+ ```ruby
55
+ RSpec.configure do |c|
56
+ c.formatter = 'documentation'
57
+ c.add_formatter('RspecSonarqubeFormatter', 'out/test-report.xml')
58
+ ...
59
+ end
60
+ ```
61
+
62
+ Alternatively, edit your `.rspec` file to define your formatters there:
63
+
64
+ ```bash
65
+ # .rspec
66
+ --require spec_helper
67
+ --color
68
+ --format RspecSonarqubeFormatter
69
+ --out out/test-report.xml
70
+ --format documentation
71
+ ```
72
+
73
+ To make SonarQube read the test report, specify the path to the generated XML in your
74
+ [`sonar-project.properties`](sonar-project.properties) or configure it in the SonarQube GUI.
75
+
76
+ ```bash
77
+ # sonar-project.properties
78
+ sonar.testExecutionReportPaths=out/test-report.xml
79
+ ```
80
+
81
+ ## Inspiration 💅
82
+
83
+ The only [existing formatter](https://github.com/witjoh/rspec_sonar_formatter) does not work out of the box and is not
84
+ published to [RubyGems.org](https://rubygems.org/gems/rspec-sonarqube-formatter), so I created my own.
85
+
86
+ Thank you to [`@witjoh`](https://github.com/witjoh) for the original work ♥️!
87
+
88
+
89
+ ## Contributing 🚧
90
+
91
+ Bug reports and pull requests are welcome on GitHub at [`otherguy/rspec-sonarqube-formatter`](https://github.com/otherguy/rspec-sonarqube-formatter).
92
+
93
+ After checking out the repository, you need to install dependencies:
94
+
95
+ ```bash
25
96
  gem install bundler -v 2.0.2
26
97
  bundle install
98
+ ```
99
+
100
+ Then, run `bundle exec rake spec` to run the test suite.
101
+
102
+ To install this gem on your local machine, run `bundle exec rake install`.
27
103
 
104
+ Please check your contributions with RuboCop by running `bundle exec rubocop`.
28
105
 
29
- Tests:
30
- bundle exec rake spec
106
+ Releases are built from tags automatically on [Travis][travis] and pushed to [RubyGems.org][rubygems].
@@ -0,0 +1,20 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ These versions are supported:
6
+
7
+ | Version | Supported |
8
+ | ------- | ------------------ |
9
+ | 1.1.0 | :white_check_mark: |
10
+ | 1.0.0 | :white_check_mark: |
11
+ | < 1.0 | :x: |
12
+
13
+ ## Reporting a Vulnerability
14
+
15
+ Please report any vulnerabilities
16
+ [as an issue](https://github.com/otherguy/rspec-sonarqube-formatter/issues)
17
+ and tag it with `security`.
18
+
19
+ Expect a response within 24 hours. Any vulnerabilities will be fixed
20
+ within a reasonable time frame.
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'htmlentities'
4
+
3
5
  class RspecSonarqubeFormatter
4
- ::RSpec::Core::Formatters.register self, :example_group_started, :example_started, :example_passed,
5
- :example_pending, :example_failed, :start, :stop, :exam
6
+ ::RSpec::Core::Formatters.register self,
7
+ :start, :stop, :example_group_started, :example_started, :example_passed, :example_failed, :example_pending
6
8
 
7
9
  def initialize(output)
8
10
  @output = output
@@ -29,25 +31,31 @@ class RspecSonarqubeFormatter
29
31
  @current_file = notification.group.metadata[:file_path]
30
32
  end
31
33
 
32
- def example_started(notification)
33
- @output.puts " <testCase name=\"#{clean_string(notification.example.description)}\" duration=\"#{(notification.example.execution_result.run_time.to_f * 1000).round}\">"
34
+ def example_started(_notification)
35
+ # Do nothing
34
36
  end
35
37
 
36
- def example_failed(notification)
37
- @output.puts " <failure message=\"#{notification.exception}\" stacktrace=\"#{notification.example.location}\" />"
38
- @output.puts ' </testCase>'
38
+ def example_passed(notification)
39
+ @output.puts " <testCase name=\"#{clean_string(notification.example.description)}\" duration=\"#{duration(notification.example)}\" />"
39
40
  end
40
41
 
41
- def example_passed(_notification)
42
+ def example_failed(notification)
43
+ @output.puts " <testCase name=\"#{clean_string(notification.example.description)}\" duration=\"#{duration(notification.example)}\">"
44
+ @output.puts " <failure message=\"#{clean_string(notification.exception)}\" stacktrace=\"#{clean_string(notification.example.location)}\" />"
42
45
  @output.puts ' </testCase>'
43
46
  end
44
47
 
45
48
  def example_pending(notification)
49
+ @output.puts " <testCase name=\"#{clean_string(notification.example.description)}\" duration=\"#{duration(notification.example)}\">"
46
50
  @output.puts " <skipped message=\"#{clean_string(notification.example.execution_result.pending_message)}\" />"
47
51
  @output.puts ' </testCase>'
48
52
  end
49
53
 
50
54
  def clean_string(input)
51
- input.to_s.gsub(/\e\[\d;*\d*m/, '').tr('"', "'")
55
+ HTMLEntities.new.encode input.to_s.gsub(/\e\[\d;*\d*m/, '').tr('"', "'")
56
+ end
57
+
58
+ def duration(example)
59
+ (example.execution_result.run_time.to_f * 1000).round
52
60
  end
53
61
  end
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = 'rspec-sonarqube-formatter'
8
8
 
9
9
  # rubocop:disable Gemspec/DuplicatedAssignment
10
- spec.version = '1.0.0-pre'
10
+ spec.version = '1.0.0-local'
11
11
  spec.version = ENV.fetch('TRAVIS_TAG') { spec.version }.to_s if ENV['TRAVIS']
12
12
  # rubocop:enable Gemspec/DuplicatedAssignment
13
13
 
@@ -31,11 +31,15 @@ Gem::Specification.new do |spec|
31
31
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
32
  spec.require_paths = ['lib']
33
33
 
34
- spec.add_dependency 'rspec', '~> 3.0'
35
- spec.add_development_dependency 'bundler', '~> 2.0.2'
36
- spec.add_development_dependency 'coveralls', '~> 0.8.23'
37
- spec.add_development_dependency 'rake', '~> 13.0.1'
38
- spec.add_development_dependency 'rubocop', '~> 0.77.0'
39
- spec.add_development_dependency 'simplecov', '~> 0.16.1'
34
+ spec.required_ruby_version = '>= 2.4.0'
35
+
36
+ spec.add_dependency 'htmlentities', '~> 4.3.3'
37
+ spec.add_dependency 'rspec', '~> 3.0'
38
+
39
+ spec.add_development_dependency 'bundler', '~> 2.1.0'
40
+ spec.add_development_dependency 'coveralls', '~> 0.8.23'
41
+ spec.add_development_dependency 'rake', '~> 13.0.1'
42
+ spec.add_development_dependency 'rubocop', '~> 1.0.0'
43
+ spec.add_development_dependency 'simplecov', '~> 0.16.1'
40
44
  spec.add_development_dependency 'simplecov-json', '~> 0.2.0'
41
45
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-sonarqube-formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Graf
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-05 00:00:00.000000000 Z
11
+ date: 2020-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: htmlentities
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.3.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.3.3
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -30,14 +44,14 @@ dependencies:
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: 2.0.2
47
+ version: 2.1.0
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: 2.0.2
54
+ version: 2.1.0
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: coveralls
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +86,14 @@ dependencies:
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: 0.77.0
89
+ version: 1.0.0
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: 0.77.0
96
+ version: 1.0.0
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: simplecov
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -132,6 +146,8 @@ files:
132
146
  - LICENSE.md
133
147
  - README.md
134
148
  - Rakefile
149
+ - SECURITY.md
150
+ - documentation/sonarcloud.png
135
151
  - lib/rspec_sonarqube_formatter.rb
136
152
  - rspec-sonarqube-formatter.gemspec
137
153
  - sonar-project.properties
@@ -149,15 +165,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
165
  requirements:
150
166
  - - ">="
151
167
  - !ruby/object:Gem::Version
152
- version: '0'
168
+ version: 2.4.0
153
169
  required_rubygems_version: !ruby/object:Gem::Requirement
154
170
  requirements:
155
171
  - - ">"
156
172
  - !ruby/object:Gem::Version
157
173
  version: 1.3.1
158
174
  requirements: []
159
- rubyforge_project:
160
- rubygems_version: 2.7.7
175
+ rubygems_version: 3.0.8
161
176
  signing_key:
162
177
  specification_version: 4
163
178
  summary: Generic test data formatter for SonarQube