querly 0.2.1 → 0.3.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/lib/querly/cli/console.rb +5 -2
- data/lib/querly/cli/formatter.rb +6 -2
- data/lib/querly/cli.rb +5 -0
- data/lib/querly/concerns/backtrace_formatter.rb +7 -0
- data/lib/querly/pattern/parser.rb +137 -125
- data/lib/querly/pattern/parser.y +2 -1
- data/lib/querly/rule.rb +8 -1
- data/lib/querly/version.rb +1 -1
- data/lib/querly.rb +1 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 278d6249e0070a8df23463f5a87e192723582d9b
|
4
|
+
data.tar.gz: 7f25f0bec22cc8fa8dc715aaa1c151f917ddbe1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fce9e93f1b3656ab76379d105eb5812694ebd21d812d3db673bc7d62c8ca8b1ddb57adc4500cf111c9c9bd29aafd37d7cb48b827806fb4cb130bd0ca8470893
|
7
|
+
data.tar.gz: 406d47ca60ac29da0d1adae7c239e327fa71640bc713fc4cbc2fd2ef1488ba6a0154cc3619ab7c45ac1aa2b67cc75cc786efdfcd38cb056c999e73f3f44c3e2d
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.3.0
|
6
|
+
|
7
|
+
* Add `version` command
|
8
|
+
* Fix *with block* and *without block* pattern parsing
|
9
|
+
* Prettier backtrace printing
|
10
|
+
* Prettier pattern syntax error message
|
11
|
+
|
5
12
|
## 0.2.1 (2016-11-24)
|
6
13
|
|
7
14
|
* Fix `self` pattern matching
|
@@ -12,7 +19,7 @@
|
|
12
19
|
* Add `check` section to select rules to check
|
13
20
|
* Add `import` section to load rules from other file
|
14
21
|
* Add `querly rules` sub command to print loaded rules
|
15
|
-
* Add *with block* and *without block* pattern (`foo {}` / `foo !{}`)
|
22
|
+
* Add *with block* and *without block* pattern (`foo() {}` / `foo() !{}`)
|
16
23
|
* Add *some of receiver chain* pattern (`...`)
|
17
24
|
* Fix keyword args pattern matching bug
|
18
25
|
|
data/lib/querly/cli/console.rb
CHANGED
@@ -3,6 +3,8 @@ require 'readline'
|
|
3
3
|
module Querly
|
4
4
|
class CLI
|
5
5
|
class Console
|
6
|
+
include Concerns::BacktraceFormatter
|
7
|
+
|
6
8
|
attr_reader :paths
|
7
9
|
|
8
10
|
def initialize(paths:)
|
@@ -87,8 +89,9 @@ Querly #{VERSION}, interactive console
|
|
87
89
|
|
88
90
|
puts "#{count} results"
|
89
91
|
rescue => exn
|
90
|
-
STDOUT.puts exn.
|
91
|
-
STDOUT.puts
|
92
|
+
STDOUT.puts Rainbow("Error: #{exn}").red
|
93
|
+
STDOUT.puts "Backtrace:"
|
94
|
+
STDOUT.puts format_backtrace(exn.backtrace)
|
92
95
|
end
|
93
96
|
else
|
94
97
|
puts_commands
|
data/lib/querly/cli/formatter.rb
CHANGED
@@ -2,6 +2,8 @@ module Querly
|
|
2
2
|
class CLI
|
3
3
|
module Formatter
|
4
4
|
class Base
|
5
|
+
include Concerns::BacktraceFormatter
|
6
|
+
|
5
7
|
# Called when analyzer started
|
6
8
|
def start; end
|
7
9
|
|
@@ -26,7 +28,8 @@ module Querly
|
|
26
28
|
# Abort(status != 0) after the call
|
27
29
|
def fatal_error(error)
|
28
30
|
STDERR.puts Rainbow("Fatal error: #{error}").red
|
29
|
-
STDERR.puts
|
31
|
+
STDERR.puts "Backtrace:"
|
32
|
+
STDERR.puts format_backtrace(error.backtrace)
|
30
33
|
end
|
31
34
|
|
32
35
|
# Called on exit/abort
|
@@ -37,7 +40,8 @@ module Querly
|
|
37
40
|
def config_error(path, error)
|
38
41
|
STDERR.puts Rainbow("Failed to load configuration: #{path}").red
|
39
42
|
STDERR.puts error
|
40
|
-
STDERR.puts
|
43
|
+
STDERR.puts "Backtrace:"
|
44
|
+
STDERR.puts format_backtrace(error.backtrace)
|
41
45
|
end
|
42
46
|
|
43
47
|
def script_error(path, error)
|
data/lib/querly/cli.rb
CHANGED
@@ -9,7 +9,7 @@ module Querly
|
|
9
9
|
module Pattern
|
10
10
|
class Parser < Racc::Parser
|
11
11
|
|
12
|
-
module_eval(<<'...end parser.y/module_eval...', 'parser.y',
|
12
|
+
module_eval(<<'...end parser.y/module_eval...', 'parser.y', 102)
|
13
13
|
|
14
14
|
require "strscan"
|
15
15
|
|
@@ -113,116 +113,120 @@ end
|
|
113
113
|
##### State transition tables begin ###
|
114
114
|
|
115
115
|
racc_action_table = [
|
116
|
-
|
117
|
-
|
118
|
-
30, -40,
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
11, 12, 13, 14, 15, 16, 17, 30, 19, 63,
|
123
|
-
46, 48, 64, 20, 51, 52, 7, 18, 66, 77,
|
124
|
-
nil, 6, 8, 9, 10, 11, 12, 13, 14, 15,
|
125
|
-
16, 17, nil, 19, 29, nil, 7, 18, 20, 22,
|
116
|
+
-39, 29, -38, 29, 64, -39, 26, 59, -37, -38,
|
117
|
+
34, 35, 34, 35, 74, 75, 39, 61, 38, 30,
|
118
|
+
-41, 30, -40, 44, 36, 34, 35, 34, 35, 36,
|
119
|
+
34, 35, 34, 35, 34, 35, 7, 18, 20, 41,
|
120
|
+
42, 6, 8, 9, 10, 11, 12, 13, 14, 15,
|
121
|
+
16, 17, 30, 19, 46, 36, 48, 18, 20, 22,
|
126
122
|
23, 6, 8, 9, 10, 11, 12, 13, 14, 15,
|
127
|
-
16, 17,
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
123
|
+
16, 17, 73, 19, 73, 50, 52, 63, 20, 55,
|
124
|
+
56, 65, 66, 29, 29, 29, 68, 79, nil, nil,
|
125
|
+
nil, 71, 72, 71, 72, 74, 75, 74, 75, 7,
|
126
|
+
18, 30, 30, 30, 6, 8, 9, 10, 11, 12,
|
127
|
+
13, 14, 15, 16, 17, nil, 19, nil, nil, 7,
|
128
|
+
18, 20, 22, 23, 6, 8, 9, 10, 11, 12,
|
129
|
+
13, 14, 15, 16, 17, nil, 19, nil, nil, 48,
|
130
|
+
18, 20, 22, 23, 6, 8, 9, 10, 11, 12,
|
131
|
+
13, 14, 15, 16, 17, nil, 19, nil, 50, 52,
|
132
|
+
7, 20, 55, 56, nil, 6, 8, 9, 10, 11,
|
133
|
+
12, 13, 14, 15, 16, 17, nil, 19, nil, nil,
|
134
|
+
7, 18, 20, 55, 56, 6, 8, 9, 10, 11,
|
135
|
+
12, 13, 14, 15, 16, 17, nil, 19, nil, nil,
|
136
|
+
7, nil, 20, 22, 23, 6, 8, 9, 10, 11,
|
137
|
+
12, 13, 14, 15, 16, 17, nil, 19, nil, nil,
|
138
|
+
7, 18, 20, 22, 23, 6, 8, 9, 10, 11,
|
139
|
+
12, 13, 14, 15, 16, 17, nil, 19, nil, nil,
|
140
|
+
7, 18, 20, 22, 23, 6, 8, 9, 10, 11,
|
141
|
+
12, 13, 14, 15, 16, 17, nil, 19, nil, nil,
|
142
|
+
48, 18, 20, 22, 23, 6, 8, 9, 10, 11,
|
143
|
+
12, 13, 14, 15, 16, 17, 29, 19, nil, 50,
|
144
|
+
52, nil, 20, 55, 56, 29, 27, 28, nil, nil,
|
145
|
+
45, nil, nil, nil, 30, nil, nil, nil, nil, nil,
|
146
|
+
nil, nil, nil, 30 ]
|
146
147
|
|
147
148
|
racc_action_check = [
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
0, 0,
|
171
|
-
0,
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
149
|
+
56, 49, 55, 77, 53, 23, 1, 43, 21, 22,
|
150
|
+
66, 66, 79, 79, 73, 73, 25, 49, 24, 49,
|
151
|
+
56, 77, 55, 26, 56, 56, 56, 55, 55, 23,
|
152
|
+
23, 23, 43, 43, 22, 22, 71, 71, 25, 25,
|
153
|
+
25, 71, 71, 71, 71, 71, 71, 71, 71, 71,
|
154
|
+
71, 71, 31, 71, 36, 46, 61, 61, 71, 71,
|
155
|
+
71, 61, 61, 61, 61, 61, 61, 61, 61, 61,
|
156
|
+
61, 61, 63, 61, 64, 61, 61, 52, 61, 61,
|
157
|
+
61, 54, 57, 62, 80, 81, 60, 67, nil, nil,
|
158
|
+
nil, 63, 63, 64, 64, 63, 63, 64, 64, 65,
|
159
|
+
65, 62, 80, 81, 65, 65, 65, 65, 65, 65,
|
160
|
+
65, 65, 65, 65, 65, nil, 65, nil, nil, 68,
|
161
|
+
68, 65, 65, 65, 68, 68, 68, 68, 68, 68,
|
162
|
+
68, 68, 68, 68, 68, nil, 68, nil, nil, 38,
|
163
|
+
38, 68, 68, 68, 38, 38, 38, 38, 38, 38,
|
164
|
+
38, 38, 38, 38, 38, nil, 38, nil, 38, 38,
|
165
|
+
48, 38, 38, 38, nil, 48, 48, 48, 48, 48,
|
166
|
+
48, 48, 48, 48, 48, 48, nil, 48, nil, nil,
|
167
|
+
50, 50, 48, 48, 48, 50, 50, 50, 50, 50,
|
168
|
+
50, 50, 50, 50, 50, 50, nil, 50, nil, nil,
|
169
|
+
7, nil, 50, 50, 50, 7, 7, 7, 7, 7,
|
170
|
+
7, 7, 7, 7, 7, 7, nil, 7, nil, nil,
|
171
|
+
0, 0, 7, 7, 7, 0, 0, 0, 0, 0,
|
172
|
+
0, 0, 0, 0, 0, 0, nil, 0, nil, nil,
|
173
|
+
18, 18, 0, 0, 0, 18, 18, 18, 18, 18,
|
174
|
+
18, 18, 18, 18, 18, 18, nil, 18, nil, nil,
|
175
|
+
59, 59, 18, 18, 18, 59, 59, 59, 59, 59,
|
176
|
+
59, 59, 59, 59, 59, 59, 32, 59, nil, 59,
|
177
|
+
59, nil, 59, 59, 59, 3, 3, 3, nil, nil,
|
178
|
+
32, nil, nil, nil, 32, nil, nil, nil, nil, nil,
|
179
|
+
nil, nil, nil, 3 ]
|
178
180
|
|
179
181
|
racc_action_pointer = [
|
180
|
-
|
181
|
-
nil, nil, nil, nil, nil, nil, nil, nil,
|
182
|
-
nil,
|
183
|
-
nil,
|
184
|
-
nil, nil,
|
185
|
-
|
186
|
-
|
187
|
-
nil, -
|
188
|
-
nil ]
|
182
|
+
218, 6, nil, 281, nil, nil, nil, 198, nil, nil,
|
183
|
+
nil, nil, nil, nil, nil, nil, nil, nil, 238, nil,
|
184
|
+
nil, 5, 6, 2, 15, 14, 23, nil, nil, nil,
|
185
|
+
nil, 30, 272, nil, nil, nil, 28, nil, 137, nil,
|
186
|
+
nil, nil, nil, 4, nil, nil, 28, nil, 158, -3,
|
187
|
+
178, nil, 57, -16, 58, -1, -3, 64, nil, 258,
|
188
|
+
63, 54, 79, 70, 72, 97, -18, 69, 117, nil,
|
189
|
+
nil, 34, nil, -11, nil, nil, nil, -1, nil, -16,
|
190
|
+
80, 81, nil ]
|
189
191
|
|
190
192
|
racc_action_default = [
|
191
|
-
-
|
192
|
-
-11, -12, -13, -14, -15, -16, -17, -18, -
|
193
|
-
-35, -
|
194
|
-
-
|
195
|
-
|
196
|
-
-
|
197
|
-
-
|
198
|
-
-
|
199
|
-
-
|
193
|
+
-57, -57, -1, -2, -5, -6, -7, -36, -9, -10,
|
194
|
+
-11, -12, -13, -14, -15, -16, -17, -18, -57, -20,
|
195
|
+
-35, -46, -54, -42, -57, -57, -57, -3, -4, -52,
|
196
|
+
-53, -8, -57, -44, -55, -56, -57, -45, -21, -36,
|
197
|
+
-37, -38, -39, -54, 83, -19, -42, -43, -36, -22,
|
198
|
+
-57, -25, -26, -31, -57, -54, -42, -57, -48, -21,
|
199
|
+
-57, -21, -24, -28, -28, -57, -54, -57, -57, -23,
|
200
|
+
-27, -57, -30, -57, -40, -41, -32, -33, -47, -54,
|
201
|
+
-34, -29, -50 ]
|
200
202
|
|
201
203
|
racc_goto_table = [
|
202
|
-
3,
|
203
|
-
|
204
|
-
nil,
|
205
|
-
nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
206
|
-
nil, nil, nil, nil,
|
207
|
-
|
208
|
-
nil, nil, nil,
|
204
|
+
3, 37, 60, 57, 70, 76, 1, 31, 47, 40,
|
205
|
+
43, 2, nil, nil, nil, nil, nil, nil, 32, nil,
|
206
|
+
nil, 58, nil, nil, 67, nil, 69, 60, nil, nil,
|
207
|
+
nil, nil, nil, nil, 37, nil, nil, nil, nil, nil,
|
208
|
+
nil, nil, nil, nil, 78, nil, nil, nil, 31, nil,
|
209
|
+
62, nil, nil, nil, nil, nil, nil, 82, nil, nil,
|
210
|
+
nil, nil, nil, nil, nil, 77, nil, nil, 80, nil,
|
211
|
+
nil, 81 ]
|
209
212
|
|
210
213
|
racc_goto_check = [
|
211
214
|
3, 12, 9, 6, 7, 7, 1, 3, 4, 10,
|
212
215
|
11, 2, nil, nil, nil, nil, nil, nil, 3, nil,
|
213
|
-
nil,
|
214
|
-
nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
215
|
-
nil, nil, nil, nil,
|
216
|
-
|
217
|
-
nil, nil, nil,
|
216
|
+
nil, 12, nil, nil, 6, nil, 6, 9, nil, nil,
|
217
|
+
nil, nil, nil, nil, 12, nil, nil, nil, nil, nil,
|
218
|
+
nil, nil, nil, nil, 12, nil, nil, nil, 3, nil,
|
219
|
+
3, nil, nil, nil, nil, nil, nil, 12, nil, nil,
|
220
|
+
nil, nil, nil, nil, nil, 3, nil, nil, 3, nil,
|
221
|
+
nil, 3 ]
|
218
222
|
|
219
223
|
racc_goto_pointer = [
|
220
|
-
nil, 6, 11, 0, -
|
221
|
-
-16, -15, -
|
224
|
+
nil, 6, 11, 0, -28, nil, -35, -59, nil, -46,
|
225
|
+
-16, -15, -22, nil ]
|
222
226
|
|
223
227
|
racc_goto_default = [
|
224
|
-
nil, nil, nil,
|
225
|
-
21, 24,
|
228
|
+
nil, nil, nil, 49, 4, 5, nil, 51, 53, 54,
|
229
|
+
21, 24, 33, 25 ]
|
226
230
|
|
227
231
|
racc_reduce_table = [
|
228
232
|
0, 0, :racc_error,
|
@@ -269,22 +273,23 @@ racc_reduce_table = [
|
|
269
273
|
1, 39, :_reduce_none,
|
270
274
|
1, 34, :_reduce_42,
|
271
275
|
3, 34, :_reduce_43,
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
+
2, 35, :_reduce_44,
|
277
|
+
2, 35, :_reduce_45,
|
278
|
+
1, 35, :_reduce_46,
|
279
|
+
5, 35, :_reduce_47,
|
276
280
|
3, 35, :_reduce_48,
|
277
|
-
|
281
|
+
3, 35, :_reduce_49,
|
278
282
|
6, 35, :_reduce_50,
|
279
|
-
|
283
|
+
6, 35, :_reduce_51,
|
280
284
|
2, 43, :_reduce_52,
|
281
|
-
|
282
|
-
|
283
|
-
1, 42, :_reduce_55
|
285
|
+
2, 43, :_reduce_53,
|
286
|
+
0, 42, :_reduce_54,
|
287
|
+
1, 42, :_reduce_55,
|
288
|
+
1, 42, :_reduce_56 ]
|
284
289
|
|
285
|
-
racc_reduce_n =
|
290
|
+
racc_reduce_n = 57
|
286
291
|
|
287
|
-
racc_shift_n =
|
292
|
+
racc_shift_n = 83
|
288
293
|
|
289
294
|
racc_token_table = {
|
290
295
|
false => 0,
|
@@ -649,20 +654,27 @@ module_eval(<<'.,.,', 'parser.y', 65)
|
|
649
654
|
|
650
655
|
module_eval(<<'.,.,', 'parser.y', 67)
|
651
656
|
def _reduce_44(val, _values, result)
|
652
|
-
result = Expr::Vcall.new(name: val[0])
|
657
|
+
result = val[1] != nil ? Expr::Send.new(receiver: Expr::Any.new, name: val[0], args: Argument::AnySeq.new, block: val[1]) : Expr::Vcall.new(name: val[0])
|
653
658
|
result
|
654
659
|
end
|
655
660
|
.,.,
|
656
661
|
|
657
662
|
module_eval(<<'.,.,', 'parser.y', 68)
|
658
663
|
def _reduce_45(val, _values, result)
|
659
|
-
result = Expr::Send.new(receiver: Expr::Any.new, name: val[0], block:
|
664
|
+
result = Expr::Send.new(receiver: Expr::Any.new, name: val[0], block: val[1])
|
660
665
|
result
|
661
666
|
end
|
662
667
|
.,.,
|
663
668
|
|
664
669
|
module_eval(<<'.,.,', 'parser.y', 69)
|
665
670
|
def _reduce_46(val, _values, result)
|
671
|
+
result = Expr::Send.new(receiver: Expr::Any.new, name: val[0], block: nil)
|
672
|
+
result
|
673
|
+
end
|
674
|
+
.,.,
|
675
|
+
|
676
|
+
module_eval(<<'.,.,', 'parser.y', 70)
|
677
|
+
def _reduce_47(val, _values, result)
|
666
678
|
result = Expr::Send.new(receiver: Expr::Any.new,
|
667
679
|
name: val[0],
|
668
680
|
args: val[2],
|
@@ -671,8 +683,8 @@ module_eval(<<'.,.,', 'parser.y', 69)
|
|
671
683
|
end
|
672
684
|
.,.,
|
673
685
|
|
674
|
-
module_eval(<<'.,.,', 'parser.y',
|
675
|
-
def
|
686
|
+
module_eval(<<'.,.,', 'parser.y', 74)
|
687
|
+
def _reduce_48(val, _values, result)
|
676
688
|
result = Expr::Send.new(receiver: val[0],
|
677
689
|
name: val[1],
|
678
690
|
args: Argument::AnySeq.new,
|
@@ -681,8 +693,8 @@ module_eval(<<'.,.,', 'parser.y', 73)
|
|
681
693
|
end
|
682
694
|
.,.,
|
683
695
|
|
684
|
-
module_eval(<<'.,.,', 'parser.y',
|
685
|
-
def
|
696
|
+
module_eval(<<'.,.,', 'parser.y', 78)
|
697
|
+
def _reduce_49(val, _values, result)
|
686
698
|
result = Expr::Send.new(receiver: val[0],
|
687
699
|
name: val[1],
|
688
700
|
args: Argument::AnySeq.new,
|
@@ -691,8 +703,8 @@ module_eval(<<'.,.,', 'parser.y', 77)
|
|
691
703
|
end
|
692
704
|
.,.,
|
693
705
|
|
694
|
-
module_eval(<<'.,.,', 'parser.y',
|
695
|
-
def
|
706
|
+
module_eval(<<'.,.,', 'parser.y', 82)
|
707
|
+
def _reduce_50(val, _values, result)
|
696
708
|
result = Expr::Send.new(receiver: val[0],
|
697
709
|
name: val[1],
|
698
710
|
args: val[3],
|
@@ -701,8 +713,8 @@ module_eval(<<'.,.,', 'parser.y', 81)
|
|
701
713
|
end
|
702
714
|
.,.,
|
703
715
|
|
704
|
-
module_eval(<<'.,.,', 'parser.y',
|
705
|
-
def
|
716
|
+
module_eval(<<'.,.,', 'parser.y', 86)
|
717
|
+
def _reduce_51(val, _values, result)
|
706
718
|
result = Expr::Send.new(receiver: val[0],
|
707
719
|
name: val[1],
|
708
720
|
args: val[3],
|
@@ -711,36 +723,36 @@ module_eval(<<'.,.,', 'parser.y', 85)
|
|
711
723
|
end
|
712
724
|
.,.,
|
713
725
|
|
714
|
-
module_eval(<<'.,.,', 'parser.y',
|
715
|
-
def
|
726
|
+
module_eval(<<'.,.,', 'parser.y', 91)
|
727
|
+
def _reduce_52(val, _values, result)
|
716
728
|
result = val[0]
|
717
729
|
result
|
718
730
|
end
|
719
731
|
.,.,
|
720
732
|
|
721
|
-
module_eval(<<'.,.,', 'parser.y',
|
722
|
-
def
|
733
|
+
module_eval(<<'.,.,', 'parser.y', 92)
|
734
|
+
def _reduce_53(val, _values, result)
|
723
735
|
result = Expr::ReceiverContext.new(receiver: val[0])
|
724
736
|
result
|
725
737
|
end
|
726
738
|
.,.,
|
727
739
|
|
728
|
-
module_eval(<<'.,.,', 'parser.y',
|
729
|
-
def
|
740
|
+
module_eval(<<'.,.,', 'parser.y', 94)
|
741
|
+
def _reduce_54(val, _values, result)
|
730
742
|
result = nil
|
731
743
|
result
|
732
744
|
end
|
733
745
|
.,.,
|
734
746
|
|
735
|
-
module_eval(<<'.,.,', 'parser.y',
|
736
|
-
def
|
747
|
+
module_eval(<<'.,.,', 'parser.y', 95)
|
748
|
+
def _reduce_55(val, _values, result)
|
737
749
|
result = true
|
738
750
|
result
|
739
751
|
end
|
740
752
|
.,.,
|
741
753
|
|
742
|
-
module_eval(<<'.,.,', 'parser.y',
|
743
|
-
def
|
754
|
+
module_eval(<<'.,.,', 'parser.y', 96)
|
755
|
+
def _reduce_56(val, _values, result)
|
744
756
|
result = false
|
745
757
|
result
|
746
758
|
end
|
data/lib/querly/pattern/parser.y
CHANGED
@@ -65,7 +65,8 @@ keyword: LIDENT | UIDENT
|
|
65
65
|
constant: UIDENT { result = [val[0]] }
|
66
66
|
| UIDENT COLONCOLON constant { result = [val[0]] + val[2] }
|
67
67
|
|
68
|
-
send: LIDENT { result = Expr::Vcall.new(name: val[0]) }
|
68
|
+
send: LIDENT block { result = val[1] != nil ? Expr::Send.new(receiver: Expr::Any.new, name: val[0], args: Argument::AnySeq.new, block: val[1]) : Expr::Vcall.new(name: val[0]) }
|
69
|
+
| UIDENT block { result = Expr::Send.new(receiver: Expr::Any.new, name: val[0], block: val[1]) }
|
69
70
|
| method_name { result = Expr::Send.new(receiver: Expr::Any.new, name: val[0], block: nil) }
|
70
71
|
| method_name_or_ident LPAREN args RPAREN block { result = Expr::Send.new(receiver: Expr::Any.new,
|
71
72
|
name: val[0],
|
data/lib/querly/rule.rb
CHANGED
@@ -38,6 +38,7 @@ module Querly
|
|
38
38
|
end
|
39
39
|
|
40
40
|
class InvalidRuleHashError < StandardError; end
|
41
|
+
class PatternSyntaxError < StandardError; end
|
41
42
|
|
42
43
|
def self.load(hash)
|
43
44
|
id = hash["id"]
|
@@ -45,7 +46,13 @@ module Querly
|
|
45
46
|
|
46
47
|
srcs = Array(hash["pattern"])
|
47
48
|
raise InvalidRuleHashError, "pattern is missing" if srcs.empty?
|
48
|
-
patterns = srcs.map
|
49
|
+
patterns = srcs.map.with_index do |src, index|
|
50
|
+
begin
|
51
|
+
Pattern::Parser.parse(src)
|
52
|
+
rescue Racc::ParseError => exn
|
53
|
+
raise PatternSyntaxError, "Pattern syntax error: rule=#{hash["id"]}, index=#{index}, pattern=#{Rainbow(src.split("\n").first).blue}: #{exn}"
|
54
|
+
end
|
55
|
+
end
|
49
56
|
|
50
57
|
messages = Array(hash["message"])
|
51
58
|
raise InvalidRuleHashError, "message is missing" if messages.empty?
|
data/lib/querly/version.rb
CHANGED
data/lib/querly.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: querly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0.beta.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Soutaro Matsumoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- lib/querly/cli/formatter.rb
|
152
152
|
- lib/querly/cli/rules.rb
|
153
153
|
- lib/querly/cli/test.rb
|
154
|
+
- lib/querly/concerns/backtrace_formatter.rb
|
154
155
|
- lib/querly/config.rb
|
155
156
|
- lib/querly/node_pair.rb
|
156
157
|
- lib/querly/pattern/argument.rb
|
@@ -180,12 +181,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
181
|
version: '0'
|
181
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
183
|
requirements:
|
183
|
-
- - "
|
184
|
+
- - ">"
|
184
185
|
- !ruby/object:Gem::Version
|
185
|
-
version:
|
186
|
+
version: 1.3.1
|
186
187
|
requirements: []
|
187
188
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
189
|
+
rubygems_version: 2.6.8
|
189
190
|
signing_key:
|
190
191
|
specification_version: 4
|
191
192
|
summary: Pattern Based Checking Tool for Ruby
|