pronto-standardrb 0.1.0 → 0.1.1

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: e4e4b4304698c68c845e872a1984761ff26e1629e46630bce79ab54543559975
4
- data.tar.gz: 0ddfeae532c9be9482c23942a94a4304daddf1d9781c8a3c73f854f34266a6bf
3
+ metadata.gz: 15be9f0ad83e1ae0d6e288bed884843ba464611a93d0cf53f261a11ba77de96b
4
+ data.tar.gz: f228a57341f34541aa9ff06e329db838dc5e8b237b48613acc41a67c55f457ac
5
5
  SHA512:
6
- metadata.gz: c2fa0f6b4bff7d31bf3dc1569f1157c4481c70b46a6a5fb2d0211cbe8a8a31841edc00b8a06953c6c1a8f5a87c9f7b3ab0acea1a15473468c6c87be625e63119
7
- data.tar.gz: 7c468cbfd6e552dd618ef939f2da8003db8dbf1764e3246ee2dabf1b0c78949ccee09932b8848603643e0553e4a37964aa63f37df1c3c576bb9612734e18f3dd
6
+ metadata.gz: d7fedd511885d1db14646a26bfe6600a31922354f42f8bdb86c20347578181ae323353968ffbb3c9c9350d6cb06a63614de53af73fc23bccfe04c21b1b4037ac
7
+ data.tar.gz: 866ba7d0ccffef82c6cde636b672e50854e20f3060c5ebd7e44cd2ddf59460562d7bc9ad61cf2596bc83283ecdc0235f91da59f9e8f203cc4dd4701277865fa4
data/README.md CHANGED
@@ -1,8 +1,14 @@
1
- # Pronto::Standardrb
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
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pronto/standardrb`. To experiment with that code, run `bin/console` for an interactive prompt.
7
+ I'm sorry about the premature release.
8
+
9
+ # Pronto::Standardrb
4
10
 
5
- TODO: Delete this and the text above, and describe your gem
11
+ [Pronto](https://github.com/prontolabs/pronto) runner for [Standardrb](https://github.com/prontolabs/pronto)
6
12
 
7
13
  ## Installation
8
14
 
@@ -1,18 +1,82 @@
1
1
  require "pronto/standardrb/version"
2
2
  require "pronto"
3
- require "pronto/rubocop"
3
+ require "rubocop"
4
4
  require "pry"
5
5
  require "standard"
6
6
 
7
7
  module Pronto
8
- class Standardrb < Rubocop
9
- def initialize(patches, _ = nil)
10
- super(patches)
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
- @builds_config = Standard::BuildsConfig.new
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
- config = @builds_config.call([])
15
- @inspector = ::RuboCop::Runner.new(config.rubocop_options, @config_store)
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
@@ -1,5 +1,5 @@
1
1
  module Pronto
2
2
  module StandardrbVersion
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
@@ -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 "pronto-rubocop"
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.0
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-13 00:00:00.000000000 Z
11
+ date: 2019-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: standard
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: pronto
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: pronto-rubocop
42
+ name: standard
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="