tailor 0.1.5 → 1.0.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -1
- data/.rspec +2 -1
- data/.tailor +6 -0
- data/Gemfile.lock +47 -78
- data/{ChangeLog.rdoc → History.rdoc} +0 -0
- data/README.rdoc +157 -24
- data/Rakefile +0 -9
- data/bin/tailor +16 -69
- data/features/configurable.feature +78 -0
- data/features/horizontal_spacing.feature +262 -0
- data/features/indentation.feature +17 -21
- data/features/indentation/bad_files_with_no_trailing_newline.feature +90 -0
- data/features/indentation/good_files_with_no_trailing_newline.feature +206 -0
- data/features/name_detection.feature +72 -0
- data/features/step_definitions/indentation_steps.rb +10 -133
- data/features/support/env.rb +7 -15
- data/features/support/file_cases/horizontal_spacing_cases.rb +265 -0
- data/features/support/file_cases/indentation_cases.rb +972 -0
- data/features/support/file_cases/naming_cases.rb +52 -0
- data/features/support/file_cases/vertical_spacing_cases.rb +70 -0
- data/features/support/hooks.rb +8 -0
- data/features/support/{1_file_with_bad_operator_spacing → legacy}/bad_op_spacing.rb +0 -0
- data/features/support/{1_file_with_bad_ternary_colon_spacing → legacy}/bad_ternary_colon_spacing.rb +0 -0
- data/features/support/{1_long_file_with_indentation/my_project.rb → legacy/long_file_with_indentation.rb} +1 -1
- data/features/support/world.rb +14 -0
- data/features/vertical_spacing.feature +114 -0
- data/lib/ext/string_ext.rb +5 -0
- data/lib/tailor.rb +6 -252
- data/lib/tailor/cli.rb +49 -0
- data/lib/tailor/cli/options.rb +251 -0
- data/lib/tailor/composite_observable.rb +56 -0
- data/lib/tailor/configuration.rb +263 -0
- data/lib/tailor/critic.rb +162 -0
- data/lib/tailor/formatters/text.rb +126 -0
- data/lib/tailor/lexed_line.rb +246 -0
- data/lib/tailor/lexer.rb +428 -0
- data/lib/tailor/lexer/token.rb +103 -0
- data/lib/tailor/lexer_constants.rb +75 -0
- data/lib/tailor/logger.rb +28 -0
- data/lib/tailor/problem.rb +100 -0
- data/lib/tailor/reporter.rb +48 -0
- data/lib/tailor/ruler.rb +39 -0
- data/lib/tailor/rulers.rb +7 -0
- data/lib/tailor/rulers/allow_camel_case_methods_ruler.rb +30 -0
- data/lib/tailor/rulers/allow_hard_tabs_ruler.rb +22 -0
- data/lib/tailor/rulers/allow_screaming_snake_case_classes_ruler.rb +32 -0
- data/lib/tailor/rulers/allow_trailing_line_spaces_ruler.rb +33 -0
- data/lib/tailor/rulers/indentation_spaces_ruler.rb +199 -0
- data/lib/tailor/rulers/indentation_spaces_ruler/indentation_manager.rb +362 -0
- data/lib/tailor/rulers/max_code_lines_in_class_ruler.rb +84 -0
- data/lib/tailor/rulers/max_code_lines_in_method_ruler.rb +84 -0
- data/lib/tailor/rulers/max_line_length_ruler.rb +31 -0
- data/lib/tailor/rulers/spaces_after_comma_ruler.rb +83 -0
- data/lib/tailor/rulers/spaces_after_lbrace_ruler.rb +114 -0
- data/lib/tailor/rulers/spaces_after_lbracket_ruler.rb +123 -0
- data/lib/tailor/rulers/spaces_after_lparen_ruler.rb +116 -0
- data/lib/tailor/rulers/spaces_before_comma_ruler.rb +67 -0
- data/lib/tailor/rulers/spaces_before_lbrace_ruler.rb +93 -0
- data/lib/tailor/rulers/spaces_before_rbrace_ruler.rb +98 -0
- data/lib/tailor/rulers/spaces_before_rbracket_ruler.rb +70 -0
- data/lib/tailor/rulers/spaces_before_rparen_ruler.rb +70 -0
- data/lib/tailor/rulers/spaces_in_empty_braces_ruler.rb +94 -0
- data/lib/tailor/rulers/trailing_newlines_ruler.rb +36 -0
- data/lib/tailor/runtime_error.rb +3 -0
- data/lib/tailor/tailorrc.erb +88 -0
- data/lib/tailor/version.rb +2 -2
- data/spec/spec_helper.rb +7 -5
- data/spec/tailor/cli_spec.rb +94 -0
- data/spec/tailor/configuration_spec.rb +147 -0
- data/spec/tailor/critic_spec.rb +63 -0
- data/spec/tailor/lexed_line_spec.rb +569 -0
- data/spec/tailor/lexer/token_spec.rb +46 -0
- data/spec/tailor/lexer_spec.rb +181 -0
- data/spec/tailor/options_spec.rb +6 -0
- data/spec/tailor/problem_spec.rb +74 -0
- data/spec/tailor/reporter_spec.rb +53 -0
- data/spec/tailor/ruler_spec.rb +56 -0
- data/spec/tailor/rulers/indentation_spaces_ruler/indentation_manager_spec.rb +454 -0
- data/spec/tailor/rulers/indentation_spaces_ruler_spec.rb +128 -0
- data/spec/tailor/rulers/spaces_after_comma_spec.rb +31 -0
- data/spec/tailor/rulers/spaces_after_lbrace_ruler_spec.rb +145 -0
- data/spec/tailor/rulers/spaces_before_lbrace_ruler_spec.rb +63 -0
- data/spec/tailor/rulers/spaces_before_rbrace_ruler_spec.rb +63 -0
- data/spec/tailor/rulers_spec.rb +9 -0
- data/spec/tailor/version_spec.rb +6 -0
- data/spec/tailor_spec.rb +9 -21
- data/tailor.gemspec +22 -35
- data/tasks/features.rake +7 -0
- data/tasks/roodi.rake +9 -0
- data/tasks/roodi_config.yaml +14 -0
- data/tasks/spec.rake +16 -0
- data/tasks/yard.rake +14 -0
- metadata +224 -77
- data/features/case_checking.feature +0 -38
- data/features/spacing.feature +0 -97
- data/features/spacing/commas.feature +0 -44
- data/features/step_definitions/case_checking_steps.rb +0 -42
- data/features/step_definitions/spacing_steps.rb +0 -156
- data/features/support/1_file_with_bad_comma_spacing/bad_comma_spacing.rb +0 -43
- data/features/support/1_file_with_bad_curly_brace_spacing/bad_curly_brace_spacing.rb +0 -60
- data/features/support/1_file_with_bad_parenthesis/bad_parenthesis.rb +0 -4
- data/features/support/1_file_with_bad_square_brackets/bad_square_brackets.rb +0 -62
- data/features/support/1_file_with_camel_case_class/camel_case_class.rb +0 -5
- data/features/support/1_file_with_camel_case_method/camel_case_method.rb +0 -3
- data/features/support/1_file_with_hard_tabs/hard_tab.rb +0 -3
- data/features/support/1_file_with_long_lines/long_lines.rb +0 -5
- data/features/support/1_file_with_snake_case_class/snake_case_class.rb +0 -5
- data/features/support/1_file_with_snake_case_method/snake_case_method.rb +0 -3
- data/features/support/1_file_with_trailing_whitespace/trailing_whitespace.rb +0 -5
- data/features/support/1_good_simple_file/simple_project.rb +0 -5
- data/features/support/common.rb +0 -102
- data/features/support/matchers.rb +0 -11
- data/lib/tailor/file_line.rb +0 -220
- data/lib/tailor/indentation.rb +0 -245
- data/lib/tailor/spacing.rb +0 -237
- data/spec/file_line_spec.rb +0 -70
- data/spec/indentation_spec.rb +0 -259
- data/spec/spacing/colon_spacing_spec.rb +0 -71
- data/spec/spacing/comma_spacing_spec.rb +0 -159
- data/spec/spacing/curly_brace_spacing_spec.rb +0 -257
- data/spec/spacing/parentheses_spacing_spec.rb +0 -28
- data/spec/spacing/square_bracket_spacing_spec.rb +0 -116
- data/spec/spacing_spec.rb +0 -167
- data/tasks/metrics.rake +0 -23
@@ -0,0 +1,265 @@
|
|
1
|
+
H_SPACING_OK = {}
|
2
|
+
H_SPACING_1 = {}
|
3
|
+
H_SPACING_2 = {}
|
4
|
+
|
5
|
+
H_SPACING_OK[:short_line_no_newline] = %Q{'#{'#' * 78}'}
|
6
|
+
H_SPACING_OK[:short_line_newline_at_81] =
|
7
|
+
%Q{'#{'#' * 78}'
|
8
|
+
}
|
9
|
+
|
10
|
+
#-------------------------------------------------------------------------------
|
11
|
+
# Hard tabs
|
12
|
+
#-------------------------------------------------------------------------------
|
13
|
+
H_SPACING_1[:hard_tab] =
|
14
|
+
%Q{def something
|
15
|
+
\tputs "something"
|
16
|
+
end}
|
17
|
+
|
18
|
+
H_SPACING_1[:hard_tab_with_spaces] =
|
19
|
+
%Q{class Thing
|
20
|
+
def something
|
21
|
+
\t puts "something"
|
22
|
+
end
|
23
|
+
end}
|
24
|
+
|
25
|
+
# This only reports the hard tab problem (and not the indentation problem)
|
26
|
+
# because a hard tab is counted as 1 space; here, this is 4 spaces, so it
|
27
|
+
# looks correct to the parser. I'm leaving this behavior, as detecting the
|
28
|
+
# hard tab should signal the problem. If you fix the hard tab and don't
|
29
|
+
# fix indentation, tailor will flag you on the indentation on the next run.
|
30
|
+
H_SPACING_1[:hard_tab_with_1_indented_space] =
|
31
|
+
%Q{class Thing
|
32
|
+
def something
|
33
|
+
\t puts "something"
|
34
|
+
end
|
35
|
+
end}
|
36
|
+
|
37
|
+
H_SPACING_2[:hard_tab_with_2_indented_spaces] =
|
38
|
+
%Q{class Thing
|
39
|
+
def something
|
40
|
+
\t puts "something"
|
41
|
+
end
|
42
|
+
end}
|
43
|
+
|
44
|
+
#-------------------------------------------------------------------------------
|
45
|
+
# Long lines
|
46
|
+
#-------------------------------------------------------------------------------
|
47
|
+
H_SPACING_1[:long_line_no_newline] = %Q{'#{'#' * 79}'}
|
48
|
+
H_SPACING_1[:long_line_newline_at_82] =%Q{'#{'#' * 79}'
|
49
|
+
}
|
50
|
+
|
51
|
+
#-------------------------------------------------------------------------------
|
52
|
+
# Trailing whitespace
|
53
|
+
#-------------------------------------------------------------------------------
|
54
|
+
H_SPACING_1[:empty_line_with_spaces] = %Q{ }
|
55
|
+
H_SPACING_1[:empty_line_with_spaces_in_method] = %Q{def thing
|
56
|
+
|
57
|
+
puts 'something'
|
58
|
+
end}
|
59
|
+
|
60
|
+
H_SPACING_1[:trailing_spaces_on_def] = %Q{def thing
|
61
|
+
puts 'something'
|
62
|
+
end}
|
63
|
+
|
64
|
+
#-------------------------------------------------------------------------------
|
65
|
+
# Comma spacing
|
66
|
+
#-------------------------------------------------------------------------------
|
67
|
+
H_SPACING_1[:no_space_after_comma] = %Q{[1,2]}
|
68
|
+
H_SPACING_1[:two_spaces_after_comma] = %Q{[1, 2]}
|
69
|
+
H_SPACING_1[:one_space_before_comma] = %Q{[1 ,2]}
|
70
|
+
H_SPACING_1[:two_spaces_before_comma] = %Q{[1 , 2]}
|
71
|
+
H_SPACING_2[:two_spaces_before_comma_twice] = %Q{[1 , 2 , 3]}
|
72
|
+
H_SPACING_2[:two_spaces_after_comma_twice] = %Q{[1, 2, 3]}
|
73
|
+
|
74
|
+
H_SPACING_2[:spaces_before_with_trailing_comments] = %Q{[
|
75
|
+
1 , # Comment!
|
76
|
+
2 , # Another comment.
|
77
|
+
}
|
78
|
+
|
79
|
+
H_SPACING_OK[:space_after_comma_in_array] = %Q{[1, 2]}
|
80
|
+
|
81
|
+
H_SPACING_OK[:trailing_comma] = %Q{def thing(one, two,
|
82
|
+
three)
|
83
|
+
end}
|
84
|
+
|
85
|
+
H_SPACING_OK[:trailing_comma_with_trailing_comment] =
|
86
|
+
%Q{def thing(one, two, # Comment!
|
87
|
+
three)
|
88
|
+
end}
|
89
|
+
|
90
|
+
H_SPACING_OK[:no_before_comma_in_array] = %Q{[1, 2]}
|
91
|
+
|
92
|
+
#-------------------------------------------------------------------------------
|
93
|
+
# Braces
|
94
|
+
#-------------------------------------------------------------------------------
|
95
|
+
H_SPACING_OK[:empty_hash] = %Q{{}}
|
96
|
+
H_SPACING_OK[:single_line_hash] = %Q{{ :one => 'one' }}
|
97
|
+
H_SPACING_OK[:single_line_hash_lonely_braces] = %Q{{
|
98
|
+
:one => 'one'
|
99
|
+
}}
|
100
|
+
|
101
|
+
H_SPACING_OK[:hash_as_param_in_parens] =
|
102
|
+
%Q{add_headers({ content_length: new_body.length })}
|
103
|
+
|
104
|
+
H_SPACING_OK[:two_line_hash] = %Q{{ :one =>
|
105
|
+
'one' }}
|
106
|
+
|
107
|
+
H_SPACING_OK[:two_line_hash_trailing_comment] = %Q{{ :one => # comment
|
108
|
+
'one' }}
|
109
|
+
|
110
|
+
H_SPACING_OK[:three_line_hash] = %Q{{ :one =>
|
111
|
+
'one', :two =>
|
112
|
+
'two' }}
|
113
|
+
|
114
|
+
H_SPACING_OK[:single_line_block] = %Q{1..10.times { |n| puts number }}
|
115
|
+
H_SPACING_OK[:multi_line_braces_block] = %Q{1..10.times { |n|
|
116
|
+
puts number }}
|
117
|
+
|
118
|
+
H_SPACING_OK[:multi_line_qword_using_braces] = %Q{%w{
|
119
|
+
foo
|
120
|
+
bar
|
121
|
+
baz
|
122
|
+
}.each do |whatevs|
|
123
|
+
bla
|
124
|
+
end}
|
125
|
+
|
126
|
+
H_SPACING_OK[:empty_hash_in_multi_line_statement] =
|
127
|
+
%Q{if true
|
128
|
+
{}
|
129
|
+
end}
|
130
|
+
|
131
|
+
H_SPACING_OK[:multi_line_hash_in_multi_line_statement] =
|
132
|
+
%Q{if true
|
133
|
+
options = {
|
134
|
+
one: 1
|
135
|
+
}
|
136
|
+
end}
|
137
|
+
|
138
|
+
H_SPACING_OK[:single_line_string_interp] = %Q{`\#{IFCONFIG} | grep \#{ip}`}
|
139
|
+
H_SPACING_OK[:single_line_block_in_string_interp] =
|
140
|
+
%Q{"I did this \#{1..10.times { |n| n }} times."}
|
141
|
+
|
142
|
+
H_SPACING_OK[:empty_hash_in_string_in_block] =
|
143
|
+
%Q{[1].map { |n| { :first => "\#{n}-\#{{}}" } }}
|
144
|
+
|
145
|
+
H_SPACING_OK[:string_interp_with_colonop] =
|
146
|
+
%Q{"\#{::Rails.root}"}
|
147
|
+
|
148
|
+
H_SPACING_1[:single_line_hash_2_spaces_before_lbrace] =
|
149
|
+
%Q{thing = { :one => 'one' }}
|
150
|
+
|
151
|
+
H_SPACING_1[:single_line_hash_2_spaces_before_rbrace] =
|
152
|
+
%Q{thing = { :one => 'one' }}
|
153
|
+
|
154
|
+
H_SPACING_1[:single_line_hash_2_spaces_after_lbrace] =
|
155
|
+
%Q{thing = { :one => 'one' }}
|
156
|
+
|
157
|
+
H_SPACING_1[:single_line_hash_0_spaces_before_lbrace] =
|
158
|
+
%Q{thing ={ :one => 'one' }}
|
159
|
+
|
160
|
+
H_SPACING_1[:two_line_hash_2_spaces_before_lbrace] = %Q{thing1 =
|
161
|
+
thing2 = { :one => 'one' }}
|
162
|
+
|
163
|
+
H_SPACING_1[:two_line_hash_2_spaces_before_rbrace] = %Q{thing1 =
|
164
|
+
thing2 = { :one => 'one' }}
|
165
|
+
|
166
|
+
H_SPACING_1[:two_line_hash_2_spaces_before_lbrace_lonely_braces] =
|
167
|
+
%Q{thing1 =
|
168
|
+
thing2 = {
|
169
|
+
:one => 'one'
|
170
|
+
}}
|
171
|
+
|
172
|
+
H_SPACING_1[:space_in_empty_hash_in_string_in_block] =
|
173
|
+
%Q{[1].map { |n| { :first => "\#{n}-\#{{ }}" } }}
|
174
|
+
|
175
|
+
H_SPACING_1[:single_line_block_2_spaces_before_lbrace] =
|
176
|
+
%Q{1..10.times { |n| puts n }}
|
177
|
+
|
178
|
+
H_SPACING_1[:single_line_block_in_string_interp_2_spaces_before_lbrace] =
|
179
|
+
%Q{"I did this \#{1..10.times { |n| puts n }} times."}
|
180
|
+
|
181
|
+
H_SPACING_1[:single_line_block_0_spaces_before_lbrace] =
|
182
|
+
%Q{1..10.times{ |n| puts n }}
|
183
|
+
|
184
|
+
H_SPACING_1[:two_line_braces_block_2_spaces_before_lbrace] =
|
185
|
+
%Q{1..10.times { |n|
|
186
|
+
puts n}}
|
187
|
+
|
188
|
+
H_SPACING_1[:two_line_braces_block_0_spaces_before_lbrace_trailing_comment] =
|
189
|
+
%Q{1..10.times{ |n| # comment
|
190
|
+
puts n}}
|
191
|
+
|
192
|
+
H_SPACING_2[:no_space_after_l_before_r_after_string_interp] =
|
193
|
+
%Q{logger.debug "Upgrading from \#{current_version} to \#{new_version}", {:format => :short}}
|
194
|
+
|
195
|
+
H_SPACING_2[:no_space_before_consecutive_rbraces] =
|
196
|
+
%Q{thing = { 'id' => "\#{source}", 'attributes' => { 'height' => "\#{height}"}}}
|
197
|
+
|
198
|
+
#-------------------------------------------------------------------------------
|
199
|
+
# Brackets
|
200
|
+
#-------------------------------------------------------------------------------
|
201
|
+
H_SPACING_OK[:empty_array] = %Q{[]}
|
202
|
+
H_SPACING_OK[:simple_array] = %Q{[1, 2, 3]}
|
203
|
+
H_SPACING_OK[:two_d_array] = %Q{[[1, 2, 3], ['a', 'b', 'c']]}
|
204
|
+
H_SPACING_OK[:hash_key_reference] = %Q{thing[:one]}
|
205
|
+
H_SPACING_OK[:array_of_symbols] =
|
206
|
+
%Q{transition [:active, :reactivated] => :opened}
|
207
|
+
H_SPACING_OK[:array_of_hashes] =
|
208
|
+
%Q{[ { :one => [[1, 2, 3], ['a', 'b', 'c']] },
|
209
|
+
{ :two => [[4, 5, 6], ['d', 'e', 'f']] }]}
|
210
|
+
|
211
|
+
H_SPACING_OK[:simple_array_lonely_brackets] =
|
212
|
+
%Q{[
|
213
|
+
1, 2,
|
214
|
+
3
|
215
|
+
]}
|
216
|
+
|
217
|
+
H_SPACING_OK[:simple_nested_array_lonely_brackets] =
|
218
|
+
%Q{def thing
|
219
|
+
[
|
220
|
+
1, 2,
|
221
|
+
3
|
222
|
+
]
|
223
|
+
end}
|
224
|
+
|
225
|
+
|
226
|
+
H_SPACING_OK[:empty_array_in_multi_line_statement] =
|
227
|
+
%Q{if true
|
228
|
+
[]
|
229
|
+
end}
|
230
|
+
|
231
|
+
H_SPACING_1[:space_in_empty_array] = %Q{[ ]}
|
232
|
+
H_SPACING_1[:simple_array_space_after_lbracket] = %Q{[ 1, 2, 3]}
|
233
|
+
H_SPACING_1[:simple_array_space_before_rbracket] = %Q{[1, 2, 3 ]}
|
234
|
+
H_SPACING_1[:hash_key_ref_space_before_rbracket] = %Q{thing[:one ]}
|
235
|
+
H_SPACING_1[:hash_key_ref_space_after_lbracket] = %Q{thing[ :one]}
|
236
|
+
H_SPACING_2[:two_d_array_space_after_lbrackets] =
|
237
|
+
%Q{[ [1, 2, 3], [ 'a', 'b', 'c']]}
|
238
|
+
H_SPACING_2[:two_d_array_space_before_rbrackets] =
|
239
|
+
%Q{[[1, 2, 3 ], [ 'a', 'b', 'c'] ]}
|
240
|
+
|
241
|
+
#-------------------------------------------------------------------------------
|
242
|
+
# Parens
|
243
|
+
#-------------------------------------------------------------------------------
|
244
|
+
H_SPACING_OK[:empty_parens] = %Q{def thing()}
|
245
|
+
H_SPACING_OK[:simple_method_call] = %Q{thing(one, two)}
|
246
|
+
H_SPACING_OK[:multi_line_method_call] = %Q{thing(one,
|
247
|
+
two)}
|
248
|
+
H_SPACING_OK[:multi_line_method_call_lonely_parens] = %Q{thing(
|
249
|
+
one, two
|
250
|
+
)}
|
251
|
+
|
252
|
+
H_SPACING_1[:simple_method_call_space_after_lparen] = %Q{thing( one, two)}
|
253
|
+
H_SPACING_1[:simple_method_call_space_before_rparen] = %Q{thing(one, two )}
|
254
|
+
H_SPACING_1[:method_call_space_after_lparen_trailing_comment] =
|
255
|
+
%Q{thing( one, two) # comment}
|
256
|
+
H_SPACING_2[:method_call_space_after_lparen_before_rparen_trailing_comment] =
|
257
|
+
%Q{thing( one, two ) # comment}
|
258
|
+
|
259
|
+
H_SPACING_1[:multi_line_method_call_space_after_lparen] = %Q{thing( one,
|
260
|
+
two)}
|
261
|
+
H_SPACING_1[:multi_line_method_call_space_after_lparen_trailing_comment] =
|
262
|
+
%Q{thing( one,
|
263
|
+
two)}
|
264
|
+
|
265
|
+
|
@@ -0,0 +1,972 @@
|
|
1
|
+
INDENT_OK = {}
|
2
|
+
|
3
|
+
INDENT_OK[:class] =
|
4
|
+
%Q{class MyClass
|
5
|
+
end}
|
6
|
+
|
7
|
+
INDENT_OK[:one_line_class] =
|
8
|
+
%Q{class MyClass; end}
|
9
|
+
|
10
|
+
INDENT_OK[:one_line_subclass] =
|
11
|
+
%Q{class MyClass < RuntimeError; end}
|
12
|
+
|
13
|
+
INDENT_OK[:one_line_subclass_with_inheritance] =
|
14
|
+
%Q{class MyClass < Array
|
15
|
+
class MyError < RuntimeError; end
|
16
|
+
include AnotherThing
|
17
|
+
end}
|
18
|
+
|
19
|
+
INDENT_OK[:class_empty] =
|
20
|
+
%Q{class MyClass
|
21
|
+
|
22
|
+
end}
|
23
|
+
|
24
|
+
INDENT_OK[:class_empty_trailing_comment] =
|
25
|
+
%Q{class MyClass # Comment!
|
26
|
+
|
27
|
+
end}
|
28
|
+
|
29
|
+
INDENT_OK[:class_singlestatement] =
|
30
|
+
%Q{class MyClass
|
31
|
+
include Stuff
|
32
|
+
end}
|
33
|
+
|
34
|
+
INDENT_OK[:assignment_addition_multistatement] =
|
35
|
+
%Q{thing = 1 +
|
36
|
+
2 + 3 + 4 +
|
37
|
+
5}
|
38
|
+
|
39
|
+
INDENT_OK[:assignment_addition_multistatement_trailing_comment] =
|
40
|
+
%Q{thing = 1 + # Comment!
|
41
|
+
2 + 3 + 4 +
|
42
|
+
5}
|
43
|
+
|
44
|
+
INDENT_OK[:assignment_hash_multistatement] =
|
45
|
+
%Q{thing = {
|
46
|
+
:one => 'one',
|
47
|
+
two: 'two'
|
48
|
+
}}
|
49
|
+
|
50
|
+
INDENT_OK[:assignment_hash_multistatement_trailing_comment] =
|
51
|
+
%Q{thing = {
|
52
|
+
:one => 'one', # Comment
|
53
|
+
two: 'two'
|
54
|
+
}}
|
55
|
+
|
56
|
+
INDENT_OK[:assignment_array_multistatement] =
|
57
|
+
%Q{thing = [
|
58
|
+
:one,
|
59
|
+
:two
|
60
|
+
]}
|
61
|
+
|
62
|
+
INDENT_OK[:assignment_array_multistatement_trailing_comment] =
|
63
|
+
%Q{thing = [
|
64
|
+
:one, # comment
|
65
|
+
:two
|
66
|
+
]}
|
67
|
+
|
68
|
+
INDENT_OK[:assignment_paren_multistatement] =
|
69
|
+
%Q{eval('puts',
|
70
|
+
binding,
|
71
|
+
'my_file.rb',
|
72
|
+
5)}
|
73
|
+
|
74
|
+
INDENT_OK[:assignment_paren_multistatement_trailing_comment] =
|
75
|
+
%Q{eval('puts',
|
76
|
+
binding,
|
77
|
+
'my_file.rb', # comment
|
78
|
+
5)}
|
79
|
+
|
80
|
+
INDENT_OK[:assignment_twolevel_hash_multistatement] =
|
81
|
+
%Q{thing = {
|
82
|
+
:one => {
|
83
|
+
:a => 'a',
|
84
|
+
b: => 'b'
|
85
|
+
},
|
86
|
+
two: {
|
87
|
+
x: 'x',
|
88
|
+
:y => 'y'
|
89
|
+
}
|
90
|
+
}}
|
91
|
+
|
92
|
+
INDENT_OK[:assignment_twolevel_array_multistatement] =
|
93
|
+
%Q{thing = [
|
94
|
+
[:one],
|
95
|
+
[
|
96
|
+
:two,
|
97
|
+
:three
|
98
|
+
]
|
99
|
+
]}
|
100
|
+
|
101
|
+
INDENT_OK[:assignment_twolevel_paren_multistatement] =
|
102
|
+
%Q{result = Integer(
|
103
|
+
String.new(
|
104
|
+
"1"
|
105
|
+
).to_i,
|
106
|
+
16
|
107
|
+
)}
|
108
|
+
|
109
|
+
INDENT_OK[:method_call_multistatement] =
|
110
|
+
%Q{my_method_with_many_params(one, two,
|
111
|
+
three,
|
112
|
+
four,
|
113
|
+
five)}
|
114
|
+
|
115
|
+
INDENT_OK[:method_call_multistatement_trailing_comment] =
|
116
|
+
%Q{my_method_with_many_params(one, two,
|
117
|
+
three, # comment
|
118
|
+
four,
|
119
|
+
five)}
|
120
|
+
|
121
|
+
INDENT_OK[:method_call_multistatement_lonely_paren] =
|
122
|
+
%Q{my_method_with_many_params(one, two,
|
123
|
+
three,
|
124
|
+
four,
|
125
|
+
five
|
126
|
+
)}
|
127
|
+
|
128
|
+
INDENT_OK[:method_call_multistatement_lonely_paren_trailing_comment] =
|
129
|
+
%Q{my_method_with_many_params(one, two, # comment
|
130
|
+
three,
|
131
|
+
four,
|
132
|
+
five
|
133
|
+
)}
|
134
|
+
|
135
|
+
INDENT_OK[:rescue_ending_with_comma] =
|
136
|
+
%Q{begin
|
137
|
+
ssh.upload source, dest
|
138
|
+
@logger.info "Successfully copied the file \#{source} to " +
|
139
|
+
"\#{@config[:scp_hostname]}:\#{dest}."
|
140
|
+
rescue SocketError, ArgumentError, SystemCallError,
|
141
|
+
Net::SCP::Exception, Timeout::Error => ex
|
142
|
+
@logger.error "Failed to copy the file \#{source} to \#{dest} due to " +
|
143
|
+
"\#{ex.message}"
|
144
|
+
end}
|
145
|
+
|
146
|
+
INDENT_OK[:rescue_ending_with_comma_trailing_comment] =
|
147
|
+
%Q{begin
|
148
|
+
ssh.upload source, dest
|
149
|
+
@logger.info "Successfully copied the file \#{source} to " +
|
150
|
+
"\#{@config[:scp_hostname]}:\#{dest}."
|
151
|
+
rescue SocketError, ArgumentError, SystemCallError, # comment
|
152
|
+
Net::SCP::Exception, Timeout::Error => ex
|
153
|
+
@logger.error "Failed to copy the file \#{source} to \#{dest} due to " +
|
154
|
+
"\#{ex.message}"
|
155
|
+
end}
|
156
|
+
|
157
|
+
INDENT_OK[:keyword_ending_with_period] =
|
158
|
+
%Q{if [].
|
159
|
+
empty?
|
160
|
+
puts 'hi'
|
161
|
+
end}
|
162
|
+
|
163
|
+
INDENT_OK[:keyword_ending_with_period_trailing_comment] =
|
164
|
+
%Q{if []. # comment
|
165
|
+
empty?
|
166
|
+
puts 'hi'
|
167
|
+
end}
|
168
|
+
|
169
|
+
INDENT_OK[:def] =
|
170
|
+
%Q{def a_method
|
171
|
+
end}
|
172
|
+
|
173
|
+
INDENT_OK[:def_empty] =
|
174
|
+
%Q{def a_method
|
175
|
+
|
176
|
+
end}
|
177
|
+
|
178
|
+
INDENT_OK[:nested_def] =
|
179
|
+
%Q{def first_method
|
180
|
+
def second_method
|
181
|
+
puts "hi"
|
182
|
+
end
|
183
|
+
end}
|
184
|
+
|
185
|
+
INDENT_OK[:nested_class] =
|
186
|
+
%Q{class MyClass
|
187
|
+
class AnotherClass
|
188
|
+
end
|
189
|
+
end}
|
190
|
+
|
191
|
+
INDENT_OK[:require_class_singlestatement] =
|
192
|
+
%Q{require 'time'
|
193
|
+
|
194
|
+
class MyClass
|
195
|
+
include Stuff
|
196
|
+
end}
|
197
|
+
|
198
|
+
INDENT_OK[:require_class_singlestatement_def] =
|
199
|
+
%Q{require 'time'
|
200
|
+
|
201
|
+
class MyClass
|
202
|
+
include Stuff
|
203
|
+
|
204
|
+
def a_method
|
205
|
+
end
|
206
|
+
end}
|
207
|
+
|
208
|
+
INDENT_OK[:require_class_singlestatement_def_content] =
|
209
|
+
%Q{require 'time'
|
210
|
+
|
211
|
+
class MyClass
|
212
|
+
include Stuff
|
213
|
+
|
214
|
+
def a_method
|
215
|
+
puts "hello"
|
216
|
+
end
|
217
|
+
end}
|
218
|
+
|
219
|
+
INDENT_OK[:if_modifier] =
|
220
|
+
%Q{puts "hi" if nil.nil?}
|
221
|
+
|
222
|
+
INDENT_OK[:if_modifier2] =
|
223
|
+
%Q{start_key_registration_server if @profiles.values.include? :SM5000}
|
224
|
+
|
225
|
+
INDENT_OK[:def_return_if_modifier] =
|
226
|
+
%Q{def a_method
|
227
|
+
return @something if @something
|
228
|
+
end}
|
229
|
+
|
230
|
+
INDENT_OK[:unless_modifier] =
|
231
|
+
%Q{puts "hi" unless nil.nil?}
|
232
|
+
|
233
|
+
INDENT_OK[:def_return_unless_modifier] =
|
234
|
+
%Q{def a_method
|
235
|
+
return @something unless @something
|
236
|
+
end}
|
237
|
+
|
238
|
+
INDENT_OK[:multi_line_if_with_trailing_andop] =
|
239
|
+
%Q{unless Tim::Runner.configuration[:scp_hostname].nil?
|
240
|
+
@reporter.secure_copy if Tim::Runner.configuration[:scp_username] &&
|
241
|
+
Tim::Runner.configuration[:scp_password]
|
242
|
+
end}
|
243
|
+
|
244
|
+
INDENT_OK[:while_within_single_line_block] =
|
245
|
+
%Q{Timeout::timeout(DEVICE_TIMEOUT) { sleep(0.5) while @device_server.urls.nil? }}
|
246
|
+
|
247
|
+
INDENT_OK[:case_whens_level] =
|
248
|
+
%Q{def my_method
|
249
|
+
case true
|
250
|
+
when true
|
251
|
+
puts "stuff"
|
252
|
+
when false
|
253
|
+
puts "blah blah"
|
254
|
+
end
|
255
|
+
end}
|
256
|
+
|
257
|
+
INDENT_OK[:case_strings_in_strings] =
|
258
|
+
%Q{case type
|
259
|
+
when :output
|
260
|
+
"I like to \#{eval('puts')}, but should be \#{eval('print')}"
|
261
|
+
when :input
|
262
|
+
"Gimme \#{eval('gets')}!"
|
263
|
+
end}
|
264
|
+
|
265
|
+
INDENT_OK[:case_whens_in] =
|
266
|
+
%Q{def my_method
|
267
|
+
case true
|
268
|
+
when true
|
269
|
+
puts "stuff"
|
270
|
+
when false
|
271
|
+
puts "blah blah"
|
272
|
+
end
|
273
|
+
end}
|
274
|
+
|
275
|
+
INDENT_OK[:while_do_loop] =
|
276
|
+
%Q{while true do
|
277
|
+
puts "something"
|
278
|
+
end}
|
279
|
+
|
280
|
+
INDENT_OK[:while_do_loop2] =
|
281
|
+
%Q{i = 0;
|
282
|
+
num = 5;
|
283
|
+
|
284
|
+
while i < num do
|
285
|
+
puts("Inside the loop i = \#{i}");
|
286
|
+
i +=1;
|
287
|
+
end}
|
288
|
+
|
289
|
+
INDENT_OK[:until_do_loop] =
|
290
|
+
%Q{until true do
|
291
|
+
puts "something"
|
292
|
+
end}
|
293
|
+
|
294
|
+
INDENT_OK[:until_do_loop2] =
|
295
|
+
%Q{i = 0;
|
296
|
+
num = 5;
|
297
|
+
|
298
|
+
until i > num do
|
299
|
+
puts("Inside the loop i = \#{i}");
|
300
|
+
i +=1;
|
301
|
+
end}
|
302
|
+
|
303
|
+
INDENT_OK[:for_do_loop] =
|
304
|
+
%Q{for i in 1..100 do
|
305
|
+
puts i
|
306
|
+
end}
|
307
|
+
|
308
|
+
INDENT_OK[:loop_do_loop] =
|
309
|
+
%Q{loop do
|
310
|
+
puts 'looping'
|
311
|
+
end}
|
312
|
+
|
313
|
+
INDENT_OK[:while_as_modifier_loop] =
|
314
|
+
%Q{i = 0;
|
315
|
+
num = 5;
|
316
|
+
begin
|
317
|
+
puts("Inside the loop i = \#{i}");
|
318
|
+
i +=1;
|
319
|
+
end while i < num}
|
320
|
+
|
321
|
+
INDENT_OK[:until_as_modifier_loop] =
|
322
|
+
%Q{i = 0;
|
323
|
+
num = 5;
|
324
|
+
begin
|
325
|
+
puts("Inside the loop i = \#{i}");
|
326
|
+
i +=1;
|
327
|
+
end until i > num}
|
328
|
+
|
329
|
+
INDENT_OK[:for_with_break_loop] =
|
330
|
+
%Q{for i in 0..5
|
331
|
+
if i > 2 then
|
332
|
+
break
|
333
|
+
end
|
334
|
+
puts "Value of local variable is \#{i}"
|
335
|
+
end}
|
336
|
+
|
337
|
+
INDENT_OK[:for_with_next_loop] =
|
338
|
+
%Q{for i in 0..5
|
339
|
+
if i < 2 then
|
340
|
+
next
|
341
|
+
end
|
342
|
+
puts "Value of local variable is \#{i}"
|
343
|
+
end}
|
344
|
+
|
345
|
+
INDENT_OK[:for_with_redo_loop] =
|
346
|
+
%Q{for i in 0..5
|
347
|
+
if i < 2 then
|
348
|
+
puts "Value of local variable is \#{i}"
|
349
|
+
redo
|
350
|
+
end
|
351
|
+
end}
|
352
|
+
|
353
|
+
INDENT_OK[:for_with_retry_loop] =
|
354
|
+
%Q{for i in 1..5
|
355
|
+
retry if i > 2
|
356
|
+
puts "Value of local variable is \#{i}"
|
357
|
+
end}
|
358
|
+
|
359
|
+
INDENT_OK[:loop_with_braces] =
|
360
|
+
%Q{loop {
|
361
|
+
puts 'stuff'
|
362
|
+
}}
|
363
|
+
|
364
|
+
#----------- Braces ----------#
|
365
|
+
INDENT_OK[:single_line_braces] =
|
366
|
+
%Q{{ one: 1, two: 2 }}
|
367
|
+
|
368
|
+
INDENT_OK[:single_line_braces_as_t_string] =
|
369
|
+
%Q{%Q{this is a t string!}}
|
370
|
+
|
371
|
+
INDENT_OK[:multi_line_braces] =
|
372
|
+
%Q{{ one: 1,
|
373
|
+
two: 2 }}
|
374
|
+
|
375
|
+
INDENT_OK[:multi_line_braces_as_t_string] =
|
376
|
+
%Q{%Q{this is a t string!
|
377
|
+
suckaaaaaa!}}
|
378
|
+
|
379
|
+
INDENT_OK[:multi_line_lonely_braces] =
|
380
|
+
%Q{{
|
381
|
+
:one => 'one', :two => 'two',
|
382
|
+
:three => 'three'
|
383
|
+
}}
|
384
|
+
|
385
|
+
INDENT_OK[:multi_line_lonely_braces_as_t_string] =
|
386
|
+
%Q{%Q{
|
387
|
+
this is a t string!
|
388
|
+
suckaaaaaa!
|
389
|
+
}}
|
390
|
+
|
391
|
+
INDENT_OK[:multi_line_braces_embedded_arrays] =
|
392
|
+
%Q{{
|
393
|
+
:one => ['one', 17, {}], :two => ['two'],
|
394
|
+
:three => 'three'
|
395
|
+
}}
|
396
|
+
INDENT_OK[:braces_combo] =
|
397
|
+
%Q{{ three: 3 }
|
398
|
+
{
|
399
|
+
three: 3 }
|
400
|
+
{ three: 3
|
401
|
+
}
|
402
|
+
{
|
403
|
+
three: 3
|
404
|
+
}}
|
405
|
+
|
406
|
+
#----------- Brackets ----------#
|
407
|
+
INDENT_OK[:single_line_brackets] =
|
408
|
+
%Q{['one', 'two', 'three']}
|
409
|
+
|
410
|
+
INDENT_OK[:single_line_brackets_as_t_string] =
|
411
|
+
%Q{%Q[this is a t string!]}
|
412
|
+
|
413
|
+
INDENT_OK[:multi_line_brackets] =
|
414
|
+
%Q{['one',
|
415
|
+
'two',
|
416
|
+
'three']}
|
417
|
+
|
418
|
+
INDENT_OK[:multi_line_brackets_as_t_string] =
|
419
|
+
%Q{%Q[this is a t string!
|
420
|
+
it doesn't matter that this is way over here.
|
421
|
+
suckaaaaaa!]}
|
422
|
+
|
423
|
+
INDENT_OK[:multi_line_lonely_brackets] =
|
424
|
+
%Q{[
|
425
|
+
'one',
|
426
|
+
'two',
|
427
|
+
'three'
|
428
|
+
]}
|
429
|
+
|
430
|
+
INDENT_OK[:multi_line_lonely_brackets_as_t_string] =
|
431
|
+
%Q{%Q[
|
432
|
+
this is a t string!
|
433
|
+
it doesn't matter that this is way over here.
|
434
|
+
suckaaaaaa!
|
435
|
+
]}
|
436
|
+
|
437
|
+
INDENT_OK[:multi_line_brackets_embedded_hashes] =
|
438
|
+
%Q{summary_table.rows << [{ value: "File", align: :center },
|
439
|
+
{ value: "Total Problems", align: :center }]}
|
440
|
+
|
441
|
+
INDENT_OK[:brackets_combo] =
|
442
|
+
%Q{[2]
|
443
|
+
[
|
444
|
+
2]
|
445
|
+
[2
|
446
|
+
]
|
447
|
+
[
|
448
|
+
2
|
449
|
+
]}
|
450
|
+
|
451
|
+
#----------- Parens ----------#
|
452
|
+
|
453
|
+
INDENT_OK[:single_line_parens] =
|
454
|
+
%Q{(true || false)}
|
455
|
+
|
456
|
+
INDENT_OK[:single_line_parens_as_t_string] =
|
457
|
+
%Q{%Q(this is a t string!)}
|
458
|
+
|
459
|
+
INDENT_OK[:multi_line_parens] =
|
460
|
+
%Q{my_method(first_argument, second_arg,
|
461
|
+
third_arg)}
|
462
|
+
|
463
|
+
INDENT_OK[:multi_line_parens_as_t_string] =
|
464
|
+
%Q{%Q(this is a t string!
|
465
|
+
and i'm not going
|
466
|
+
anywhere!')}
|
467
|
+
|
468
|
+
INDENT_OK[:multi_line_lonely_parens] =
|
469
|
+
%Q{my_method(
|
470
|
+
first_argument
|
471
|
+
)}
|
472
|
+
|
473
|
+
INDENT_OK[:multi_line_lonely_parens_with_commas] =
|
474
|
+
%Q{my_method(
|
475
|
+
first_argument, second_arg,
|
476
|
+
third_arg
|
477
|
+
)}
|
478
|
+
|
479
|
+
INDENT_OK[:multi_line_lonely_parens_as_t_string] =
|
480
|
+
%Q{%Q(
|
481
|
+
this is a t string!
|
482
|
+
and i'm not going
|
483
|
+
anywhere!'
|
484
|
+
)}
|
485
|
+
|
486
|
+
INDENT_OK[:parens_combo] =
|
487
|
+
%Q{(1)
|
488
|
+
(
|
489
|
+
1)
|
490
|
+
(1
|
491
|
+
)
|
492
|
+
(
|
493
|
+
1
|
494
|
+
)}
|
495
|
+
|
496
|
+
|
497
|
+
#-------------------------------------------------------------------------------
|
498
|
+
# Operators
|
499
|
+
#-------------------------------------------------------------------------------
|
500
|
+
INDENT_OK[:multi_line_ops] =
|
501
|
+
%Q{2 -
|
502
|
+
1 -
|
503
|
+
0 +
|
504
|
+
12}
|
505
|
+
|
506
|
+
INDENT_OK[:multi_line_andop_in_method] =
|
507
|
+
%Q{def end_of_multiline_string?(lexed_line_output)
|
508
|
+
lexed_line_output.any? { |e| e[1] == :on_tstring_end } &&
|
509
|
+
lexed_line_output.none? { |e| e[1] == :on_tstring_beg }
|
510
|
+
end}
|
511
|
+
|
512
|
+
INDENT_OK[:multi_line_rshift_in_method] =
|
513
|
+
%Q{rule(:transport_specifier) do
|
514
|
+
match('[A-Za-z]').repeat(3).as(:streaming_protocol) >> forward_slash >>
|
515
|
+
match('[A-Za-z]').repeat(3).as(:profile) >>
|
516
|
+
(forward_slash >> match('[A-Za-z]').repeat(3).as(:transport_protocol)).maybe
|
517
|
+
end
|
518
|
+
|
519
|
+
rule(:interleaved) do
|
520
|
+
str('interleaved=') >> number.as(:rtp_channel) >> dash >>
|
521
|
+
number.as(:rtcp_channel)
|
522
|
+
end
|
523
|
+
|
524
|
+
rule(:ttl) do
|
525
|
+
str('ttl=') >> match('[\d]').repeat(1, 3).as(:ttl)
|
526
|
+
end}
|
527
|
+
|
528
|
+
INDENT_OK[:multi_line_string_concat_with_plus] =
|
529
|
+
%Q{DVR_SSDP_NOTIFICATION_TEMPLATE = File.dirname(__FILE__) +
|
530
|
+
'/profiles/DVR5000/ssdp_notification.erb'}
|
531
|
+
|
532
|
+
INDENT_OK[:multi_line_string_concat_with_plus_in_parens] =
|
533
|
+
%Q{DVR_CONFIG_RENDERER = Erubis::Eruby.new(File.read File.dirname(__FILE__) +
|
534
|
+
'/profiles/DVR5000/device_config.xml.erb')}
|
535
|
+
|
536
|
+
INDENT_OK[:multi_line_string_concat_twice] =
|
537
|
+
%Q{unless Tim::Runner.configuration[:email].nil? ||
|
538
|
+
Tim::Runner.configuration[:email].empty?
|
539
|
+
Tim::EmailReporter.subject_status ||= subject_status
|
540
|
+
@email_reporter.send_email
|
541
|
+
end
|
542
|
+
|
543
|
+
def print_iteration_start iteration_number
|
544
|
+
iteration_message = "Running Iteration \#{iteration_number} of " +
|
545
|
+
@config[:suite_iterations].to_s
|
546
|
+
@logger.info bar(iteration_message)
|
547
|
+
end}
|
548
|
+
|
549
|
+
#-------------------------------------------------------------------------------
|
550
|
+
# Method calls
|
551
|
+
#-------------------------------------------------------------------------------
|
552
|
+
INDENT_OK[:multi_line_method_call] =
|
553
|
+
%Q{def initialize(raw_response)
|
554
|
+
if raw_response.nil? || raw_response.empty?
|
555
|
+
raise RTSP::Error,
|
556
|
+
"\#{self.class} received nil string--this shouldn't happen."
|
557
|
+
end
|
558
|
+
|
559
|
+
@raw_response = raw_response
|
560
|
+
|
561
|
+
head, body = split_head_and_body_from @raw_response
|
562
|
+
parse_head(head)
|
563
|
+
@body = parse_body(body)
|
564
|
+
end}
|
565
|
+
|
566
|
+
INDENT_OK[:multi_line_method_call_ends_with_period] =
|
567
|
+
%Q{unless streamer == MulticastStreamer.instance
|
568
|
+
streamer.state = :DISCONNECTED
|
569
|
+
UnicastStreamer.pool << streamer unless UnicastStreamer.pool.
|
570
|
+
member? streamer
|
571
|
+
end}
|
572
|
+
|
573
|
+
INDENT_OK[:multi_line_method_call_ends_with_many_periods] =
|
574
|
+
%Q{my_hashie.first_level.
|
575
|
+
second_level.
|
576
|
+
third_level}
|
577
|
+
|
578
|
+
INDENT_OK[:method_closing_lonely_paren] =
|
579
|
+
%Q{def your_thing(one
|
580
|
+
)
|
581
|
+
end}
|
582
|
+
|
583
|
+
INDENT_OK[:method_lonely_args] =
|
584
|
+
%Q{def your_thing(
|
585
|
+
one
|
586
|
+
)
|
587
|
+
puts "stuff"
|
588
|
+
end}
|
589
|
+
|
590
|
+
#------------------------------------------------------------------------------
|
591
|
+
# If + logical operators
|
592
|
+
#------------------------------------------------------------------------------
|
593
|
+
INDENT_OK[:multi_line_if_logical_and] =
|
594
|
+
%Q{if @indentation_ruler.op_statement_nesting.empty? &&
|
595
|
+
@indentation_ruler.tstring_nesting.empty? &&
|
596
|
+
@indentation_ruler.paren_nesting.empty? &&
|
597
|
+
@indentation_ruler.brace_nesting.empty? &&
|
598
|
+
@indentation_ruler.bracket_nesting.empty?
|
599
|
+
if current_line.line_ends_with_comma?
|
600
|
+
if @indentation_ruler.last_comma_statement_line.nil?
|
601
|
+
@indentation_ruler.increase_next_line
|
602
|
+
end
|
603
|
+
|
604
|
+
@indentation_ruler.last_comma_statement_line = lineno
|
605
|
+
log "last: \#{@indentation_ruler.last_comma_statement_line}"
|
606
|
+
end
|
607
|
+
end}
|
608
|
+
|
609
|
+
INDENT_OK[:multi_line_each_block] =
|
610
|
+
%Q{style.each do |ruler_name, value|
|
611
|
+
instance_eval(
|
612
|
+
"Tailor::Rulers::\#{camelize(ruler_name.to_s)}Ruler.new(\#{value})"
|
613
|
+
)
|
614
|
+
parent_ruler.add_child_ruler(ruler)
|
615
|
+
end}
|
616
|
+
|
617
|
+
INDENT_OK[:multi_line_each_block_with_op_and_parens] =
|
618
|
+
%Q{style.each do |ruler_name, value|
|
619
|
+
ruler =
|
620
|
+
instance_eval(
|
621
|
+
"Tailor::Rulers::\#{camelize(ruler_name.to_s)}Ruler.new(\#{value})"
|
622
|
+
)
|
623
|
+
parent_ruler.add_child_ruler(ruler)
|
624
|
+
end}
|
625
|
+
|
626
|
+
INDENT_OK[:do_end_block_in_parens] =
|
627
|
+
%Q{begin
|
628
|
+
throw(:result, sexp_line.flatten.compact.any? do |s|
|
629
|
+
s == MODIFIERS[self]
|
630
|
+
end)
|
631
|
+
rescue NoMethodError
|
632
|
+
end}
|
633
|
+
|
634
|
+
INDENT_OK[:rparen_and_do_same_line] =
|
635
|
+
%Q{opt.on('-c', '--config-file FILE',
|
636
|
+
"Use a specific config file.") do |config|
|
637
|
+
options.config_file = config
|
638
|
+
end}
|
639
|
+
|
640
|
+
#-------------------------------------------------------------------------------
|
641
|
+
# Single-line keywords
|
642
|
+
#-------------------------------------------------------------------------------
|
643
|
+
INDENT_OK[:single_line_begin_rescue_end] =
|
644
|
+
%Q{def log
|
645
|
+
l = begin; lineno; rescue; "<EOF>"; end
|
646
|
+
c = begin; column; rescue; "<EOF>"; end
|
647
|
+
subclass_name = self.class.to_s.sub(/^Tailor::/, '')
|
648
|
+
args.first.insert(0, "<\#{subclass_name}> \#{l}[\#{c}]: ")
|
649
|
+
Tailor::Logger.log(*args)
|
650
|
+
end}
|
651
|
+
|
652
|
+
#-------------------------------------------------------------------------------
|
653
|
+
# Combos
|
654
|
+
#-------------------------------------------------------------------------------
|
655
|
+
INDENT_OK[:combo1] =
|
656
|
+
%Q{def set_default_smtp
|
657
|
+
Mail.defaults do
|
658
|
+
@config = Tim::Runner.configuration
|
659
|
+
delivery_method(:smtp,
|
660
|
+
{ :address => @config[:smtp_server],
|
661
|
+
:port => @config[:smtp_server_port] })
|
662
|
+
end
|
663
|
+
end}
|
664
|
+
|
665
|
+
INDENT_OK[:combo2] =
|
666
|
+
%Q{class C
|
667
|
+
|
668
|
+
send :each do
|
669
|
+
def foo
|
670
|
+
end
|
671
|
+
end
|
672
|
+
|
673
|
+
end}
|
674
|
+
|
675
|
+
INDENT_OK[:combo3] =
|
676
|
+
%Q{def report_turducken(results, performance_results)
|
677
|
+
stuffing[:log_files] = { "\#{File.basename @logger.log_file_location}" =>
|
678
|
+
File.read(@logger.log_file_location).gsub(/(?<f><)(?<q>\/)?(?<w>\w)/,
|
679
|
+
'\k<f>!\k<q>\k<w>') }.merge remote_logs
|
680
|
+
|
681
|
+
begin
|
682
|
+
Stuffer.login(@config[:turducken_server], @config[:turducken_username],
|
683
|
+
@config[:turducken_password])
|
684
|
+
suite_result_url = Stuffer.stuff(stuffing)
|
685
|
+
rescue Errno::ECONNREFUSED
|
686
|
+
@logger.error "Unable to connect to Turducken server!"
|
687
|
+
end
|
688
|
+
|
689
|
+
suite_result_url
|
690
|
+
end}
|
691
|
+
|
692
|
+
INDENT_OK[:brace_bracket_paren_combo1] =
|
693
|
+
%Q{[{ :one => your_thing(
|
694
|
+
1)
|
695
|
+
}
|
696
|
+
]}
|
697
|
+
|
698
|
+
INDENT_OK[:paren_comma_combo1] =
|
699
|
+
%Q{def do_something
|
700
|
+
self[:log_file_location] = Time.now.strftime(File.join(Tim::LOG_DIR,
|
701
|
+
"\#{self[:product]}_%Y-%m-%d_%H-%M-%S.log"))
|
702
|
+
|
703
|
+
handle_arguments arg_list
|
704
|
+
end}
|
705
|
+
|
706
|
+
INDENT_OK[:line_ends_with_label] =
|
707
|
+
%Q{options = {
|
708
|
+
actual_trailing_spaces:
|
709
|
+
lexed_line.last_non_line_feed_event.last.size
|
710
|
+
}}
|
711
|
+
|
712
|
+
#-------------------------------------------------------------------------------
|
713
|
+
# INDENT_1 (1 problem)
|
714
|
+
#-------------------------------------------------------------------------------
|
715
|
+
INDENT_1 = {}
|
716
|
+
|
717
|
+
INDENT_1[:class_indented_end] =
|
718
|
+
%Q{class MyClass
|
719
|
+
end}
|
720
|
+
|
721
|
+
INDENT_1[:class_indented_singlestatement] =
|
722
|
+
%Q{class MyClass
|
723
|
+
include Something
|
724
|
+
end}
|
725
|
+
|
726
|
+
INDENT_1[:class_indented_singlestatement_trailing_comment] =
|
727
|
+
%Q{class MyClass
|
728
|
+
include Something # comment
|
729
|
+
end}
|
730
|
+
|
731
|
+
INDENT_1[:class_outdented_singlestatement] =
|
732
|
+
%Q{class MyClass
|
733
|
+
include Something
|
734
|
+
end}
|
735
|
+
|
736
|
+
INDENT_1[:def_indented_end] =
|
737
|
+
%Q{def a
|
738
|
+
end}
|
739
|
+
|
740
|
+
INDENT_1[:def_content_indented_end] =
|
741
|
+
%Q{def a
|
742
|
+
puts "stuff"
|
743
|
+
end}
|
744
|
+
|
745
|
+
INDENT_1[:class_def_content_outdented_end] =
|
746
|
+
%Q{class A
|
747
|
+
def a
|
748
|
+
puts "stuff"
|
749
|
+
end
|
750
|
+
end}
|
751
|
+
|
752
|
+
INDENT_1[:class_def_outdented_content] =
|
753
|
+
%Q{class A
|
754
|
+
def a
|
755
|
+
puts "stuff"
|
756
|
+
end
|
757
|
+
end}
|
758
|
+
|
759
|
+
INDENT_1[:class_method_def_using_self_outdented] =
|
760
|
+
%Q{class A
|
761
|
+
self.my_method
|
762
|
+
puts 'stuff'
|
763
|
+
end
|
764
|
+
end}
|
765
|
+
|
766
|
+
INDENT_1[:case_indented_whens_level] =
|
767
|
+
%Q{def my_method
|
768
|
+
case true
|
769
|
+
when true
|
770
|
+
puts "stuff"
|
771
|
+
when false
|
772
|
+
puts "blah blah"
|
773
|
+
end
|
774
|
+
end}
|
775
|
+
|
776
|
+
INDENT_1[:case_indented_whens_level_trailing_comment] =
|
777
|
+
%Q{def my_method
|
778
|
+
case true # comment
|
779
|
+
when true
|
780
|
+
puts "stuff"
|
781
|
+
when false
|
782
|
+
puts "blah blah"
|
783
|
+
end
|
784
|
+
end}
|
785
|
+
|
786
|
+
INDENT_1[:case_outdented_whens_level] =
|
787
|
+
%Q{def my_method
|
788
|
+
case true
|
789
|
+
when true
|
790
|
+
puts "stuff"
|
791
|
+
when false
|
792
|
+
puts "blah blah"
|
793
|
+
end
|
794
|
+
end}
|
795
|
+
|
796
|
+
INDENT_1[:case_when_indented_whens_level] =
|
797
|
+
%Q{def my_method
|
798
|
+
case true
|
799
|
+
when true
|
800
|
+
puts "stuff"
|
801
|
+
when false
|
802
|
+
puts "blah blah"
|
803
|
+
end
|
804
|
+
end}
|
805
|
+
|
806
|
+
INDENT_1[:case_when_outdented_whens_level] =
|
807
|
+
%Q{def my_method
|
808
|
+
case true
|
809
|
+
when true
|
810
|
+
puts "stuff"
|
811
|
+
when false
|
812
|
+
puts "blah blah"
|
813
|
+
end
|
814
|
+
end}
|
815
|
+
|
816
|
+
INDENT_1[:case_indented_whens_in] =
|
817
|
+
%Q{def my_method
|
818
|
+
case true
|
819
|
+
when true
|
820
|
+
puts "stuff"
|
821
|
+
when false
|
822
|
+
puts "blah blah"
|
823
|
+
end
|
824
|
+
end}
|
825
|
+
|
826
|
+
INDENT_1[:while_do_indented] =
|
827
|
+
%Q{ while true do
|
828
|
+
puts "something"
|
829
|
+
end}
|
830
|
+
|
831
|
+
INDENT_1[:while_do_outdented] =
|
832
|
+
%Q{def my_method
|
833
|
+
while true do
|
834
|
+
puts "something"
|
835
|
+
end
|
836
|
+
end}
|
837
|
+
|
838
|
+
INDENT_1[:while_do_content_outdented] =
|
839
|
+
%Q{def my_method
|
840
|
+
while true do
|
841
|
+
puts "something"
|
842
|
+
end
|
843
|
+
end}
|
844
|
+
|
845
|
+
INDENT_1[:while_do_content_indented] =
|
846
|
+
%Q{def my_method
|
847
|
+
while true do
|
848
|
+
puts "something"
|
849
|
+
end
|
850
|
+
end}
|
851
|
+
|
852
|
+
INDENT_1[:while_do_indented2] =
|
853
|
+
%Q{i = 0;
|
854
|
+
num = 5;
|
855
|
+
|
856
|
+
while i < num do
|
857
|
+
puts("Inside the loop i = \#{i}" );
|
858
|
+
i +=1;
|
859
|
+
end}
|
860
|
+
|
861
|
+
INDENT_1[:while_do_indented2_trailing_comment] =
|
862
|
+
%Q{i = 0;
|
863
|
+
num = 5;
|
864
|
+
|
865
|
+
while i < num do # comment
|
866
|
+
puts("Inside the loop i = \#{i}" );
|
867
|
+
i +=1;
|
868
|
+
end}
|
869
|
+
|
870
|
+
INDENT_1[:until_do_indented] =
|
871
|
+
%Q{i = 0;
|
872
|
+
num = 5;
|
873
|
+
|
874
|
+
until i > num do
|
875
|
+
puts("Inside the loop i = \#{i}" );
|
876
|
+
i +=1;
|
877
|
+
end}
|
878
|
+
|
879
|
+
INDENT_1[:for_do_indented] =
|
880
|
+
%Q{ for i in 1..100 do
|
881
|
+
puts i
|
882
|
+
end}
|
883
|
+
|
884
|
+
INDENT_1[:loop_do_indented] =
|
885
|
+
%Q{ loop do
|
886
|
+
puts 'looping'
|
887
|
+
end}
|
888
|
+
|
889
|
+
INDENT_1[:multi_line_string_first_line_indented] =
|
890
|
+
%Q{def a_method
|
891
|
+
if defined? Term::ANSIColor
|
892
|
+
message << %Q{# \#{(i + 1).to_s.bold}.
|
893
|
+
# * position: \#{position}
|
894
|
+
# * type: \#{problem[:type].to_s.red}
|
895
|
+
# * message: \#{problem[:message].red}
|
896
|
+
}
|
897
|
+
else
|
898
|
+
message << %Q{# \#{(i + 1)}.
|
899
|
+
# * position: \#{position}
|
900
|
+
# * type: \#{problem[:type]}
|
901
|
+
# * message: \#{problem[:message]}
|
902
|
+
}
|
903
|
+
end
|
904
|
+
end}
|
905
|
+
|
906
|
+
INDENT_1[:multi_line_string_first_line_indented_trailing_comment] =
|
907
|
+
%Q{def a_method
|
908
|
+
if defined? Term::ANSIColor # comment
|
909
|
+
message << %Q{# \#{(i + 1).to_s.bold}.
|
910
|
+
# * position: \#{position}
|
911
|
+
# * type: \#{problem[:type].to_s.red}
|
912
|
+
# * message: \#{problem[:message].red}
|
913
|
+
}
|
914
|
+
else
|
915
|
+
message << %Q{# \#{(i + 1)}.
|
916
|
+
# * position: \#{position}
|
917
|
+
# * type: \#{problem[:type]}
|
918
|
+
# * message: \#{problem[:message]}
|
919
|
+
}
|
920
|
+
end
|
921
|
+
end}
|
922
|
+
|
923
|
+
#-------------------------------------------------------------------------------
|
924
|
+
# Operators
|
925
|
+
#-------------------------------------------------------------------------------
|
926
|
+
INDENT_1[:multi_line_andop_first_line_indented] =
|
927
|
+
%Q{def end_of_multiline_string?(lexed_line_output)
|
928
|
+
lexed_line_output.any? { |e| e[1] == :on_tstring_end } &&
|
929
|
+
lexed_line_output.none? { |e| e[1] == :on_tstring_beg }
|
930
|
+
end}
|
931
|
+
|
932
|
+
INDENT_1[:multi_line_andop_first_line_indented_trailing_comment] =
|
933
|
+
%Q{def end_of_multiline_string?(lexed_line_output)
|
934
|
+
lexed_line_output.any? { |e| e[1] == :on_tstring_end } && # comment
|
935
|
+
lexed_line_output.none? { |e| e[1] == :on_tstring_beg }
|
936
|
+
end}
|
937
|
+
|
938
|
+
INDENT_1[:multi_line_andop_second_line_indented] =
|
939
|
+
%Q{def end_of_multiline_string?(lexed_line_output)
|
940
|
+
lexed_line_output.any? { |e| e[1] == :on_tstring_end } &&
|
941
|
+
lexed_line_output.none? { |e| e[1] == :on_tstring_beg }
|
942
|
+
end}
|
943
|
+
|
944
|
+
INDENT_1[:multi_line_string_concat_with_plus_out] =
|
945
|
+
%Q{DVR_SSDP_NOTIFICATION_TEMPLATE = File.dirname(__FILE__) +
|
946
|
+
'/profiles/DVR5000/ssdp_notification.erb'}
|
947
|
+
|
948
|
+
INDENT_1[:multi_line_method_call_end_in] =
|
949
|
+
%Q{def initialize(raw_response)
|
950
|
+
if raw_response.nil? || raw_response.empty?
|
951
|
+
raise RTSP::Error,
|
952
|
+
"#{self.class} received nil string--this shouldn't happen."
|
953
|
+
end
|
954
|
+
end}
|
955
|
+
|
956
|
+
INDENT_1[:multi_line_method_call_ends_with_period_2nd_line_in] =
|
957
|
+
%Q{unless streamer == MulticastStreamer.instance
|
958
|
+
streamer.state = :DISCONNECTED
|
959
|
+
UnicastStreamer.pool << streamer unless UnicastStreamer.pool.
|
960
|
+
member? streamer
|
961
|
+
end}
|
962
|
+
|
963
|
+
INDENT_1[:multi_line_method_call_ends_with_many_periods_last_in] =
|
964
|
+
%Q{my_hashie.first_level.
|
965
|
+
second_level.
|
966
|
+
third_level}
|
967
|
+
|
968
|
+
INDENT_1[:multi_line_method_call_ends_with_many_periods_last_in_trailing_comment] =
|
969
|
+
%Q{my_hashie.first_level.
|
970
|
+
second_level.
|
971
|
+
third_level # comment}
|
972
|
+
|