pronto-standardrb 0.1.0 → 0.1.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 +4 -4
- data/README.md +9 -3
- data/lib/pronto/standardrb.rb +71 -7
- data/lib/pronto/standardrb/version.rb +1 -1
- data/pronto-standardrb.gemspec +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15be9f0ad83e1ae0d6e288bed884843ba464611a93d0cf53f261a11ba77de96b
|
4
|
+
data.tar.gz: f228a57341f34541aa9ff06e329db838dc5e8b237b48613acc41a67c55f457ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7fedd511885d1db14646a26bfe6600a31922354f42f8bdb86c20347578181ae323353968ffbb3c9c9350d6cb06a63614de53af73fc23bccfe04c21b1b4037ac
|
7
|
+
data.tar.gz: 866ba7d0ccffef82c6cde636b672e50854e20f3060c5ebd7e44cd2ddf59460562d7bc9ad61cf2596bc83283ecdc0235f91da59f9e8f203cc4dd4701277865fa4
|
data/README.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
-
#
|
1
|
+
# Attention!
|
2
|
+
|
3
|
+
TLDR: at the moment doesn't work as expected. please wait for bugfix :-)
|
4
|
+
|
5
|
+
Due to the inner workings of `pronto`, it seems it's not possible to simply subclass a runner, as I have done here. `require`ing a runner will add it to the runners list, IIUC, thus firing it. Since standard's opinionated config is quite different from rubocops standard config, you'll get inconclusive results.
|
2
6
|
|
3
|
-
|
7
|
+
I'm sorry about the premature release.
|
8
|
+
|
9
|
+
# Pronto::Standardrb
|
4
10
|
|
5
|
-
|
11
|
+
[Pronto](https://github.com/prontolabs/pronto) runner for [Standardrb](https://github.com/prontolabs/pronto)
|
6
12
|
|
7
13
|
## Installation
|
8
14
|
|
data/lib/pronto/standardrb.rb
CHANGED
@@ -1,18 +1,82 @@
|
|
1
1
|
require "pronto/standardrb/version"
|
2
2
|
require "pronto"
|
3
|
-
require "
|
3
|
+
require "rubocop"
|
4
4
|
require "pry"
|
5
5
|
require "standard"
|
6
6
|
|
7
7
|
module Pronto
|
8
|
-
class Standardrb <
|
9
|
-
def
|
10
|
-
|
8
|
+
class Standardrb < Runner
|
9
|
+
def run
|
10
|
+
ruby_patches
|
11
|
+
.select { |patch| patch.additions > 0 }
|
12
|
+
.flat_map do |patch|
|
13
|
+
offenses(patch).flat_map do |offense|
|
14
|
+
patch
|
15
|
+
.added_lines
|
16
|
+
.select { |line| line.new_lineno == offense.line }
|
17
|
+
.map { |line| new_message(offense, line) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def rubocop_config(patch)
|
23
|
+
builds_config = Standard::BuildsConfig.new
|
24
|
+
config = builds_config.call([])
|
25
|
+
|
26
|
+
@rubocop_config ||= begin
|
27
|
+
store = config.rubocop_config_store
|
28
|
+
store.for(path(patch))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
11
33
|
|
12
|
-
|
34
|
+
def processed_source(patch)
|
35
|
+
::RuboCop::ProcessedSource.from_file(
|
36
|
+
path(patch),
|
37
|
+
rubocop_config(patch).target_ruby_version
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def new_message(offense, line)
|
42
|
+
path = line.patch.delta.new_file[:path]
|
43
|
+
level = level(offense.severity.name)
|
44
|
+
Message.new(path, line, level, offense.message, nil, self.class)
|
45
|
+
end
|
46
|
+
|
47
|
+
def offenses(patch)
|
48
|
+
team(patch)
|
49
|
+
.inspect_file(processed_source(patch))
|
50
|
+
.sort
|
51
|
+
.reject(&:disabled?)
|
52
|
+
end
|
13
53
|
|
14
|
-
|
15
|
-
|
54
|
+
def path(patch)
|
55
|
+
patch.new_file_full_path.to_s
|
16
56
|
end
|
57
|
+
|
58
|
+
def team(patch)
|
59
|
+
@team ||= ::RuboCop::Cop::Team.new(registry, rubocop_config(patch))
|
60
|
+
end
|
61
|
+
|
62
|
+
def registry
|
63
|
+
@registry ||= ::RuboCop::Cop::Registry.new(RuboCop::Cop::Cop.all)
|
64
|
+
end
|
65
|
+
|
66
|
+
def level(severity)
|
67
|
+
severities.fetch(severity)
|
68
|
+
end
|
69
|
+
|
70
|
+
def severities
|
71
|
+
DEFAULT_SEVERITIES
|
72
|
+
end
|
73
|
+
|
74
|
+
DEFAULT_SEVERITIES = {
|
75
|
+
refactor: :warning,
|
76
|
+
convention: :warning,
|
77
|
+
warning: :warning,
|
78
|
+
error: :error,
|
79
|
+
fatal: :fatal
|
80
|
+
}.freeze
|
17
81
|
end
|
18
82
|
end
|
data/pronto-standardrb.gemspec
CHANGED
@@ -25,9 +25,9 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
27
|
|
28
|
-
spec.add_runtime_dependency "standard"
|
29
28
|
spec.add_runtime_dependency "pronto"
|
30
|
-
spec.add_runtime_dependency "
|
29
|
+
spec.add_runtime_dependency "rubocop"
|
30
|
+
spec.add_runtime_dependency "standard"
|
31
31
|
spec.add_development_dependency "bundler", "~> 2.0"
|
32
32
|
spec.add_development_dependency "pry"
|
33
33
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pronto-standardrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Rubisch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: pronto
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rubocop
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: standard
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|