linterbot 0.2.5 → 0.2.6

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: e0855f6f991d806deaac1e48b543f4e1e6d5bc2d
4
- data.tar.gz: ea8df8218f21898b019d54ee266ec766f040daf7
3
+ metadata.gz: cce54b3ca86af1db3baa979278f68036d03da1a5
4
+ data.tar.gz: e3df14ecdf920e210fdb35f868db099fbc66e9b9
5
5
  SHA512:
6
- metadata.gz: 57f8c014d89d3a9db300779eb9b9a6544ec9313a2de978fbbd6cd2c9adc126a27e953f428fd0f6be474a237f63fcac18e45be5feff56d39b7ffba49717b94b0e
7
- data.tar.gz: bae55d188438380ded222c10a3ebf88c291ad492b6586bd92da74c0d2609f0843954037f05b8e058ffbb9e5816506b81a6530a19167fa2973c96c7b908573d57
6
+ metadata.gz: e54bcb55cb4aeb26371740bfdd6d08623170f768bd3d1aa692cc13de8067d376c15dacc4c7726cccb6e05cc2155232f0c42736dfdc257b7e9863c25b0ba45971
7
+ data.tar.gz: 2062dbecbe6e8ea52fc148728f7974b3f4ae2596e69de932caa2f1a62ba086aecee54995e13a32816a7c69496a70bdfe4a4ae80744bab42ab75cda7288e4339d
@@ -1 +1 @@
1
- 2.3.0
1
+ 2.3.1
data/README.md CHANGED
@@ -29,7 +29,7 @@ Or install it yourself as:
29
29
  If you want to try it locally:
30
30
 
31
31
  ```
32
- swiftlint --reporter json | linterbot REPOSITORY PULL_REQUEST_NUMBER
32
+ swiftlint lint --reporter json | linterbot REPOSITORY PULL_REQUEST_NUMBER
33
33
  ```
34
34
 
35
35
  ### TravisCI
@@ -5,11 +5,13 @@ module Linterbot
5
5
  attr_accessor :filename
6
6
  attr_accessor :commit
7
7
  attr_accessor :pull_request_file_patch
8
+ attr_accessor :commits_count_for_file
8
9
 
9
- def initialize(filename, commit, pull_request_file_patch)
10
+ def initialize(filename, commit, pull_request_file_patch, commits_count_for_file)
10
11
  @filename = filename
11
12
  @commit = commit
12
13
  @pull_request_file_patch = Patch.new(pull_request_file_patch)
14
+ @commits_count_for_file = commits_count_for_file
13
15
  end
14
16
 
15
17
  def generate_comments(hints)
@@ -18,10 +20,9 @@ module Linterbot
18
20
  end
19
21
 
20
22
  def generate_comment_for_hint(hint)
21
- if new_file?
22
- generate_comment_for_new_file_and_hint(hint)
23
- elsif modified_file? && included_in_file_patch?(hint)
24
- generate_comment_for_modified_file_and_hint(hint)
23
+ patch_line_number = comment_position_for_hint(hint)
24
+ if patch_line_number
25
+ Comment.new(sha: commit.sha, patch_line_number: patch_line_number, hint: hint)
25
26
  end
26
27
  end
27
28
 
@@ -59,13 +60,12 @@ module Linterbot
59
60
  .first
60
61
  end
61
62
 
62
- def generate_comment_for_modified_file_and_hint(hint)
63
- patch_line_number = pull_request_file_patch_line_number(hint)
64
- Comment.new(sha: commit.sha, patch_line_number: patch_line_number, hint: hint)
65
- end
66
-
67
- def generate_comment_for_new_file_and_hint(hint)
68
- Comment.new(sha: commit.sha, patch_line_number: hint.line, hint: hint)
63
+ def comment_position_for_hint(hint)
64
+ if new_file? && commits_count_for_file == 1
65
+ hint.line
66
+ elsif modified_file? && included_in_file_patch?(hint)
67
+ pull_request_file_patch_line_number(hint)
68
+ end
69
69
  end
70
70
 
71
71
  end
@@ -36,9 +36,11 @@ module Linterbot
36
36
 
37
37
  def generate_comments(filename, hints)
38
38
  pull_request_file_patch = pull_request.patch_for_file(filename)
39
- pull_request.commits_for_file(filename)
40
- .map { |commit| CommentGenerator.new(filename, commit, pull_request_file_patch).generate_comments(hints) }
41
- .flatten
39
+ commits = pull_request.commits_for_file(filename)
40
+ commits.map do |commit|
41
+ CommentGenerator.new(filename, commit, pull_request_file_patch, commits.length)
42
+ .generate_comments(hints)
43
+ end.flatten
42
44
  end
43
45
 
44
46
  end
@@ -1,3 +1,3 @@
1
1
  module Linterbot
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linterbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guido Marucci Blas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-26 00:00:00.000000000 Z
11
+ date: 2016-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler