Skip to content

Commit d2219ba

Browse files
committed
lint fixes
character class has duplicated range indentation
1 parent bbb135b commit d2219ba

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

lib/coderay/scanners/applescript.rb

+36-36
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
module CodeRay
66
module Scanners
7-
7+
88
class AppleScript < Scanner
99

1010
register_for :applescript
11-
11+
1212
RESERVED_WORDS = [
1313
'#include', 'for', 'foreach', 'if', 'elseif', 'else', 'while', 'do', 'dowhile', 'end',
1414
'switch', 'case', 'return', 'break', 'continue', 'in', 'to', 'of', 'repeat', 'tell', 'then','as'
@@ -100,9 +100,9 @@ class AppleScript < Scanner
100100
'UTC', 'valueOf', 'variable', 'version', 'Video', 'visible', 'void', 'watch', 'width',
101101
'with', 'wordwrap', 'XML', 'xmlDecl', 'XMLNode', 'XMLSocket'
102102
]
103-
103+
104104
PREDEFINED_TYPES = [
105-
'boolean', 'small integer', 'integer', 'double integer',
105+
'boolean', 'small integer', 'integer', 'double integer',
106106
'small real', 'real', 'date','list', 'record', 'string', 'class'
107107
]
108108

@@ -118,21 +118,21 @@ class AppleScript < Scanner
118118
'all caps', 'all lowercase', 'bold', 'condensed', 'expanded', 'hidden', 'italic', 'outline', 'plain', 'shadow', 'small caps', 'strikethrough', 'subscript', 'superscript', 'underline',
119119
'version'
120120
]
121-
121+
122122
PLAIN_STRING_CONTENT = {
123123
"'" => /[^'\n]+/,
124124
'"' => /[^"\n]+/,
125125
}
126-
127-
126+
127+
128128
IDENT_KIND = CaseIgnoringWordList.new(:ident).
129129
add(RESERVED_WORDS, :reserved).
130130
add(KEYWORD_OPERATOR, :operator).
131131
add(DIRECTIVES, :directive).
132132
add(PREDEFINED_TYPES, :pre_type).
133133
add(PREDEFINED_CONSTANTS, :pre_constant)
134-
135-
134+
135+
136136

137137
def scan_tokens tokens, options
138138

@@ -145,70 +145,70 @@ def scan_tokens tokens, options
145145
match = nil
146146

147147
if state == :initial
148-
148+
149149
if scan(/\s+/x)
150150
kind = :space
151-
151+
152152
elsif scan(%r! \{ \$ [^}]* \}? | \(\* \$ (?: .*? \*\) | .* ) !mx)
153153
kind = :preprocessor
154-
155-
elsif scan(/^[\s\t]*--.*/x)
154+
155+
elsif scan(/^[\s]*--.*/x)
156156
kind = :comment
157157
elsif scan(/\(\* (?: .*? \*\)$ | .* )/mx)
158158
kind = :comment
159-
159+
160160
elsif scan(/ [-+*\/=<>:;,.@\^|\(\)\[\]]+ /x)
161161
kind = :operator
162-
162+
163163
elsif match = scan(/ [A-Za-z_][A-Za-z_0-9]* /x)
164164
kind = IDENT_KIND[match]
165-
165+
166166
elsif match = scan(/ ' ( [^\n']|'' ) (?:'|$) /x)
167167
tokens << [:open, :char]
168168
tokens << ["'", :delimiter]
169169
tokens << [self[1], :content]
170170
tokens << ["'", :delimiter]
171171
tokens << [:close, :char]
172172
next
173-
173+
174174
elsif match = scan(/["']/)
175175
tokens << [:open, :string]
176176
state = :string
177177
plain_string_content = PLAIN_STRING_CONTENT[match]
178178
kind = :delimiter
179-
179+
180180
else
181181
kind = :plain
182182
getch
183183

184184
end
185-
186-
elsif state == :string
187-
if scan(plain_string_content)
188-
kind = :content
189-
elsif scan(/['"]/)
190-
tokens << [matched, :delimiter]
191-
tokens << [:close, :string]
192-
state = :initial
193-
next
194-
elsif scan(/ \\ | $ /x)
195-
tokens << [:close, :string]
196-
kind = :error
197-
state = :initial
198-
end
199185

200-
else
201-
raise_inspect "else case \" reached; %p not handled." % peek(1), tokens
186+
elsif state == :string
187+
if scan(plain_string_content)
188+
kind = :content
189+
elsif scan(/['"]/)
190+
tokens << [matched, :delimiter]
191+
tokens << [:close, :string]
192+
state = :initial
193+
next
194+
elsif scan(/ \\ | $ /x)
195+
tokens << [:close, :string]
196+
kind = :error
197+
state = :initial
202198
end
203-
199+
200+
else
201+
raise_inspect "else case \" reached; %p not handled." % peek(1), tokens
202+
end
203+
204204
match ||= matched
205205
if $DEBUG and not kind
206206
raise_inspect 'Error token %p in line %d' %
207207
[[match, kind], line], tokens
208208
end
209209
raise_inspect 'Empty token', tokens unless match
210210
tokens << [match, kind]
211-
211+
212212
end
213213
tokens
214214
end

0 commit comments

Comments
 (0)