pronto-rubocop 0.9.1 → 0.10.0
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 +4 -4
- data/README.md +3 -4
- data/lib/pronto/rubocop.rb +5 -62
- data/lib/pronto/rubocop/patch_cop.rb +79 -0
- data/lib/pronto/rubocop/version.rb +1 -1
- data/pronto-rubocop.gemspec +2 -2
- metadata +13 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '061479d3c9326adbd73af0ee8e79c5a1f46ed3aa8f8ea8dfa7b7946a899e4aff'
|
4
|
+
data.tar.gz: 22ab34372429508f391103d663cb462650fac8c08110771ff897400a22662a42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c921d367340e6b725fd6f5c057c0d7ba3fbdab8b03f1ea5a56a559a6336ca646fca67f0f4f6467822db4c300779a015565fb48cf099bf22a38a549f6af8f846e
|
7
|
+
data.tar.gz: f1711fd2fb7c1bdd9c2374307879eb91e3af059928668a92864def3fea788f3f884075c08b9416623e770aa6309b13a6088d0308a4451047ee5ef529dea55647
|
data/README.md
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
# Pronto runner for Rubocop
|
2
2
|
|
3
|
-
[](https://codeclimate.com/github/prontolabs/pronto-rubocop)
|
4
|
+
[](https://travis-ci.org/prontolabs/pronto-rubocop)
|
5
5
|
[](http://badge.fury.io/rb/pronto-rubocop)
|
6
|
-
[](https://gemnasium.com/mmozuras/pronto-rubocop)
|
7
6
|
|
8
|
-
Pronto runner for [Rubocop](https://github.com/bbatsov/rubocop), ruby code analyzer. [What is Pronto?](https://github.com/
|
7
|
+
Pronto runner for [Rubocop](https://github.com/bbatsov/rubocop), ruby code analyzer. [What is Pronto?](https://github.com/prontolabs/pronto)
|
9
8
|
|
10
9
|
## Configuration
|
11
10
|
|
data/lib/pronto/rubocop.rb
CHANGED
@@ -1,71 +1,14 @@
|
|
1
1
|
require 'pronto'
|
2
2
|
require 'rubocop'
|
3
|
+
require 'pronto/rubocop/patch_cop'
|
3
4
|
|
4
5
|
module Pronto
|
5
6
|
class Rubocop < Runner
|
6
|
-
def initialize(_, _ = nil)
|
7
|
-
super
|
8
|
-
|
9
|
-
@config_store = ::RuboCop::ConfigStore.new
|
10
|
-
@config_store.options_config = ENV['RUBOCOP_CONFIG'] if ENV['RUBOCOP_CONFIG']
|
11
|
-
@inspector = ::RuboCop::Runner.new({}, @config_store)
|
12
|
-
end
|
13
|
-
|
14
7
|
def run
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
.
|
19
|
-
.flatten.compact
|
20
|
-
end
|
21
|
-
|
22
|
-
def valid_patch?(patch)
|
23
|
-
return false if patch.additions < 1
|
24
|
-
|
25
|
-
config_store = config_store_for(patch)
|
26
|
-
path = patch.new_file_full_path
|
27
|
-
|
28
|
-
return false if config_store.file_to_exclude?(path.to_s)
|
29
|
-
return true if config_store.file_to_include?(path.to_s)
|
30
|
-
|
31
|
-
ruby_file?(path)
|
32
|
-
end
|
33
|
-
|
34
|
-
def inspect(patch)
|
35
|
-
processed_source = processed_source_for(patch)
|
36
|
-
offences = @inspector.send(:inspect_file, processed_source).first
|
37
|
-
|
38
|
-
offences.sort.reject(&:disabled?).map do |offence|
|
39
|
-
patch.added_lines
|
40
|
-
.select { |line| line.new_lineno == offence.line }
|
41
|
-
.map { |line| new_message(offence, line) }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def new_message(offence, line)
|
46
|
-
path = line.patch.delta.new_file[:path]
|
47
|
-
level = level(offence.severity.name)
|
48
|
-
|
49
|
-
Message.new(path, line, level, offence.message, nil, self.class)
|
50
|
-
end
|
51
|
-
|
52
|
-
def config_store_for(patch)
|
53
|
-
path = patch.new_file_full_path.to_s
|
54
|
-
@config_store.for(path)
|
55
|
-
end
|
56
|
-
|
57
|
-
def processed_source_for(patch)
|
58
|
-
path = patch.new_file_full_path.to_s
|
59
|
-
::RuboCop::ProcessedSource.from_file(path, RUBY_VERSION[0..2].to_f)
|
60
|
-
end
|
61
|
-
|
62
|
-
def level(severity)
|
63
|
-
case severity
|
64
|
-
when :refactor, :convention
|
65
|
-
:warning
|
66
|
-
when :warning, :error, :fatal
|
67
|
-
severity
|
68
|
-
end
|
8
|
+
ruby_patches
|
9
|
+
.select { |patch| patch.additions > 0 }
|
10
|
+
.map { |patch| PatchCop.new(patch, self).messages }
|
11
|
+
.flatten
|
69
12
|
end
|
70
13
|
end
|
71
14
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Pronto
|
2
|
+
class Rubocop < Runner
|
3
|
+
class PatchCop
|
4
|
+
def initialize(patch, runner)
|
5
|
+
@patch = patch
|
6
|
+
@runner = runner
|
7
|
+
end
|
8
|
+
|
9
|
+
def messages
|
10
|
+
return [] unless valid?
|
11
|
+
|
12
|
+
offences.map do |offence|
|
13
|
+
patch
|
14
|
+
.added_lines
|
15
|
+
.select { |line| line.new_lineno == offence.line }
|
16
|
+
.map { |line| new_message(offence, line) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :patch, :runner
|
23
|
+
|
24
|
+
def valid?
|
25
|
+
return false if config.file_to_exclude?(path)
|
26
|
+
return true if config.file_to_include?(path)
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
def path
|
31
|
+
@path ||= patch.new_file_full_path.to_s
|
32
|
+
end
|
33
|
+
|
34
|
+
def config
|
35
|
+
@config ||= begin
|
36
|
+
store = ::RuboCop::ConfigStore.new
|
37
|
+
store.options_config = ENV['RUBOCOP_CONFIG'] if ENV['RUBOCOP_CONFIG']
|
38
|
+
store.for(path)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def offences
|
43
|
+
team
|
44
|
+
.inspect_file(processed_source)
|
45
|
+
.sort
|
46
|
+
.reject(&:disabled?)
|
47
|
+
end
|
48
|
+
|
49
|
+
def team
|
50
|
+
@team ||= ::RuboCop::Cop::Team.new(registry, config)
|
51
|
+
end
|
52
|
+
|
53
|
+
def registry
|
54
|
+
@registry ||= ::RuboCop::Cop::Registry.new(RuboCop::Cop::Cop.all)
|
55
|
+
end
|
56
|
+
|
57
|
+
def processed_source
|
58
|
+
@processed_source ||=
|
59
|
+
::RuboCop::ProcessedSource.from_file(path, config.target_ruby_version)
|
60
|
+
end
|
61
|
+
|
62
|
+
def new_message(offence, line)
|
63
|
+
path = line.patch.delta.new_file[:path]
|
64
|
+
level = level(offence.severity.name)
|
65
|
+
|
66
|
+
Message.new(path, line, level, offence.message, nil, runner.class)
|
67
|
+
end
|
68
|
+
|
69
|
+
def level(severity)
|
70
|
+
case severity
|
71
|
+
when :refactor, :convention
|
72
|
+
:warning
|
73
|
+
when :warning, :error, :fatal
|
74
|
+
severity
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/pronto-rubocop.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.summary = 'Pronto runner for Rubocop, ruby code analyzer'
|
15
15
|
|
16
16
|
s.licenses = ['MIT']
|
17
|
-
s.required_ruby_version = '>= 2.
|
17
|
+
s.required_ruby_version = '>= 2.3.0'
|
18
18
|
s.rubygems_version = '1.8.23'
|
19
19
|
|
20
20
|
s.files = `git ls-files`.split($RS).reject do |file|
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.require_paths = ['lib']
|
34
34
|
|
35
35
|
s.add_runtime_dependency('rubocop', '~> 0.50', '>= 0.49.1')
|
36
|
-
s.add_runtime_dependency('pronto', '~> 0.
|
36
|
+
s.add_runtime_dependency('pronto', '~> 0.10.0')
|
37
37
|
s.add_development_dependency('rake', '~> 12.0')
|
38
38
|
s.add_development_dependency('rspec', '~> 3.4')
|
39
39
|
s.add_development_dependency('rspec-its', '~> 1.2')
|
metadata
CHANGED
@@ -1,49 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pronto-rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mindaugas Mozūras
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.50'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: 0.49.1
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0.50'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0.50'
|
30
27
|
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: 0.49.1
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.50'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: pronto
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.
|
39
|
+
version: 0.10.0
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
46
|
+
version: 0.10.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- LICENSE
|
98
98
|
- README.md
|
99
99
|
- lib/pronto/rubocop.rb
|
100
|
+
- lib/pronto/rubocop/patch_cop.rb
|
100
101
|
- lib/pronto/rubocop/version.rb
|
101
102
|
- pronto-rubocop.gemspec
|
102
103
|
homepage: http://github.com/mmozuras/pronto-rubocop
|
@@ -111,15 +112,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
112
|
requirements:
|
112
113
|
- - ">="
|
113
114
|
- !ruby/object:Gem::Version
|
114
|
-
version: 2.
|
115
|
+
version: 2.3.0
|
115
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
117
|
requirements:
|
117
118
|
- - ">="
|
118
119
|
- !ruby/object:Gem::Version
|
119
120
|
version: '0'
|
120
121
|
requirements: []
|
121
|
-
|
122
|
-
rubygems_version: 2.7.6
|
122
|
+
rubygems_version: 3.0.1
|
123
123
|
signing_key:
|
124
124
|
specification_version: 4
|
125
125
|
summary: Pronto runner for Rubocop, ruby code analyzer
|