Skip to content

Commit 429f400

Browse files
authored
Merge pull request rails#52654 from kamipo/fix_rubocop_offences
Fix rubocop offences for actionpack/lib/action_dispatch/journey/parser.rb
2 parents ac10452 + 98b93cd commit 429f400

File tree

3 files changed

+61
-62
lines changed

3 files changed

+61
-62
lines changed

.rubocop.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ AllCops:
1515
- '**/tmp/**/*'
1616
- '**/templates/**/*'
1717
- '**/vendor/**/*'
18-
- 'actionpack/lib/action_dispatch/journey/parser.rb'
1918
- 'actionmailbox/test/dummy/**/*'
2019
- 'activestorage/test/dummy/**/*'
2120
- 'actiontext/test/dummy/**/*'
Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# frozen_string_literal: true
12

23
require "action_dispatch/journey/scanner"
34
require "action_dispatch/journey/nodes/node"
@@ -23,81 +24,80 @@ def parse(string)
2324
end
2425

2526
private
27+
def advance_token
28+
@next_token = @scanner.next_token
29+
end
2630

27-
def advance_token
28-
@next_token = @scanner.next_token
29-
end
31+
def do_parse
32+
parse_expressions
33+
end
3034

31-
def do_parse
32-
parse_expressions
33-
end
35+
def parse_expressions
36+
node = parse_expression
37+
38+
while @next_token
39+
case @next_token
40+
when :RPAREN
41+
break
42+
when :OR
43+
node = parse_or(node)
44+
else
45+
node = Cat.new(node, parse_expressions)
46+
end
47+
end
48+
49+
node
50+
end
3451

35-
def parse_expressions
36-
node = parse_expression
52+
def parse_or(lhs)
53+
advance_token
54+
node = parse_expression
55+
Or.new([lhs, node])
56+
end
3757

38-
while @next_token
39-
case @next_token
40-
when :RPAREN
41-
break
42-
when :OR
43-
node = parse_or(node)
58+
def parse_expression
59+
if @next_token == :STAR
60+
parse_star
61+
elsif @next_token == :LPAREN
62+
parse_group
4463
else
45-
node = Cat.new(node, parse_expressions)
64+
parse_terminal
4665
end
4766
end
4867

49-
node
50-
end
51-
52-
def parse_or(lhs)
53-
advance_token
54-
node = parse_expression
55-
Or.new([lhs, node])
56-
end
68+
def parse_star
69+
node = Star.new(Symbol.new(@scanner.last_string, Symbol::GREEDY_EXP))
70+
advance_token
71+
node
72+
end
5773

58-
def parse_expression
59-
if @next_token == :STAR
60-
parse_star
61-
elsif @next_token == :LPAREN
62-
parse_group
63-
else
64-
parse_terminal
74+
def parse_group
75+
advance_token
76+
node = parse_expressions
77+
if @next_token == :RPAREN
78+
node = Group.new(node)
79+
advance_token
80+
node
81+
else
82+
raise ArgumentError, "missing right parenthesis."
83+
end
6584
end
66-
end
6785

68-
def parse_star
69-
node = Star.new(Symbol.new(@scanner.last_string, Symbol::GREEDY_EXP))
70-
advance_token
71-
node
72-
end
86+
def parse_terminal
87+
node = case @next_token
88+
when :SYMBOL
89+
Symbol.new(@scanner.last_string)
90+
when :LITERAL
91+
Literal.new(@scanner.last_literal)
92+
when :SLASH
93+
Slash.new("/")
94+
when :DOT
95+
Dot.new(".")
96+
end
7397

74-
def parse_group
75-
advance_token
76-
node = parse_expressions
77-
if @next_token == :RPAREN
78-
node = Group.new(node)
7998
advance_token
8099
node
81-
else
82-
raise ArgumentError, "missing right parenthesis."
83-
end
84-
end
85-
86-
def parse_terminal
87-
node = case @next_token
88-
when :SYMBOL
89-
Symbol.new(@scanner.last_string)
90-
when :LITERAL
91-
Literal.new(@scanner.last_literal)
92-
when :SLASH
93-
Slash.new("/")
94-
when :DOT
95-
Dot.new(".")
96100
end
97-
98-
advance_token
99-
node
100-
end
101101
end
102102
end
103103
end

guides/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The editing files for the Guides rebuild reside in `stylesrc` and use SCSS to im
1010

1111
## Building the Guides in Development
1212

13-
To generate new guides into static files, type `rake guides:generate` from inside the `guides` folder. If you make changes to the HTML or ERB, you'll need to remove the "output" directory before running this command. The master SCSS files (style.scss, highlight.scss) will compile as part of this process.
13+
To generate new guides into static files, type `rake guides:generate` from inside the `guides` folder. If you make changes to the HTML or ERB, you'll need to remove the "output" directory before running this command. The master SCSS files (style.scss, highlight.scss) will compile as part of this process.
1414

1515
## FAQ
1616

0 commit comments

Comments
 (0)