rubocop-checkstyle_formatter 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +13 -0
  3. data/.rubocop_todo.yml +24 -0
  4. data/.travis.yml +10 -17
  5. data/Appraisals +7 -11
  6. data/gemfiles/rubocop_0.40.0.gemfile.lock +11 -10
  7. data/gemfiles/rubocop_0.41.2.gemfile.lock +11 -10
  8. data/gemfiles/rubocop_0.42.0.gemfile.lock +11 -10
  9. data/gemfiles/{rubocop_0.30.1.gemfile → rubocop_0.43.0.gemfile} +1 -1
  10. data/gemfiles/{rubocop_0.39.0.gemfile.lock → rubocop_0.43.0.gemfile.lock} +14 -13
  11. data/gemfiles/{rubocop_0.32.1.gemfile → rubocop_0.44.1.gemfile} +1 -1
  12. data/gemfiles/{rubocop_0.38.0.gemfile.lock → rubocop_0.44.1.gemfile.lock} +14 -13
  13. data/gemfiles/{rubocop_0.31.0.gemfile → rubocop_0.45.0.gemfile} +1 -1
  14. data/gemfiles/{rubocop_0.36.0.gemfile.lock → rubocop_0.45.0.gemfile.lock} +15 -12
  15. data/gemfiles/{rubocop_0.33.0.gemfile → rubocop_0.46.0.gemfile} +1 -1
  16. data/gemfiles/{rubocop_0.37.2.gemfile.lock → rubocop_0.46.0.gemfile.lock} +15 -14
  17. data/gemfiles/rubocop_0.47.1.gemfile +7 -0
  18. data/gemfiles/rubocop_0.47.1.gemfile.lock +57 -0
  19. data/gemfiles/rubocop_0.48.1.gemfile +7 -0
  20. data/gemfiles/rubocop_0.48.1.gemfile.lock +57 -0
  21. data/lib/rubocop/formatter/checkstyle_formatter.rb +15 -11
  22. data/rubocop-checkstyle_formatter.gemspec +8 -6
  23. data/spec/rubocop/formatter/checkstyle_formatter_spec.rb +24 -4
  24. data/spec/spec_helper.rb +1 -1
  25. metadata +19 -25
  26. data/gemfiles/rubocop_0.30.1.gemfile.lock +0 -57
  27. data/gemfiles/rubocop_0.31.0.gemfile.lock +0 -57
  28. data/gemfiles/rubocop_0.32.1.gemfile.lock +0 -57
  29. data/gemfiles/rubocop_0.33.0.gemfile.lock +0 -57
  30. data/gemfiles/rubocop_0.34.2.gemfile +0 -7
  31. data/gemfiles/rubocop_0.34.2.gemfile.lock +0 -57
  32. data/gemfiles/rubocop_0.35.1.gemfile +0 -7
  33. data/gemfiles/rubocop_0.35.1.gemfile.lock +0 -59
  34. data/gemfiles/rubocop_0.36.0.gemfile +0 -7
  35. data/gemfiles/rubocop_0.37.2.gemfile +0 -7
  36. data/gemfiles/rubocop_0.38.0.gemfile +0 -7
  37. data/gemfiles/rubocop_0.39.0.gemfile +0 -7
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rubocop", "0.33.0"
5
+ gem "rubocop", "0.46.0"
6
6
 
7
7
  gemspec :path => "../"
@@ -1,8 +1,8 @@
1
1
  PATH
2
- remote: ../
2
+ remote: ..
3
3
  specs:
4
- rubocop-checkstyle_formatter (0.2.0)
5
- rubocop (>= 0.20.1)
4
+ rubocop-checkstyle_formatter (0.3.0)
5
+ rubocop (>= 0.30.1)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -12,17 +12,18 @@ GEM
12
12
  rake
13
13
  thor (>= 0.14.0)
14
14
  ast (2.3.0)
15
- diff-lcs (1.2.5)
16
- parser (2.3.1.2)
15
+ diff-lcs (1.3)
16
+ parser (2.4.0.0)
17
17
  ast (~> 2.2)
18
18
  powerpack (0.1.1)
19
- rainbow (2.1.0)
19
+ rainbow (2.2.2)
20
+ rake
20
21
  rake (10.5.0)
21
22
  rspec (3.5.0)
22
23
  rspec-core (~> 3.5.0)
23
24
  rspec-expectations (~> 3.5.0)
24
25
  rspec-mocks (~> 3.5.0)
25
- rspec-core (3.5.2)
26
+ rspec-core (3.5.4)
26
27
  rspec-support (~> 3.5.0)
27
28
  rspec-expectations (3.5.0)
28
29
  diff-lcs (>= 1.2.0, < 2.0)
@@ -31,15 +32,15 @@ GEM
31
32
  diff-lcs (>= 1.2.0, < 2.0)
32
33
  rspec-support (~> 3.5.0)
33
34
  rspec-support (3.5.0)
34
- rubocop (0.37.2)
35
- parser (>= 2.3.0.4, < 3.0)
35
+ rubocop (0.46.0)
36
+ parser (>= 2.3.1.1, < 3.0)
36
37
  powerpack (~> 0.1)
37
38
  rainbow (>= 1.99.1, < 3.0)
38
39
  ruby-progressbar (~> 1.7)
39
- unicode-display_width (~> 0.3)
40
+ unicode-display_width (~> 1.0, >= 1.0.1)
40
41
  ruby-progressbar (1.8.1)
41
- thor (0.19.1)
42
- unicode-display_width (0.3.1)
42
+ thor (0.19.4)
43
+ unicode-display_width (1.2.1)
43
44
 
44
45
  PLATFORMS
45
46
  ruby
@@ -49,8 +50,8 @@ DEPENDENCIES
49
50
  bundler (~> 1.3)
50
51
  rake (~> 10.1)
51
52
  rspec (~> 3.5.0)
52
- rubocop (= 0.37.2)
53
+ rubocop (= 0.46.0)
53
54
  rubocop-checkstyle_formatter!
54
55
 
55
56
  BUNDLED WITH
56
- 1.12.5
57
+ 1.14.6
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rubocop", "0.47.1"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,57 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rubocop-checkstyle_formatter (0.3.0)
5
+ rubocop (>= 0.30.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ appraisal (1.0.3)
11
+ bundler
12
+ rake
13
+ thor (>= 0.14.0)
14
+ ast (2.3.0)
15
+ diff-lcs (1.3)
16
+ parser (2.4.0.0)
17
+ ast (~> 2.2)
18
+ powerpack (0.1.1)
19
+ rainbow (2.2.2)
20
+ rake
21
+ rake (10.5.0)
22
+ rspec (3.5.0)
23
+ rspec-core (~> 3.5.0)
24
+ rspec-expectations (~> 3.5.0)
25
+ rspec-mocks (~> 3.5.0)
26
+ rspec-core (3.5.4)
27
+ rspec-support (~> 3.5.0)
28
+ rspec-expectations (3.5.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.5.0)
31
+ rspec-mocks (3.5.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.5.0)
34
+ rspec-support (3.5.0)
35
+ rubocop (0.47.1)
36
+ parser (>= 2.3.3.1, < 3.0)
37
+ powerpack (~> 0.1)
38
+ rainbow (>= 1.99.1, < 3.0)
39
+ ruby-progressbar (~> 1.7)
40
+ unicode-display_width (~> 1.0, >= 1.0.1)
41
+ ruby-progressbar (1.8.1)
42
+ thor (0.19.4)
43
+ unicode-display_width (1.2.1)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ appraisal (~> 1.0.0)
50
+ bundler (~> 1.3)
51
+ rake (~> 10.1)
52
+ rspec (~> 3.5.0)
53
+ rubocop (= 0.47.1)
54
+ rubocop-checkstyle_formatter!
55
+
56
+ BUNDLED WITH
57
+ 1.14.6
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rubocop", "0.48.1"
6
+
7
+ gemspec :path => "../"
@@ -0,0 +1,57 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ rubocop-checkstyle_formatter (0.3.0)
5
+ rubocop (>= 0.30.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ appraisal (1.0.3)
11
+ bundler
12
+ rake
13
+ thor (>= 0.14.0)
14
+ ast (2.3.0)
15
+ diff-lcs (1.3)
16
+ parser (2.4.0.0)
17
+ ast (~> 2.2)
18
+ powerpack (0.1.1)
19
+ rainbow (2.2.2)
20
+ rake
21
+ rake (10.5.0)
22
+ rspec (3.5.0)
23
+ rspec-core (~> 3.5.0)
24
+ rspec-expectations (~> 3.5.0)
25
+ rspec-mocks (~> 3.5.0)
26
+ rspec-core (3.5.4)
27
+ rspec-support (~> 3.5.0)
28
+ rspec-expectations (3.5.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.5.0)
31
+ rspec-mocks (3.5.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.5.0)
34
+ rspec-support (3.5.0)
35
+ rubocop (0.48.1)
36
+ parser (>= 2.3.3.1, < 3.0)
37
+ powerpack (~> 0.1)
38
+ rainbow (>= 1.99.1, < 3.0)
39
+ ruby-progressbar (~> 1.7)
40
+ unicode-display_width (~> 1.0, >= 1.0.1)
41
+ ruby-progressbar (1.8.1)
42
+ thor (0.19.4)
43
+ unicode-display_width (1.2.1)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ appraisal (~> 1.0.0)
50
+ bundler (~> 1.3)
51
+ rake (~> 10.1)
52
+ rspec (~> 3.5.0)
53
+ rubocop (= 0.48.1)
54
+ rubocop-checkstyle_formatter!
55
+
56
+ BUNDLED WITH
57
+ 1.14.6
@@ -3,14 +3,14 @@ require 'rexml/document'
3
3
  require 'rubocop/formatter/base_formatter'
4
4
 
5
5
  # XXX: Renamed to RuboCop since 0.23.0
6
- RuboCop = Rubocop if defined?(Rubocop) && ! defined?(RuboCop)
6
+ RuboCop = Rubocop if defined?(Rubocop) && !defined?(RuboCop)
7
7
 
8
8
  module RuboCop
9
9
  module Formatter
10
10
  # = This formatter reports in Checkstyle format.
11
11
  class CheckstyleFormatter < BaseFormatter
12
12
  include PathUtil if defined?(PathUtil)
13
- def started(target_file)
13
+ def started(_target_file)
14
14
  @document = REXML::Document.new.tap do |d|
15
15
  d << REXML::XMLDecl.new
16
16
  end
@@ -20,15 +20,13 @@ module RuboCop
20
20
  def file_finished(file, offences)
21
21
  REXML::Element.new('file', @checkstyle).tap do |f|
22
22
  path_name = file
23
- path_name = relative_path(file) if defined?(relative_path)
23
+ path_name = relative_path(path_name) if !ENV.has_key?('RUBOCOP_CHECKSTYLE_FORMATTER_ABSOLUTE_PATH') && defined?(relative_path)
24
24
  f.attributes['name'] = path_name
25
- # f.attributes['name'] =
26
- # defined?(PathUtil) ? PathUtil.relative_path(file) : file
27
25
  add_offences(f, offences)
28
26
  end
29
27
  end
30
28
 
31
- def finished(inspected_files)
29
+ def finished(_inspected_files)
32
30
  @document.write(output, 2)
33
31
  end
34
32
 
@@ -37,15 +35,21 @@ module RuboCop
37
35
  def add_offences(parent, offences)
38
36
  offences.each do |offence|
39
37
  REXML::Element.new('error', parent).tap do |e|
40
- e.attributes['line'] = offence.line
41
- e.attributes['column'] = offence.column
42
- e.attributes['severity'] = to_checkstyle_severity(offence.severity.to_s)
43
- e.attributes['message'] = offence.message
44
- e.attributes['source'] = 'com.puppycrawl.tools.checkstyle.' + offence.cop_name
38
+ e.add_attributes(offence_attributes(offence))
45
39
  end
46
40
  end
47
41
  end
48
42
 
43
+ def offence_attributes(offence)
44
+ {
45
+ 'line' => offence.line,
46
+ 'column' => offence.column,
47
+ 'severity' => to_checkstyle_severity(offence.severity.to_s),
48
+ 'message' => offence.message,
49
+ 'source' => 'com.puppycrawl.tools.checkstyle.' + offence.cop_name
50
+ }
51
+ end
52
+
49
53
  # TODO be able to configure severity mapping
50
54
  def to_checkstyle_severity(rubocop_severity)
51
55
  case rubocop_severity.to_s
@@ -1,23 +1,25 @@
1
1
  # -*- encoding: utf-8 -*-
2
+
3
+ require 'English'
2
4
  lib = File.expand_path('../lib', __FILE__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
 
5
7
  Gem::Specification.new do |gem|
6
8
  gem.name = 'rubocop-checkstyle_formatter'
7
- gem.version = '0.3.0'
9
+ gem.version = '0.4.0'
8
10
  gem.authors = ['Eito Katagiri']
9
11
  gem.email = ['eitoball@gmail.com']
10
- gem.description = %q{A formatter for rubocop that outputs in checkstyle format}
11
- gem.summary = %q{A formatter for rubocop that outputs in checkstyle format}
12
+ gem.description = 'A formatter for rubocop that outputs in checkstyle format'
13
+ gem.summary = 'A formatter for rubocop that outputs in checkstyle format'
12
14
  gem.homepage = 'https://github.com/eitoball/rubocop-checkstyle_formatter'
13
15
  gem.license = 'MIT'
14
16
 
15
- gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
17
19
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
20
  gem.require_paths = ['lib']
19
21
 
20
- gem.add_dependency 'rubocop', '>= 0.30.1'
22
+ gem.add_dependency 'rubocop', '>= 0.35.1'
21
23
  gem.add_development_dependency 'appraisal', '~> 1.0.0'
22
24
  gem.add_development_dependency 'bundler', '~> 1.3'
23
25
  gem.add_development_dependency 'rake', '~> 10.1'
@@ -1,4 +1,5 @@
1
1
  # encoding: utf-8
2
+
2
3
  require 'spec_helper'
3
4
  require 'stringio'
4
5
  require 'rexml/document'
@@ -6,7 +7,7 @@ require 'rexml/document'
6
7
  module RuboCop
7
8
  module Formatter
8
9
  describe CheckstyleFormatter do
9
- let(:severities) { [:refactor, :convention, :warning, :error, :fatal] }
10
+ let(:severities) { %i[refactor convention warning error fatal] }
10
11
  let(:cop) do
11
12
  Cop::Cop.new.tap do |c|
12
13
  source_buffer = Parser::Source::Buffer.new('sample.rb', 1).tap { |b| b.source = '' }
@@ -43,13 +44,32 @@ module RuboCop
43
44
  message = error.attribute('message').value
44
45
  severity = error.attribute('severity').value
45
46
  case message
46
- when 'refactor', 'convention'; expect(severity).to eq('info')
47
- when 'warning'; expect(severity).to eq('warning')
48
- when 'error', 'fatal'; expect(severity).to eq('error')
47
+ when 'refactor', 'convention' then expect(severity).to eq('info')
48
+ when 'warning' then expect(severity).to eq('warning')
49
+ when 'error', 'fatal' then expect(severity).to eq('error')
49
50
  end
50
51
  end
51
52
  end
52
53
  end
54
+
55
+ context 'RUBOCOP_CHECKSTYLE_FORMATTER_ABSOLUTE_PATH is defined' do
56
+ around do |example|
57
+ ENV['RUBOCOP_CHECKSTYLE_FORMATTER_ABSOLUTE_PATH'] = 'true'
58
+ example.run
59
+ ENV.delete('RUBOCOP_CHECKSTYLE_FORMATTER_ABSOLUTE_PATH')
60
+ end
61
+
62
+ it 'should use absolute path in name attribute of file tag' do
63
+ output = StringIO.new
64
+ formatter = described_class.new(output)
65
+ formatter.started(file)
66
+ formatter.file_finished(file, cop.respond_to?(:offenses) ? cop.offenses : cop.offences)
67
+ formatter.finished([file])
68
+ doc = REXML::Document.new(output.string)
69
+ file = REXML::XPath.first(doc, '/checkstyle/file')
70
+ expect(Pathname.new(file['name'])).to be_absolute
71
+ end
72
+ end
53
73
  end
54
74
  end
55
75
  end
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w{ .. lib }))
3
+ $LOAD_PATH.unshift(File.absolute_path('../../lib', __FILE__))
4
4
  require 'rspec'
5
5
  require 'rubocop'
6
6
  require 'rubocop/formatter/checkstyle_formatter'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-checkstyle_formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eito Katagiri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-26 00:00:00.000000000 Z
11
+ date: 2017-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.30.1
19
+ version: 0.35.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.30.1
26
+ version: 0.35.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: appraisal
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -88,38 +88,32 @@ extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
90
  - ".gitignore"
91
+ - ".rubocop.yml"
92
+ - ".rubocop_todo.yml"
91
93
  - ".travis.yml"
92
94
  - Appraisals
93
95
  - Gemfile
94
96
  - LICENSE.txt
95
97
  - README.md
96
98
  - Rakefile
97
- - gemfiles/rubocop_0.30.1.gemfile
98
- - gemfiles/rubocop_0.30.1.gemfile.lock
99
- - gemfiles/rubocop_0.31.0.gemfile
100
- - gemfiles/rubocop_0.31.0.gemfile.lock
101
- - gemfiles/rubocop_0.32.1.gemfile
102
- - gemfiles/rubocop_0.32.1.gemfile.lock
103
- - gemfiles/rubocop_0.33.0.gemfile
104
- - gemfiles/rubocop_0.33.0.gemfile.lock
105
- - gemfiles/rubocop_0.34.2.gemfile
106
- - gemfiles/rubocop_0.34.2.gemfile.lock
107
- - gemfiles/rubocop_0.35.1.gemfile
108
- - gemfiles/rubocop_0.35.1.gemfile.lock
109
- - gemfiles/rubocop_0.36.0.gemfile
110
- - gemfiles/rubocop_0.36.0.gemfile.lock
111
- - gemfiles/rubocop_0.37.2.gemfile
112
- - gemfiles/rubocop_0.37.2.gemfile.lock
113
- - gemfiles/rubocop_0.38.0.gemfile
114
- - gemfiles/rubocop_0.38.0.gemfile.lock
115
- - gemfiles/rubocop_0.39.0.gemfile
116
- - gemfiles/rubocop_0.39.0.gemfile.lock
117
99
  - gemfiles/rubocop_0.40.0.gemfile
118
100
  - gemfiles/rubocop_0.40.0.gemfile.lock
119
101
  - gemfiles/rubocop_0.41.2.gemfile
120
102
  - gemfiles/rubocop_0.41.2.gemfile.lock
121
103
  - gemfiles/rubocop_0.42.0.gemfile
122
104
  - gemfiles/rubocop_0.42.0.gemfile.lock
105
+ - gemfiles/rubocop_0.43.0.gemfile
106
+ - gemfiles/rubocop_0.43.0.gemfile.lock
107
+ - gemfiles/rubocop_0.44.1.gemfile
108
+ - gemfiles/rubocop_0.44.1.gemfile.lock
109
+ - gemfiles/rubocop_0.45.0.gemfile
110
+ - gemfiles/rubocop_0.45.0.gemfile.lock
111
+ - gemfiles/rubocop_0.46.0.gemfile
112
+ - gemfiles/rubocop_0.46.0.gemfile.lock
113
+ - gemfiles/rubocop_0.47.1.gemfile
114
+ - gemfiles/rubocop_0.47.1.gemfile.lock
115
+ - gemfiles/rubocop_0.48.1.gemfile
116
+ - gemfiles/rubocop_0.48.1.gemfile.lock
123
117
  - lib/rubocop/formatter/checkstyle_formatter.rb
124
118
  - rubocop-checkstyle_formatter.gemspec
125
119
  - spec/rubocop/formatter/checkstyle_formatter_spec.rb
@@ -144,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
138
  version: '0'
145
139
  requirements: []
146
140
  rubyforge_project:
147
- rubygems_version: 2.5.1
141
+ rubygems_version: 2.6.11
148
142
  signing_key:
149
143
  specification_version: 4
150
144
  summary: A formatter for rubocop that outputs in checkstyle format