checkstyle_filter-git 1.0.1 → 1.0.2

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: e18bdb52a8261ab9b0dbbf4aef9c8e1e2d98e26d
4
- data.tar.gz: b45931a545437dba683f7aabb1ca4a05765f26ae
3
+ metadata.gz: 48c2ee1c9b3596966f7f0ea3213e6f18aec1dbf4
4
+ data.tar.gz: a4848b617efeed1117ca57791c78a69c1bb23468
5
5
  SHA512:
6
- metadata.gz: ba59856e2db9f7a5256bdcbbfa2d02412281059546a0c2259b63f562e7780c9a9d71246cf61d5145d5f45feba2d368bc01479d632a7aec088ddf86f422d84279
7
- data.tar.gz: 0bf2d14735b346bec69c132dde49ee328ec2f67795c449107a5178da3e0e1bdba9734a8a35aa7756323a981a8c88b6155eec3fa95db1e264f70dc7468f3ddaf3
6
+ metadata.gz: 51445acca2a43ef41b9cdf4ea65e0df762f2034f69519ee9e8bf5041a13b0148fdce53f16e17910d927ccfca4e957ddf3d2293908fbdb1290af806e70c24f443
7
+ data.tar.gz: a3e6c37e3bda2c783cdfb81f8f1c4669b3f7d4d62b23e83dc9ea1fff86b9963d857a291f25046f447913aa042632181fad648f5589635f379cb5e257c052da7c
@@ -10,10 +10,12 @@ module CheckstyleFilter
10
10
  document = REXML::Document.new data
11
11
  document.elements.each('/checkstyle/file') do |file_element|
12
12
  file_name = file_element.attribute('name') && file_element.attribute('name').value
13
- if file_in_patches?(file_name, patches)
13
+ file = file_relative_path_string(file_name)
14
+ patch = patches.find_patch_by_file(file)
15
+ if patch
14
16
  file_element.elements.each('error') do |error_element|
15
17
  line = error_element.attribute('line') && error_element.attribute('line').value.to_i
16
- unless file_element_error_line_no_in_patches?(file_name, patches, line)
18
+ unless patch.changed_line_numbers.include?(line)
17
19
  error_element.remove
18
20
  end
19
21
  end
@@ -27,30 +29,12 @@ module CheckstyleFilter
27
29
  document.to_s
28
30
  end
29
31
 
30
- def self.file_in_patches?(file_name, patches)
31
- patches
32
- .map(&:file)
33
- .map { |file| Pathname.new(file).expand_path }
34
- .include?(Pathname.new(file_name).expand_path)
35
- end
36
-
37
- def self.file_element_error_line_no_in_patches?(file_name, patches, line_no)
38
- diff_patches = patches
39
- .select { |patch| same_file?(patch.file, file_name) }
40
- return false if diff_patches.empty?
41
-
42
- modified_lines = Set.new
43
- diff_patches.map do |patch|
44
- patch.changed_lines.map do |line|
45
- modified_lines << line.number
46
- end
32
+ def self.file_relative_path_string(file_name)
33
+ if Pathname.new(file_name).absolute?
34
+ Pathname.new(file_name).relative_path_from(Pathname.new(Dir.pwd)).to_s
35
+ else
36
+ Pathname.new(file_name).relative_path_from(Pathname.new('.')).to_s
47
37
  end
48
-
49
- modified_lines.include?(line_no)
50
- end
51
-
52
- def self.same_file?(one, other)
53
- Pathname.new(one).expand_path == Pathname.new(other).expand_path
54
38
  end
55
39
  end
56
40
  end
@@ -1,5 +1,5 @@
1
1
  module CheckstyleFilter
2
2
  module Git
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checkstyle_filter-git
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - sanemat
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-02-22 00:00:00.000000000 Z
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor