danger-detekt-instacart 0.0.4 → 0.0.5

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
  SHA256:
3
- metadata.gz: b764046152e872ed4909383bf6ee158807244d1aef3ad6f13ab8d1d89ae50f3b
4
- data.tar.gz: 0df1e39db6cb862cc6b00d0a1ee8b2eefc8fb2f3be2cd4010f36f7ae90cd1092
3
+ metadata.gz: 121cbd9513e19e69a0d0b5a50aee136d4508d124869faec7b9609bc1c01c2fd0
4
+ data.tar.gz: '0288f83f40f8f83a6cd41a885613af2a6f693fcb0a94cf1610bf3ed838a1615c'
5
5
  SHA512:
6
- metadata.gz: 2948c60dc188f6ffa8b8b9d0f8cfae99baff98176171d9a8419cb965c6dad328b0b21ecbbadae2125559127dc630233a32cf55b6786be3c00611c0c5cd23a077
7
- data.tar.gz: f568ae43cc6f1e056aa6954af029168c70b6ddd2794dea27f0944334625ee218c69672a4c84ea25b8f378091a8c5bbabd550afba27960f786956a28e9221870f
6
+ metadata.gz: 75ea33c23366c94528d2fedfcf4380ee9fd2f230580016acc78438305b894a848198dffd7ff946264321cd9fc7be134ee47fd3139867a1cd9a3aa10a74735983
7
+ data.tar.gz: ff2f35504289856d75e772617148412ca14409573e59a7fa49fe9dc57bc8dc5cd6d98995367ad4c4470c1fabf9aad41ab56a7f888a740b73eb1c5c88926e80cc
data/Gemfile.lock CHANGED
@@ -1,27 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- danger-kotlin_detekt (0.0.3)
4
+ danger-kotlin_detekt (0.0.4)
5
5
  danger-plugin-api (~> 1.0)
6
6
  oga
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.8.0)
12
- public_suffix (>= 2.0.2, < 5.0)
11
+ addressable (2.8.1)
12
+ public_suffix (>= 2.0.2, < 6.0)
13
13
  ansi (1.5.0)
14
- ast (2.4.0)
15
- claide (1.0.3)
14
+ ast (2.4.2)
15
+ claide (1.1.0)
16
16
  claide-plugins (0.9.2)
17
17
  cork
18
18
  nap
19
19
  open4 (~> 1.3)
20
- coderay (1.1.2)
20
+ coderay (1.1.3)
21
21
  colored2 (3.1.2)
22
22
  cork (0.3.0)
23
23
  colored2 (~> 3.1)
24
- danger (8.0.4)
24
+ danger (8.6.1)
25
25
  claide (~> 1.0)
26
26
  claide-plugins (>= 0.9.2)
27
27
  colored2 (~> 3.1)
@@ -29,29 +29,51 @@ GEM
29
29
  faraday (>= 0.9.0, < 2.0)
30
30
  faraday-http-cache (~> 2.0)
31
31
  git (~> 1.7)
32
- kramdown (~> 2.0)
32
+ kramdown (~> 2.3)
33
33
  kramdown-parser-gfm (~> 1.0)
34
34
  no_proxy_fix
35
35
  octokit (~> 4.7)
36
- terminal-table (~> 1)
36
+ terminal-table (>= 1, < 4)
37
37
  danger-plugin-api (1.0.0)
38
38
  danger (> 2.0)
39
- diff-lcs (1.3)
40
- faraday (1.0.1)
41
- multipart-post (>= 1.2, < 3)
42
- faraday-http-cache (2.2.0)
39
+ diff-lcs (1.5.0)
40
+ faraday (1.10.2)
41
+ faraday-em_http (~> 1.0)
42
+ faraday-em_synchrony (~> 1.0)
43
+ faraday-excon (~> 1.1)
44
+ faraday-httpclient (~> 1.0)
45
+ faraday-multipart (~> 1.0)
46
+ faraday-net_http (~> 1.0)
47
+ faraday-net_http_persistent (~> 1.0)
48
+ faraday-patron (~> 1.0)
49
+ faraday-rack (~> 1.0)
50
+ faraday-retry (~> 1.0)
51
+ ruby2_keywords (>= 0.0.4)
52
+ faraday-em_http (1.0.0)
53
+ faraday-em_synchrony (1.0.0)
54
+ faraday-excon (1.1.0)
55
+ faraday-http-cache (2.4.1)
43
56
  faraday (>= 0.8)
44
- ffi (1.9.25)
45
- formatador (0.2.5)
46
- git (1.11.0)
57
+ faraday-httpclient (1.0.1)
58
+ faraday-multipart (1.0.4)
59
+ multipart-post (~> 2)
60
+ faraday-net_http (1.0.1)
61
+ faraday-net_http_persistent (1.2.0)
62
+ faraday-patron (1.0.0)
63
+ faraday-rack (1.0.0)
64
+ faraday-retry (1.0.3)
65
+ ffi (1.15.5)
66
+ formatador (1.1.0)
67
+ git (1.13.1)
68
+ addressable (~> 2.8)
47
69
  rchardet (~> 1.8)
48
- guard (2.14.2)
70
+ guard (2.18.0)
49
71
  formatador (>= 0.2.4)
50
72
  listen (>= 2.7, < 4.0)
51
73
  lumberjack (>= 1.0.12, < 2.0)
52
74
  nenv (~> 0.1)
53
75
  notiffany (~> 0.0)
54
- pry (>= 0.9.12)
76
+ pry (>= 0.13.0)
55
77
  shellany (~> 0.0)
56
78
  thor (>= 0.18.1)
57
79
  guard-compat (1.2.1)
@@ -59,78 +81,86 @@ GEM
59
81
  guard (~> 2.1)
60
82
  guard-compat (~> 1.1)
61
83
  rspec (>= 2.99.0, < 4.0)
62
- kramdown (2.3.1)
84
+ json (2.6.2)
85
+ kramdown (2.4.0)
63
86
  rexml
64
87
  kramdown-parser-gfm (1.1.0)
65
88
  kramdown (~> 2.0)
66
89
  listen (3.0.7)
67
90
  rb-fsevent (>= 0.9.3)
68
91
  rb-inotify (>= 0.9.7)
69
- lumberjack (1.0.13)
70
- method_source (0.9.0)
71
- multipart-post (2.1.1)
92
+ lumberjack (1.2.8)
93
+ method_source (1.0.0)
94
+ multipart-post (2.2.3)
72
95
  nap (1.1.0)
73
96
  nenv (0.3.0)
74
97
  no_proxy_fix (0.1.2)
75
- notiffany (0.1.1)
98
+ notiffany (0.1.3)
76
99
  nenv (~> 0.1)
77
100
  shellany (~> 0.0)
78
- octokit (4.18.0)
79
- faraday (>= 0.9)
80
- sawyer (~> 0.8.0, >= 0.5.3)
81
- oga (2.15)
101
+ octokit (4.25.1)
102
+ faraday (>= 1, < 3)
103
+ sawyer (~> 0.9)
104
+ oga (3.4)
82
105
  ast
83
106
  ruby-ll (~> 2.1)
84
107
  open4 (1.3.4)
85
- parallel (1.12.1)
86
- parser (2.5.1.2)
87
- ast (~> 2.4.0)
88
- powerpack (0.1.2)
89
- pry (0.11.3)
90
- coderay (~> 1.1.0)
91
- method_source (~> 0.9.0)
92
- public_suffix (4.0.6)
93
- rainbow (2.2.2)
94
- rake
95
- rake (13.0.1)
96
- rb-fsevent (0.10.3)
97
- rb-inotify (0.9.10)
98
- ffi (>= 0.5.0, < 2)
108
+ parallel (1.22.1)
109
+ parser (3.1.2.1)
110
+ ast (~> 2.4.1)
111
+ pry (0.14.1)
112
+ coderay (~> 1.1)
113
+ method_source (~> 1.0)
114
+ public_suffix (5.0.1)
115
+ rainbow (3.1.1)
116
+ rake (13.0.6)
117
+ rb-fsevent (0.11.2)
118
+ rb-inotify (0.10.1)
119
+ ffi (~> 1.0)
99
120
  rchardet (1.8.0)
100
- rexml (3.2.5)
101
- rspec (3.8.0)
102
- rspec-core (~> 3.8.0)
103
- rspec-expectations (~> 3.8.0)
104
- rspec-mocks (~> 3.8.0)
105
- rspec-core (3.8.0)
106
- rspec-support (~> 3.8.0)
107
- rspec-expectations (3.8.1)
121
+ regexp_parser (2.5.0)
122
+ rexml (3.2.8)
123
+ strscan (>= 3.0.9)
124
+ rspec (3.11.0)
125
+ rspec-core (~> 3.11.0)
126
+ rspec-expectations (~> 3.11.0)
127
+ rspec-mocks (~> 3.11.0)
128
+ rspec-core (3.11.0)
129
+ rspec-support (~> 3.11.0)
130
+ rspec-expectations (3.11.0)
108
131
  diff-lcs (>= 1.2.0, < 2.0)
109
- rspec-support (~> 3.8.0)
110
- rspec-mocks (3.8.0)
132
+ rspec-support (~> 3.11.0)
133
+ rspec-mocks (3.11.1)
111
134
  diff-lcs (>= 1.2.0, < 2.0)
112
- rspec-support (~> 3.8.0)
113
- rspec-support (3.8.0)
114
- rubocop (0.49.1)
135
+ rspec-support (~> 3.11.0)
136
+ rspec-support (3.11.0)
137
+ rubocop (1.35.1)
138
+ json (~> 2.3)
115
139
  parallel (~> 1.10)
116
- parser (>= 2.3.3.1, < 3.0)
117
- powerpack (~> 0.1)
118
- rainbow (>= 1.99.1, < 3.0)
140
+ parser (>= 3.1.2.1)
141
+ rainbow (>= 2.2.2, < 4.0)
142
+ regexp_parser (>= 1.8, < 3.0)
143
+ rexml (>= 3.2.5, < 4.0)
144
+ rubocop-ast (>= 1.20.1, < 2.0)
119
145
  ruby-progressbar (~> 1.7)
120
- unicode-display_width (~> 1.0, >= 1.0.1)
146
+ unicode-display_width (>= 1.4.0, < 3.0)
147
+ rubocop-ast (1.21.0)
148
+ parser (>= 3.1.1.0)
121
149
  ruby-ll (2.1.2)
122
150
  ansi
123
151
  ast
124
- ruby-progressbar (1.10.0)
125
- sawyer (0.8.2)
152
+ ruby-progressbar (1.11.0)
153
+ ruby2_keywords (0.0.5)
154
+ sawyer (0.9.2)
126
155
  addressable (>= 2.3.5)
127
- faraday (> 0.8, < 2.0)
156
+ faraday (>= 0.17.3, < 3)
128
157
  shellany (0.0.1)
129
- terminal-table (1.8.0)
130
- unicode-display_width (~> 1.1, >= 1.1.1)
131
- thor (0.20.0)
132
- unicode-display_width (1.7.0)
133
- yard (0.9.20)
158
+ strscan (3.1.0)
159
+ terminal-table (3.0.2)
160
+ unicode-display_width (>= 1.1.1, < 3)
161
+ thor (1.2.1)
162
+ unicode-display_width (2.2.0)
163
+ yard (0.9.36)
134
164
 
135
165
  PLATFORMS
136
166
  ruby
@@ -148,4 +178,4 @@ DEPENDENCIES
148
178
  yard
149
179
 
150
180
  BUNDLED WITH
151
- 1.16.5
181
+ 1.17.2
data/README.md CHANGED
@@ -42,6 +42,8 @@ Defaults to "Warning".
42
42
  `filtering` - Enable filtering
43
43
  Only show messages within changed files.
44
44
 
45
+ Additionally, you can further filter to only the modified lines by setting the `filtering_lines` parameter to `true`.
46
+
45
47
  `skip_gradle_task` - Skip gradle task
46
48
 
47
49
 
@@ -1,3 +1,3 @@
1
1
  module KotlinDetekt
2
- VERSION = "0.0.4".freeze
2
+ VERSION = "0.0.5".freeze
3
3
  end
@@ -55,6 +55,9 @@ module Danger
55
55
  # Skip gradle task
56
56
  attr_accessor :skip_gradle_task
57
57
 
58
+ # Only shows messages for the modified lines.
59
+ attr_accessor :filtering_lines
60
+
58
61
  # Calls Detekt task of your gradle project.
59
62
  # It fails if `gradlew` cannot be found inside current directory.
60
63
  # It fails if `severity` level is not a valid option.
@@ -138,10 +141,14 @@ module Danger
138
141
  results.each do |r|
139
142
  location = r.parent
140
143
  filename = location.get("name").gsub(dir, "")
141
- next unless !filtering || (target_files.include? filename)
142
- line = r.get("line") || "N/A"
144
+ next unless (!filtering && !filtering_lines) || (target_files.include? filename)
145
+ line = r.get("line").to_i || "N/A"
143
146
  reason = r.get("message")
144
147
  rule = r.get("source")
148
+ if filtering_lines
149
+ added_lines = parse_added_line_numbers(git.diff[filename].patch)
150
+ next unless added_lines.include? line
151
+ end
145
152
  count += 1
146
153
  message << "`#{filename}` | #{line} | #{reason} | #{rule} \n"
147
154
  end
@@ -167,11 +174,49 @@ module Danger
167
174
  filtered.each do |r|
168
175
  location = r.parent
169
176
  filename = location.get("name").gsub(dir, "")
170
- next unless !filtering || (target_files.include? filename)
177
+ next unless (!filtering && !filtering_lines) || (target_files.include? filename)
171
178
  line = (r.get("line") || "0").to_i
172
- send(level == "warning" ? "warn" : "fail", r.get("message"), file: filename, line: line)
179
+ if filtering_lines
180
+ added_lines = parse_added_line_numbers(git.diff[filename].patch)
181
+ next unless added_lines.include? line
182
+ end
183
+ reason = r.get("message")
184
+ rule = r.get("source")
185
+
186
+ message = "**Issue:** #{reason}".dup
187
+ message << "\n"
188
+ message << "**Rule:** #{rule}"
189
+ message << "\n"
190
+ message << "**File:** `#{filename}:#{line}`" # file:line for quick search
191
+
192
+ send(level == "warning" ? "warn" : "fail", message, file: filename, line: line)
193
+ end
194
+ end
195
+ end
196
+
197
+ # Parses git diff of a file and retuns an array of added line numbers.
198
+ def parse_added_line_numbers(diff)
199
+ current_line_number = nil
200
+ added_line_numbers = []
201
+ diff_lines = diff.strip.split("\n")
202
+ diff_lines.each_with_index do |line, index|
203
+ if m = /\+(\d+)(?:,\d+)? @@/.match(line)
204
+ # (e.g. @@ -32,10 +32,7 @@)
205
+ current_line_number = Integer(m[1])
206
+ else
207
+ unless current_line_number.nil?
208
+ if line.start_with?("+")
209
+ # added line
210
+ added_line_numbers.push current_line_number
211
+ current_line_number += 1
212
+ elsif !line.start_with?("-")
213
+ # unmodified line
214
+ current_line_number += 1
215
+ end
216
+ end
173
217
  end
174
218
  end
219
+ added_line_numbers
175
220
  end
176
221
 
177
222
  def gradlew_exists?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-detekt-instacart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Fesquet
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-08-24 00:00:00.000000000 Z
12
+ date: 2024-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oga
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
210
  - !ruby/object:Gem::Version
211
211
  version: '0'
212
212
  requirements: []
213
- rubygems_version: 3.3.13
213
+ rubygems_version: 3.4.10
214
214
  signing_key:
215
215
  specification_version: 4
216
216
  summary: A longer description of danger-kotlin_detekt. This is a forked version to