pronto-clippy 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ae6bb9201f78c72b8ee5b34afed2543f4cb1e7d
4
- data.tar.gz: 17cc3270d9902dc7d919ad1d57ca0f36ee1116f1
3
+ metadata.gz: eaf84449187646b216960f4f3c69e10423a9c2d9
4
+ data.tar.gz: 8bea12be7b33d56368c966ad616bde00fd4ed7ec
5
5
  SHA512:
6
- metadata.gz: e5dd61df84698c401fbf337a76379c6524222d2b23f25a3945f271e72158384fa8e1c83560460ac846a36d8d1ec8cc007082564033988956e78ca25d0223a345
7
- data.tar.gz: 01d6ec4939272c6cc6e5e0c4ff212cee43b8e790e6c0ac7d069c1b90f3b441f8637150ec2229d798e5e9ad791f4891ced4325484a4a41ac3b93ee32dc13e1f4a
6
+ metadata.gz: 5a61223f255912bd437f3cb72d2395cbd77870e1818baac85aaf84b9d551e2e3e3aa3e53174fa66692bfac2c9967469ad662c1c7cbba21cb27e73e4cc9f06ef9
7
+ data.tar.gz: edfdb52c1659ca2bc092d2004fc90d2d71faa8353be6022fbd80c2b21e87255f854d23a615934468981eafe4dce997f1f40a5876c6ad21e6374fd1fd64c34f49
@@ -12,7 +12,7 @@ module Pronto
12
12
  .each_line
13
13
  .map { |json| JSON.parse(json) }
14
14
  .group_by do |entry|
15
- entry['spans'].first['file_name']
15
+ File.expand_path(entry['spans'].first['file_name'])
16
16
  end
17
17
  end
18
18
 
@@ -1,5 +1,5 @@
1
1
  module Pronto
2
2
  module Clippy
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.1.1'.freeze
4
4
  end
5
5
  end
@@ -3,32 +3,40 @@ require_relative 'clippy/wrapper'
3
3
 
4
4
  module Pronto
5
5
  class ClippyRunner < Runner
6
+ attr_reader :patches
7
+
6
8
  def run
7
9
  return [] unless @patches
8
10
 
9
- @offences = Clippy::Wrapper.new.lint
10
11
 
11
- @patches
12
+ patches
12
13
  .reject { |patch| patch.additions.zero? }
13
14
  .select { |patch| rust_file?(patch.new_file_full_path.to_s) }
14
15
  .map { |patch| inspect(patch) }
15
16
  end
16
17
 
18
+ def offences
19
+ @offences ||= Clippy::Wrapper.new.lint
20
+ end
21
+
17
22
  private
18
23
 
19
24
  def inspect(patch)
20
- @offences
25
+ offences
21
26
  .fetch(patch.new_file_full_path.to_s, [])
22
27
  .inject([]) do |arr, offence|
23
- span = offence['spans']
24
- line_start = span['line_start'].to_i
25
- line_end = span['line_end'].to_i
28
+ line = contains?(patch, offence['spans'].first)
29
+ arr << new_message(offence, line) if line
30
+ arr
31
+ end
32
+ end
26
33
 
27
- line = patch.added_lines.find do |nr|
28
- (line_start..line_end).cover?(nr)
29
- end
34
+ def contains?(patch, span)
35
+ line_start = span['line_start'].to_i
36
+ line_end = span['line_end'].to_i
30
37
 
31
- arr << new_message(offence, line) if line
38
+ patch.added_lines.find do |entry|
39
+ (line_start..line_end).cover?(entry.new_lineno)
32
40
  end
33
41
  end
34
42
 
@@ -36,7 +44,7 @@ module Pronto
36
44
  path = line.patch.delta.new_file[:path]
37
45
  Message.new(path,
38
46
  line,
39
- offence['level'],
47
+ offence['level'].to_sym,
40
48
  offence['message'],
41
49
  nil,
42
50
  self.class)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto-clippy
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
  - Łukasz Jan Niemier