Skip to content

Commit cb889e0

Browse files
author
jneen
committed
add Layout/IndentationWidth and Layout/EndAlignment
1 parent 6d60f0c commit cb889e0

File tree

14 files changed

+119
-223
lines changed

14 files changed

+119
-223
lines changed

.rubocop.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ Layout/IndentationStyle:
3333
IndentationWidth: 2
3434
EnforcedStyle: spaces
3535

36+
Layout/IndentationWidth:
37+
Enabled: true
38+
39+
Layout/EndAlignment:
40+
Enabled: true
41+
EnforcedStyleAlignWith: variable
42+
3643
Metrics:
3744
Enabled: false
3845

lib/rouge/cli.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ def run
347347
formatter.format(lexer.lex(input)) { |piece| print piece }
348348
end
349349

350-
private_class_method def self.parse_cgi(str)
350+
private_class_method def self.parse_cgi(str)
351351
pairs = URI.decode_www_form(str).map { |k, v| [k.to_sym, v] }
352352
Hash[pairs]
353353
end
@@ -510,7 +510,7 @@ def run
510510
end
511511

512512

513-
private_class_method def self.normalize_syntax(argv)
513+
private_class_method def self.normalize_syntax(argv)
514514
out = []
515515
argv.each do |arg|
516516
case arg

lib/rouge/lexers/liquid.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,10 @@ class Liquid < RegexLexer
9696

9797
rule %r/(cycle)(\s+)(?:([\w-]+|'[^']*'|"[^"]*")(\s*)(:))?(\s*)/ do |m|
9898
token_class = case m[3]
99-
when %r/'[^']*'/ then Str::Single
100-
when %r/"[^"]*"/ then Str::Double
101-
else
102-
Name::Attribute
103-
end
99+
when %r/'[^']*'/ then Str::Single
100+
when %r/"[^"]*"/ then Str::Double
101+
else Name::Attribute
102+
end
104103
groups Name::Tag, Text::Whitespace, token_class,
105104
Text::Whitespace, Punctuation, Text::Whitespace
106105
push :tag_args

lib/rouge/lexers/nim.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ def self.underscorize(words)
134134
# Note: Have to do this with a block to push multiple states first,
135135
# since we can't pass array of states like w/ Pygments.
136136
rule(/[0-9][0-9_]*(?=([eE.]|'?[fF](32|64)))/) do
137-
push :floatsuffix
138-
push :floatnumber
139-
token Num::Float
137+
push :floatsuffix
138+
push :floatnumber
139+
token Num::Float
140140
end
141141

142142
rule(/0[xX][a-fA-F0-9][a-fA-F0-9_]*/, Num::Hex, :intsuffix)

lib/rouge/lexers/rego.rb

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,59 @@
22
# frozen_string_literal: true
33

44
module Rouge
5-
module Lexers
6-
class Rego < RegexLexer
7-
title "Rego"
8-
desc "The Rego open-policy-agent (OPA) policy language (openpolicyagent.org)"
9-
tag 'rego'
10-
filenames '*.rego'
11-
12-
def self.constants
13-
@constants ||= Set.new %w(
14-
true false null
15-
)
16-
end
17-
18-
def self.operators
19-
@operators ||= Set.new %w(
20-
as default else import not package some with
21-
)
22-
end
23-
24-
state :basic do
25-
rule %r/\s+/, Text
26-
rule %r/#.*/, Comment::Single
27-
28-
rule %r/[\[\](){}|.,;!]/, Punctuation
29-
30-
rule %r/"[^"]*"/, Str::Double
31-
32-
rule %r/-?\d+\.\d+([eE][+-]?\d+)?/, Num::Float
33-
rule %r/-?\d+([eE][+-]?\d+)?/, Num
34-
35-
rule %r/\\u[0-9a-fA-F]{4}/, Num::Hex
36-
rule %r/\\["\/bfnrt]/, Str::Escape
37-
end
38-
39-
state :operators do
40-
rule %r/(=|!=|>=|<=|>|<|\+|-|\*|%|\/|\||&|:=)/, Operator
41-
rule %r/[\/:?@^~]+/, Operator
42-
end
43-
44-
state :root do
45-
mixin :basic
46-
mixin :operators
47-
48-
rule %r/[[:word:]]+/ do |m|
49-
if self.class.constants.include? m[0]
50-
token Keyword::Constant
51-
elsif self.class.operators.include? m[0]
52-
token Operator::Word
53-
else
54-
token Name
55-
end
56-
end
57-
end
5+
module Lexers
6+
class Rego < RegexLexer
7+
title "Rego"
8+
desc "The Rego open-policy-agent (OPA) policy language (openpolicyagent.org)"
9+
tag 'rego'
10+
filenames '*.rego'
11+
12+
def self.constants
13+
@constants ||= Set.new %w(
14+
true false null
15+
)
16+
end
17+
18+
def self.operators
19+
@operators ||= Set.new %w(
20+
as default else import not package some with
21+
)
22+
end
23+
24+
state :basic do
25+
rule %r/\s+/, Text
26+
rule %r/#.*/, Comment::Single
27+
28+
rule %r/[\[\](){}|.,;!]/, Punctuation
29+
30+
rule %r/"[^"]*"/, Str::Double
31+
32+
rule %r/-?\d+\.\d+([eE][+-]?\d+)?/, Num::Float
33+
rule %r/-?\d+([eE][+-]?\d+)?/, Num
34+
35+
rule %r/\\u[0-9a-fA-F]{4}/, Num::Hex
36+
rule %r/\\["\/bfnrt]/, Str::Escape
37+
end
38+
39+
state :operators do
40+
rule %r/(=|!=|>=|<=|>|<|\+|-|\*|%|\/|\||&|:=)/, Operator
41+
rule %r/[\/:?@^~]+/, Operator
42+
end
43+
44+
state :root do
45+
mixin :basic
46+
mixin :operators
47+
48+
rule %r/[[:word:]]+/ do |m|
49+
if self.class.constants.include? m[0]
50+
token Keyword::Constant
51+
elsif self.class.operators.include? m[0]
52+
token Operator::Word
53+
else
54+
token Name
55+
end
5856
end
57+
end
5958
end
59+
end
6060
end

lib/rouge/lexers/robot_framework.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ def self.settings_with_args
129129
rule %r/([A-Z]+(?: [A-Z]+)?)(:?)/i do |m|
130130
match = m[1].downcase
131131
@next = if self.class.settings_with_keywords.include? match
132-
:keyword
133-
elsif self.class.settings_with_args.include? match
134-
:args
135-
end
132+
:keyword
133+
elsif self.class.settings_with_args.include? match
134+
:args
135+
end
136136
groups Name::Builtin::Pseudo, Punctuation
137137
end
138138
end

lib/rouge/lexers/swift.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class Swift < RegexLexer
156156
state :tuple do
157157
rule %r/(#{id})/, Name::Variable
158158
rule %r/(`)(#{id})(`)/ do
159-
groups Punctuation, Name::Variable, Punctuation
159+
groups Punctuation, Name::Variable, Punctuation
160160
end
161161
rule %r/,/, Punctuation
162162
rule %r/[(]/, Punctuation, :push

lib/rouge/lexers/varnish.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ def self.variables
128128

129129
# numeric literals (integer / float)
130130
rule numeric do |m|
131-
case m[0]
132-
when /^#{decimal}$/
133-
token Num::Integer
134-
when /^0x#{hex}$/
135-
token Num::Integer
136-
else
137-
token Num::Float
138-
end
131+
case m[0]
132+
when /^#{decimal}$/
133+
token Num::Integer
134+
when /^0x#{hex}$/
135+
token Num::Integer
136+
else
137+
token Num::Float
138+
end
139139
end
140140

141141
# standard strings

lib/rouge/lexers/zig.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,16 @@ def self.builtins
8484
rule %r/([.]?)(\s*)(@?#{id})(\s*)([(]?)/ do |m|
8585
name = m[3]
8686
t = if self.class.keywords.include? name
87-
Keyword
88-
elsif self.class.builtins.include? name
89-
Name::Builtin
90-
elsif !m[1].empty? && !m[5].empty?
91-
Name::Function
92-
elsif !m[1].empty?
93-
Name::Property
94-
else
95-
Name
96-
end
87+
Keyword
88+
elsif self.class.builtins.include? name
89+
Name::Builtin
90+
elsif !m[1].empty? && !m[5].empty?
91+
Name::Function
92+
elsif !m[1].empty?
93+
Name::Property
94+
else
95+
Name
96+
end
9797

9898
groups Punctuation, Text, t, Text, Punctuation
9999
end

spec/formatters/tex_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
let(:options) { { :wrap => false } }
1414

1515
let(:expected) do
16-
<<-'OUT'
17-
\begin{RG*}%
18-
\RG{n}{foo}%
19-
\end{RG*}%
20-
OUT
16+
<<~'OUT'
17+
\begin{RG*}%
18+
\RG{n}{foo}%
19+
\end{RG*}%
20+
OUT
2121
end
2222

2323
it 'renders' do

0 commit comments

Comments
 (0)