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 +4 -4
- data/.ruby-version +1 -1
- data/README.md +1 -1
- data/lib/linterbot/comment_generator.rb +12 -12
- data/lib/linterbot/pull_request_analyzer.rb +5 -3
- data/lib/linterbot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cce54b3ca86af1db3baa979278f68036d03da1a5
|
4
|
+
data.tar.gz: e3df14ecdf920e210fdb35f868db099fbc66e9b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e54bcb55cb4aeb26371740bfdd6d08623170f768bd3d1aa692cc13de8067d376c15dacc4c7726cccb6e05cc2155232f0c42736dfdc257b7e9863c25b0ba45971
|
7
|
+
data.tar.gz: 2062dbecbe6e8ea52fc148728f7974b3f4ae2596e69de932caa2f1a62ba086aecee54995e13a32816a7c69496a70bdfe4a4ae80744bab42ab75cda7288e4339d
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.
|
1
|
+
2.3.1
|
data/README.md
CHANGED
@@ -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
|
-
|
22
|
-
|
23
|
-
|
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
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
|
41
|
-
.
|
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
|
data/lib/linterbot/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|