tailor 0.1.5 → 1.0.0.alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,78 @@
|
|
1
|
+
@wip
|
2
|
+
Feature: Configurable
|
3
|
+
As a Ruby developer
|
4
|
+
I want to be able to configure tailor to my style likings
|
5
|
+
So that tailor only detects the problems that I care about.
|
6
|
+
|
7
|
+
Scenario: No config file exists
|
8
|
+
Given a file named ".tailorrc" should not exist
|
9
|
+
When I successfully run `tailor --show-config`
|
10
|
+
Then the output should contain:
|
11
|
+
"""
|
12
|
+
+---------------------------+------------------+
|
13
|
+
| Configuration |
|
14
|
+
+---------------------------+------------------+
|
15
|
+
| Indentation |
|
16
|
+
+---------------------------+------------------+
|
17
|
+
| spaces | 2 |
|
18
|
+
| allow_hard_tabs | false |
|
19
|
+
| continuation_spaces | 2 |
|
20
|
+
+---------------------------+------------------+
|
21
|
+
| Vertical whitespace |
|
22
|
+
+---------------------------+------------------+
|
23
|
+
| trailing_newlines | 1 |
|
24
|
+
+---------------------------+------------------+
|
25
|
+
"""
|
26
|
+
And the exit status should be 0
|
27
|
+
|
28
|
+
Scenario: Configuration file at ~/.tailorrc is valid YAML
|
29
|
+
Given a file named ".tailorrc" with:
|
30
|
+
"""
|
31
|
+
---
|
32
|
+
:indentation:
|
33
|
+
:spaces: 5
|
34
|
+
:vertical_whitespace:
|
35
|
+
:trailing_newlines: 11
|
36
|
+
"""
|
37
|
+
When I successfully run `tailor --show-config`
|
38
|
+
Then the output should contain:
|
39
|
+
"""
|
40
|
+
+-------------------------+------------------+
|
41
|
+
| Configuration |
|
42
|
+
+-------------------------+------------------+
|
43
|
+
| Indentation |
|
44
|
+
+-------------------------+------------------+
|
45
|
+
| spaces | 5 |
|
46
|
+
+-------------------------+------------------+
|
47
|
+
| Vertical whitespace |
|
48
|
+
+-------------------------+------------------+
|
49
|
+
| trailing_newlines | 11 |
|
50
|
+
+-------------------------+------------------+
|
51
|
+
"""
|
52
|
+
|
53
|
+
Scenario: Pass in configuration file at runtime
|
54
|
+
Given a file named "some_config.yml" with:
|
55
|
+
"""
|
56
|
+
---
|
57
|
+
:indentation:
|
58
|
+
:spaces: 7
|
59
|
+
:vertical_whitespace:
|
60
|
+
:trailing_newlines: 13
|
61
|
+
"""
|
62
|
+
When I successfully run `tailor --config some_config.yml`
|
63
|
+
Then the output should contain:
|
64
|
+
"""
|
65
|
+
+-------------------------+------------------+
|
66
|
+
| Configuration |
|
67
|
+
+-------------------------+------------------+
|
68
|
+
| Indentation |
|
69
|
+
+-------------------------+------------------+
|
70
|
+
| spaces | 7 |
|
71
|
+
+-------------------------+------------------+
|
72
|
+
| Vertical whitespace |
|
73
|
+
+-------------------------+------------------+
|
74
|
+
| trailing_newlines | 13 |
|
75
|
+
+-------------------------+------------------+
|
76
|
+
"""
|
77
|
+
|
78
|
+
|
@@ -0,0 +1,262 @@
|
|
1
|
+
Feature: Horizontal spacing detection
|
2
|
+
As a Ruby developer, I want to be able to detect horizontal spacing
|
3
|
+
problems so that I can fix them.
|
4
|
+
|
5
|
+
Background:
|
6
|
+
Given my configuration file ".tailor" looks like:
|
7
|
+
"""
|
8
|
+
Tailor.config do |config|
|
9
|
+
config.file_set do
|
10
|
+
trailing_newlines 0
|
11
|
+
end
|
12
|
+
end
|
13
|
+
"""
|
14
|
+
|
15
|
+
@bad_files @hard_tabs
|
16
|
+
|
17
|
+
Scenario Outline: Detect hard tabs
|
18
|
+
Given <File> exists without a newline at the end
|
19
|
+
When I run `tailor -d -c .tailor <File>`
|
20
|
+
Then the output should match /Total Problems.*<Count>/
|
21
|
+
And the output should match /position: <Position>/
|
22
|
+
And the output should match /position: <Position 2>/
|
23
|
+
And the exit status should be 1
|
24
|
+
|
25
|
+
Scenarios: Hard tab
|
26
|
+
| File | Position | Position 2 | Count |
|
27
|
+
| h_spacing/1/hard_tab | 2:0 | | 1 |
|
28
|
+
| h_spacing/1/hard_tab_with_spaces | 3:0 | | 1 |
|
29
|
+
| h_spacing/1/hard_tab_with_1_indented_space | 3:0 | | 1 |
|
30
|
+
| h_spacing/2/hard_tab_with_2_indented_spaces | 3:0 | 3:5 | 2 |
|
31
|
+
|
32
|
+
@bad_files @long_lines
|
33
|
+
|
34
|
+
Scenario Outline: Detect long lines
|
35
|
+
Given <File> exists without a newline at the end
|
36
|
+
When I run `tailor -d -c .tailor <File>`
|
37
|
+
Then the output should match /Total Problems.*<Count>/
|
38
|
+
And the output should match /position: <Position>/
|
39
|
+
And the exit status should be 1
|
40
|
+
|
41
|
+
Scenarios:
|
42
|
+
| File | Position | Count |
|
43
|
+
| h_spacing/1/long_line_no_newline | 1:81 | 1 |
|
44
|
+
| h_spacing/1/long_line_newline_at_82 | 1:81 | 1 |
|
45
|
+
|
46
|
+
@good_files @long_lines
|
47
|
+
|
48
|
+
Scenario Outline: Lines under long-line threshold
|
49
|
+
Given <File> exists without a newline at the end
|
50
|
+
When I run `tailor -d -c .tailor <File>`
|
51
|
+
Then the output should match /Total Problems.*0/
|
52
|
+
And the exit status should be 0
|
53
|
+
|
54
|
+
Scenarios:
|
55
|
+
| File |
|
56
|
+
| h_spacing/ok/short_line_no_newline |
|
57
|
+
| h_spacing/ok/short_line_newline_at_81 |
|
58
|
+
|
59
|
+
@bad_files @trailing_spaces
|
60
|
+
|
61
|
+
Scenario Outline: Lines with trailing spaces
|
62
|
+
Given <File> exists without a newline at the end
|
63
|
+
When I run `tailor -d -c .tailor <File>`
|
64
|
+
Then the output should match /Total Problems.*<Count>/
|
65
|
+
And the output should match /position: <Position>/
|
66
|
+
And the exit status should be 1
|
67
|
+
|
68
|
+
Scenarios:
|
69
|
+
| File | Count | Position |
|
70
|
+
| h_spacing/1/empty_line_with_spaces | 1 | 1:2 |
|
71
|
+
| h_spacing/1/empty_line_with_spaces_in_method | 1 | 2:2 |
|
72
|
+
| h_spacing/1/trailing_spaces_on_def | 1 | 1:10 |
|
73
|
+
|
74
|
+
@bad_files @commas
|
75
|
+
|
76
|
+
Scenario Outline: Lines with bad comma spacing
|
77
|
+
Given <File> exists without a newline at the end
|
78
|
+
When I run `tailor -d -c .tailor <File>`
|
79
|
+
Then the output should match /Total Problems.*<Count>/
|
80
|
+
And the output should match /position: <Position>/
|
81
|
+
And the output should match /position: <Position 2>/
|
82
|
+
And the exit status should be 1
|
83
|
+
|
84
|
+
Scenarios:
|
85
|
+
| File | Count | Position | Position 2 |
|
86
|
+
| h_spacing/1/no_space_after_comma | 1 | 1:3 | |
|
87
|
+
| h_spacing/1/two_spaces_after_comma | 1 | 1:3 | |
|
88
|
+
| h_spacing/2/two_spaces_after_comma_twice | 2 | 1:3 | 1:7 |
|
89
|
+
| h_spacing/1/one_space_before_comma | 1 | 1:4 | |
|
90
|
+
| h_spacing/1/two_spaces_before_comma | 1 | 1:3 | |
|
91
|
+
| h_spacing/2/two_spaces_before_comma_twice | 2 | 1:3 | 1:8 |
|
92
|
+
| h_spacing/2/spaces_before_with_trailing_comments | 2 | 2:3 | 3:3 |
|
93
|
+
|
94
|
+
@good_files @commas
|
95
|
+
|
96
|
+
Scenario Outline: Lines with good comma spacing
|
97
|
+
Given <File> exists without a newline at the end
|
98
|
+
When I run `tailor -d -c .tailor <File>`
|
99
|
+
Then the output should match /Total Problems.*0/
|
100
|
+
And the exit status should be 0
|
101
|
+
|
102
|
+
Scenarios:
|
103
|
+
| File |
|
104
|
+
| h_spacing/ok/space_after_comma_in_array |
|
105
|
+
| h_spacing/ok/trailing_comma |
|
106
|
+
| h_spacing/ok/trailing_comma_with_trailing_comment |
|
107
|
+
|
108
|
+
@good_files @braces
|
109
|
+
|
110
|
+
Scenario Outline: Lines with good spacing around braces
|
111
|
+
Given <File> exists without a newline at the end
|
112
|
+
When I run `tailor -d -c .tailor <File>`
|
113
|
+
Then the output should match /Total Problems.*0/
|
114
|
+
And the exit status should be 0
|
115
|
+
|
116
|
+
@single_line
|
117
|
+
Scenarios: Single-line
|
118
|
+
| File |
|
119
|
+
| h_spacing/ok/empty_hash |
|
120
|
+
| h_spacing/ok/single_line_hash |
|
121
|
+
| h_spacing/ok/single_line_hash_lonely_braces |
|
122
|
+
| h_spacing/ok/single_line_block |
|
123
|
+
| h_spacing/ok/single_line_string_interp |
|
124
|
+
| h_spacing/ok/single_line_block_in_string_interp |
|
125
|
+
| h_spacing/ok/empty_hash_in_string_in_block |
|
126
|
+
| h_spacing/ok/string_interp_with_colonop |
|
127
|
+
| h_spacing/ok/hash_as_param_in_parens |
|
128
|
+
|
129
|
+
@multi_line
|
130
|
+
Scenarios: Multi-line
|
131
|
+
| File |
|
132
|
+
| h_spacing/ok/two_line_hash |
|
133
|
+
| h_spacing/ok/two_line_hash_trailing_comment |
|
134
|
+
| h_spacing/ok/three_line_hash |
|
135
|
+
| h_spacing/ok/multi_line_braces_block |
|
136
|
+
| h_spacing/ok/multi_line_qword_using_braces |
|
137
|
+
| h_spacing/ok/empty_hash_in_multi_line_statement |
|
138
|
+
| h_spacing/ok/multi_line_hash_in_multi_line_statement |
|
139
|
+
|
140
|
+
@bad_files @braces
|
141
|
+
|
142
|
+
Scenario Outline: Lines with bad spacing around braces
|
143
|
+
Given <File> exists without a newline at the end
|
144
|
+
When I run `tailor -d -c .tailor <File>`
|
145
|
+
Then the output should match /Total Problems.*<Problems>/
|
146
|
+
And the output should match /position: <Position>/
|
147
|
+
And the output should match /position: <Position 2>/
|
148
|
+
And the exit status should be 1
|
149
|
+
|
150
|
+
@single_line
|
151
|
+
Scenarios: Single-line
|
152
|
+
| File | Position | Position 2 | Problems |
|
153
|
+
| h_spacing/1/single_line_hash_2_spaces_before_lbrace | 1:9 | | 1 |
|
154
|
+
| h_spacing/1/single_line_hash_2_spaces_before_rbrace | 1:25 | | 1 |
|
155
|
+
| h_spacing/1/single_line_hash_2_spaces_after_lbrace | 1:9 | | 1 |
|
156
|
+
| h_spacing/1/single_line_hash_0_spaces_before_lbrace | 1:7 | | 1 |
|
157
|
+
| h_spacing/1/single_line_block_2_spaces_before_lbrace | 1:13 | | 1 |
|
158
|
+
| h_spacing/1/single_line_block_in_string_interp_2_spaces_before_lbrace | 1:27 | | 1 |
|
159
|
+
| h_spacing/1/single_line_block_0_spaces_before_lbrace | 1:11 | | 1 |
|
160
|
+
| h_spacing/1/space_in_empty_hash_in_string_in_block | 1:36 | | 1 |
|
161
|
+
| h_spacing/2/no_space_after_l_before_r_after_string_interp | 1:69 | 1:86 | 2 |
|
162
|
+
| h_spacing/2/no_space_before_consecutive_rbraces | 1:72 | 1:73 | 2 |
|
163
|
+
|
164
|
+
@multi_line
|
165
|
+
Scenarios: Multi-line
|
166
|
+
| File | Position | Position 2 | Problems |
|
167
|
+
| h_spacing/1/two_line_hash_2_spaces_before_lbrace | 2:12 | | 1 |
|
168
|
+
| h_spacing/1/two_line_hash_2_spaces_before_rbrace | 2:28 | | 1 |
|
169
|
+
| h_spacing/1/two_line_hash_2_spaces_before_lbrace_lonely_braces | 2:12 | | 1 |
|
170
|
+
| h_spacing/1/two_line_braces_block_2_spaces_before_lbrace | 1:13 | | 1 |
|
171
|
+
| h_spacing/1/two_line_braces_block_0_spaces_before_lbrace_trailing_comment | 1:11 | | 1 |
|
172
|
+
|
173
|
+
@good_files @brackets
|
174
|
+
|
175
|
+
Scenario Outline: Lines with good spacing around brackets
|
176
|
+
Given <File> exists without a newline at the end
|
177
|
+
When I run `tailor -d -c .tailor <File>`
|
178
|
+
Then the output should match /Total Problems.*0/
|
179
|
+
And the exit status should be 0
|
180
|
+
|
181
|
+
@single_line
|
182
|
+
Scenarios: Single-line
|
183
|
+
| File |
|
184
|
+
| h_spacing/ok/empty_array |
|
185
|
+
| h_spacing/ok/simple_array |
|
186
|
+
| h_spacing/ok/two_d_array |
|
187
|
+
| h_spacing/ok/hash_key_reference |
|
188
|
+
| h_spacing/ok/array_of_hashes |
|
189
|
+
| h_spacing/ok/array_of_symbols |
|
190
|
+
|
191
|
+
@multi_line
|
192
|
+
Scenarios: Multi-line
|
193
|
+
| File |
|
194
|
+
| h_spacing/ok/simple_array_lonely_brackets |
|
195
|
+
| h_spacing/ok/simple_nested_array_lonely_brackets |
|
196
|
+
| h_spacing/ok/empty_array_in_multi_line_statement |
|
197
|
+
|
198
|
+
@bad_files @brackets
|
199
|
+
|
200
|
+
Scenario Outline: Lines with bad spacing around brackets
|
201
|
+
Given <File> exists without a newline at the end
|
202
|
+
When I run `tailor -d -c .tailor <File>`
|
203
|
+
Then the output should match /Total Problems.*<Problems>/
|
204
|
+
And the output should match /position: <Position>/
|
205
|
+
And the output should match /position: <Position 2>/
|
206
|
+
And the exit status should be 1
|
207
|
+
|
208
|
+
@single_line
|
209
|
+
Scenarios: Single-line
|
210
|
+
| File | Position | Position 2 | Problems |
|
211
|
+
| h_spacing/1/space_in_empty_array | 1:1 | | 1 |
|
212
|
+
| h_spacing/1/simple_array_space_after_lbracket | 1:1 | | 1 |
|
213
|
+
| h_spacing/1/simple_array_space_before_rbracket | 1:9 | | 1 |
|
214
|
+
| h_spacing/1/hash_key_ref_space_before_rbracket | 1:11 | | 1 |
|
215
|
+
| h_spacing/1/hash_key_ref_space_after_lbracket | 1:6 | | 1 |
|
216
|
+
| h_spacing/2/two_d_array_space_after_lbrackets | 1:1 | 1:14 | 2 |
|
217
|
+
| h_spacing/2/two_d_array_space_before_rbrackets | 1:10 | 1:30 | 2 |
|
218
|
+
|
219
|
+
@good_files @parens
|
220
|
+
|
221
|
+
Scenario Outline: Lines with good spacing around parens
|
222
|
+
Given <File> exists without a newline at the end
|
223
|
+
When I run `tailor -d -c .tailor <File>`
|
224
|
+
Then the output should match /Total Problems.*0/
|
225
|
+
And the exit status should be 0
|
226
|
+
|
227
|
+
@single_line
|
228
|
+
Scenarios: Single-line
|
229
|
+
| File |
|
230
|
+
| h_spacing/ok/empty_parens |
|
231
|
+
| h_spacing/ok/simple_method_call |
|
232
|
+
|
233
|
+
@multi_line
|
234
|
+
Scenarios: Multi-line
|
235
|
+
| File |
|
236
|
+
| h_spacing/ok/multi_line_method_call |
|
237
|
+
| h_spacing/ok/multi_line_method_call_lonely_parens |
|
238
|
+
|
239
|
+
@bad_files @parens
|
240
|
+
|
241
|
+
Scenario Outline: Lines with bad spacing around parens
|
242
|
+
Given <File> exists without a newline at the end
|
243
|
+
When I run `tailor -d -c .tailor <File>`
|
244
|
+
Then the output should match /Total Problems.*<Problems>/
|
245
|
+
And the output should match /position: <Position>/
|
246
|
+
And the output should match /position: <Position 2>/
|
247
|
+
And the exit status should be 1
|
248
|
+
|
249
|
+
@single_line
|
250
|
+
Scenarios: Single-line
|
251
|
+
| File | Position | Position 2 | Problems |
|
252
|
+
| h_spacing/1/simple_method_call_space_after_lparen | 1:6 | | 1 |
|
253
|
+
| h_spacing/1/simple_method_call_space_before_rparen | 1:15 | | 1 |
|
254
|
+
| h_spacing/1/method_call_space_after_lparen_trailing_comment | 1:6 | | 1 |
|
255
|
+
| h_spacing/2/method_call_space_after_lparen_before_rparen_trailing_comment | 1:6 | 1:16 | 2 |
|
256
|
+
|
257
|
+
@multi_line
|
258
|
+
Scenarios: Multi-line
|
259
|
+
| File | Position | Position 2 | Problems |
|
260
|
+
| h_spacing/1/multi_line_method_call_space_after_lparen | 1:6 | | 1 |
|
261
|
+
| h_spacing/1/multi_line_method_call_space_after_lparen_trailing_comment | 1:6 | | 1 |
|
262
|
+
|
@@ -1,22 +1,18 @@
|
|
1
|
-
|
1
|
+
@wip
|
2
|
+
Feature: Indentation check
|
3
|
+
As a Ruby developer
|
4
|
+
I want to check the indentation of my Ruby code
|
5
|
+
So that I follow Ruby indentation conventions.
|
2
6
|
|
3
|
-
Scenario:
|
4
|
-
Given
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
And the line 2 is a "def" statement
|
16
|
-
When I run the checker on the project
|
17
|
-
Then the level of line 1 should be 0.0
|
18
|
-
And the level of line 2 should be 1.0
|
19
|
-
And the level of line 3 should be 2.0
|
20
|
-
And the level of line 4 should be 1.0
|
21
|
-
And the level of line 5 should be 0.0
|
22
|
-
|
7
|
+
Scenario: No indentation problems with this project
|
8
|
+
Given my configuration file ".tailor" looks like:
|
9
|
+
"""
|
10
|
+
Tailor.config do |config|
|
11
|
+
config.file_set do
|
12
|
+
trailing_newlines 0
|
13
|
+
end
|
14
|
+
end
|
15
|
+
"""
|
16
|
+
When I successfully run `tailor -d -c .tailor ../../lib`
|
17
|
+
Then the output should contain "problem count: 0"
|
18
|
+
And the exit status should be 0
|
@@ -0,0 +1,90 @@
|
|
1
|
+
@indentation
|
2
|
+
Feature: Indentation check on bad fails without trailing newlines
|
3
|
+
|
4
|
+
Background:
|
5
|
+
Given my configuration file ".tailor" looks like:
|
6
|
+
"""
|
7
|
+
Tailor.config do |config|
|
8
|
+
config.file_set do
|
9
|
+
trailing_newlines 0
|
10
|
+
end
|
11
|
+
end
|
12
|
+
"""
|
13
|
+
|
14
|
+
@bad_files
|
15
|
+
Scenario Outline: Detect singular problems on poorly indented files
|
16
|
+
Given <File> exists without a newline at the end
|
17
|
+
When I run `tailor -d -c .tailor <File>`
|
18
|
+
Then the output should match /Total Problems.*1/
|
19
|
+
And the output should match /position: <Position>/
|
20
|
+
And the exit status should be 1
|
21
|
+
|
22
|
+
@multi_line
|
23
|
+
Scenarios: 1 problem with classes
|
24
|
+
| File | Position |
|
25
|
+
| indent/1/class_indented_end | 2:1 |
|
26
|
+
| indent/1/class_method_def_using_self_outdented | 2:1 |
|
27
|
+
|
28
|
+
|
29
|
+
@multi_line
|
30
|
+
Scenarios: 1 problem with single-line statement
|
31
|
+
| File | Position |
|
32
|
+
| indent/1/class_indented_singlestatement | 2:3 |
|
33
|
+
| indent/1/class_indented_singlestatement_trailing_comment | 2:3 |
|
34
|
+
| indent/1/class_outdented_singlestatement | 2:1 |
|
35
|
+
| indent/1/class_def_outdented_content | 3:3 |
|
36
|
+
|
37
|
+
@multi_line
|
38
|
+
Scenarios: 1 problem with def
|
39
|
+
| File | Position |
|
40
|
+
| indent/1/def_indented_end | 2:1 |
|
41
|
+
| indent/1/def_content_indented_end | 3:1 |
|
42
|
+
| indent/1/class_def_content_outdented_end | 4:1 |
|
43
|
+
|
44
|
+
@multi_line
|
45
|
+
Scenarios: 1 problem with case
|
46
|
+
| File | Position |
|
47
|
+
| indent/1/case_indented_whens_level | 2:3 |
|
48
|
+
| indent/1/case_indented_whens_level_trailing_comment | 2:3 |
|
49
|
+
| indent/1/case_outdented_whens_level | 2:1 |
|
50
|
+
| indent/1/case_when_indented_whens_level | 3:3 |
|
51
|
+
| indent/1/case_when_outdented_whens_level | 3:1 |
|
52
|
+
| indent/1/case_indented_whens_in | 2:3 |
|
53
|
+
|
54
|
+
@multi_line
|
55
|
+
Scenarios: 1 problem with 'do' loop
|
56
|
+
| File | Position |
|
57
|
+
| indent/1/while_do_indented | 1:1 |
|
58
|
+
| indent/1/while_do_indented2 | 4:1 |
|
59
|
+
| indent/1/while_do_indented2_trailing_comment | 4:1 |
|
60
|
+
| indent/1/while_do_outdented | 2:1 |
|
61
|
+
| indent/1/while_do_content_indented | 3:5 |
|
62
|
+
| indent/1/while_do_content_outdented | 3:3 |
|
63
|
+
| indent/1/until_do_indented | 4:1 |
|
64
|
+
| indent/1/for_do_indented | 1:1 |
|
65
|
+
| indent/1/loop_do_indented | 1:1 |
|
66
|
+
|
67
|
+
@multi_line
|
68
|
+
Scenarios: 1 problem with multi-line string
|
69
|
+
| File | Position |
|
70
|
+
| indent/1/multi_line_string_first_line_indented | 2:3 |
|
71
|
+
| indent/1/multi_line_string_first_line_indented_trailing_comment | 2:3 |
|
72
|
+
|
73
|
+
@multi_line
|
74
|
+
Scenarios: 1 problem with multi-line operator use
|
75
|
+
| File | Position |
|
76
|
+
| indent/1/multi_line_andop_first_line_indented | 2:3 |
|
77
|
+
| indent/1/multi_line_andop_first_line_indented_trailing_comment | 2:3 |
|
78
|
+
| indent/1/multi_line_andop_second_line_indented | 3:5 |
|
79
|
+
| indent/1/multi_line_string_concat_with_plus_out | 2:1 |
|
80
|
+
|
81
|
+
@multi_line
|
82
|
+
Scenarios: 1 problem with multi-line method ending with period
|
83
|
+
| File | Position |
|
84
|
+
| indent/1/multi_line_method_call_end_in | 5:3 |
|
85
|
+
| indent/1/multi_line_method_call_ends_with_period_2nd_line_in | 4:5 |
|
86
|
+
| indent/1/multi_line_method_call_ends_with_many_periods_last_in | 3:4 |
|
87
|
+
| indent/1/multi_line_method_call_ends_with_many_periods_last_in_trailing_comment | 3:4 |
|
88
|
+
|
89
|
+
|
90
|
+
|