tailor 1.2.1 → 1.3.0
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +30 -28
- data/History.md +257 -0
- data/README.md +486 -0
- data/Rakefile +1 -9
- data/lib/ext/string_ext.rb +1 -1
- data/lib/tailor/cli.rb +3 -1
- data/lib/tailor/cli/options.rb +59 -39
- data/lib/tailor/configuration.rb +8 -5
- data/lib/tailor/configuration/file_set.rb +1 -3
- data/lib/tailor/configuration/style.rb +2 -0
- data/lib/tailor/critic.rb +2 -2
- data/lib/tailor/formatters/text.rb +17 -16
- data/lib/tailor/lexed_line.rb +2 -4
- data/lib/tailor/lexer.rb +9 -9
- data/lib/tailor/lexer/lexer_constants.rb +32 -32
- data/lib/tailor/lexer/token.rb +8 -10
- data/lib/tailor/logger.rb +1 -1
- data/lib/tailor/problem.rb +4 -1
- data/lib/tailor/rake_task.rb +4 -1
- data/lib/tailor/reporter.rb +3 -3
- data/lib/tailor/ruler.rb +2 -2
- data/lib/tailor/rulers/allow_camel_case_methods_ruler.rb +2 -2
- data/lib/tailor/rulers/allow_hard_tabs_ruler.rb +1 -1
- data/lib/tailor/rulers/allow_invalid_ruby_ruler.rb +1 -1
- data/lib/tailor/rulers/allow_screaming_snake_case_classes_ruler.rb +2 -2
- data/lib/tailor/rulers/indentation_spaces_ruler.rb +24 -22
- data/lib/tailor/rulers/indentation_spaces_ruler/indentation_manager.rb +13 -13
- data/lib/tailor/rulers/max_code_lines_in_class_ruler.rb +2 -2
- data/lib/tailor/rulers/max_code_lines_in_method_ruler.rb +2 -2
- data/lib/tailor/rulers/spaces_after_comma_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_after_conditional_ruler.rb +48 -0
- data/lib/tailor/rulers/spaces_after_lbrace_ruler.rb +8 -8
- data/lib/tailor/rulers/spaces_after_lbracket_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_after_lparen_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_before_comma_ruler.rb +2 -2
- data/lib/tailor/rulers/spaces_before_lbrace_ruler.rb +4 -4
- data/lib/tailor/rulers/spaces_before_rbrace_ruler.rb +9 -9
- data/lib/tailor/rulers/spaces_before_rbracket_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_before_rparen_ruler.rb +6 -6
- data/lib/tailor/rulers/spaces_in_empty_braces_ruler.rb +1 -1
- data/lib/tailor/rulers/trailing_newlines_ruler.rb +2 -2
- data/lib/tailor/tailorrc.erb +1 -1
- data/lib/tailor/version.rb +1 -1
- data/spec/functional/conditional_spacing_spec.rb +149 -0
- data/spec/functional/configuration_spec.rb +36 -26
- data/spec/functional/horizontal_spacing/braces_spec.rb +1 -1
- data/spec/functional/horizontal_spacing/brackets_spec.rb +14 -14
- data/spec/functional/horizontal_spacing/comma_spacing_spec.rb +8 -8
- data/spec/functional/horizontal_spacing/hard_tabs_spec.rb +13 -13
- data/spec/functional/horizontal_spacing/long_lines_spec.rb +6 -6
- data/spec/functional/horizontal_spacing/long_methods_spec.rb +55 -0
- data/spec/functional/horizontal_spacing/parens_spec.rb +17 -17
- data/spec/functional/horizontal_spacing/trailing_whitespace_spec.rb +8 -8
- data/spec/functional/horizontal_spacing_spec.rb +11 -11
- data/spec/functional/indentation_spacing/bad_indentation_spec.rb +83 -83
- data/spec/functional/indentation_spacing_spec.rb +10 -10
- data/spec/functional/naming/camel_case_methods_spec.rb +6 -6
- data/spec/functional/naming/screaming_snake_case_classes_spec.rb +10 -10
- data/spec/functional/naming_spec.rb +3 -3
- data/spec/functional/vertical_spacing/class_length_spec.rb +6 -6
- data/spec/functional/vertical_spacing/method_length_spec.rb +6 -6
- data/spec/functional/vertical_spacing_spec.rb +3 -3
- data/spec/support/conditional_spacing_cases.rb +37 -0
- data/spec/support/good_indentation_cases.rb +1 -1
- data/spec/unit/tailor/cli/options_spec.rb +50 -0
- data/spec/unit/tailor/cli_spec.rb +3 -3
- data/spec/unit/tailor/composite_observable_spec.rb +8 -8
- data/spec/unit/tailor/configuration/file_set_spec.rb +2 -2
- data/spec/unit/tailor/configuration/style_spec.rb +30 -29
- data/spec/unit/tailor/configuration_spec.rb +39 -24
- data/spec/unit/tailor/critic_spec.rb +18 -17
- data/spec/unit/tailor/formatter_spec.rb +15 -15
- data/spec/unit/tailor/formatters/yaml_spec.rb +1 -1
- data/spec/unit/tailor/lexed_line_spec.rb +258 -258
- data/spec/unit/tailor/lexer/token_spec.rb +11 -11
- data/spec/unit/tailor/lexer_spec.rb +35 -35
- data/spec/unit/tailor/problem_spec.rb +13 -13
- data/spec/unit/tailor/reporter_spec.rb +19 -18
- data/spec/unit/tailor/ruler_spec.rb +15 -15
- data/spec/unit/tailor/rulers/indentation_spaces_ruler/indentation_manager_spec.rb +72 -72
- data/spec/unit/tailor/rulers/indentation_spaces_ruler_spec.rb +32 -32
- data/spec/unit/tailor/rulers/spaces_after_comma_ruler_spec.rb +8 -8
- data/spec/unit/tailor/rulers/spaces_after_lbrace_ruler_spec.rb +36 -36
- data/spec/unit/tailor/rulers/spaces_before_lbrace_ruler_spec.rb +14 -14
- data/spec/unit/tailor/rulers/spaces_before_rbrace_ruler_spec.rb +14 -14
- data/spec/unit/tailor/rulers_spec.rb +2 -2
- data/spec/unit/tailor/version_spec.rb +1 -1
- data/spec/unit/tailor_spec.rb +4 -4
- data/tailor.gemspec +1 -1
- metadata +16 -9
- data/History.rdoc +0 -189
- data/README.rdoc +0 -422
- data/spec/unit/tailor/options_spec.rb +0 -6
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'tailor/rulers'
|
3
3
|
|
4
4
|
describe Tailor::Rulers do
|
5
|
-
it
|
5
|
+
it 'requires all of its children' do
|
6
6
|
# if it does one, it'll have done them all.
|
7
7
|
subject.const_get('AllowCamelCaseMethodsRuler').should be_true
|
8
8
|
end
|
data/spec/unit/tailor_spec.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'tailor'
|
3
3
|
|
4
4
|
describe Tailor do
|
5
5
|
before { Tailor::Logger.log = false }
|
6
6
|
|
7
|
-
describe
|
8
|
-
it
|
7
|
+
describe '.config' do
|
8
|
+
it 'creates a new Configuration object' do
|
9
9
|
Tailor::Configuration.should_receive(:new)
|
10
10
|
Tailor.config
|
11
11
|
end
|
12
12
|
|
13
|
-
it
|
13
|
+
it 'returns a Configuration object' do
|
14
14
|
Tailor.config.should be_a Tailor::Configuration
|
15
15
|
end
|
16
16
|
end
|
data/tailor.gemspec
CHANGED
@@ -20,7 +20,7 @@ project, whatever style that may be.
|
|
20
20
|
s.email = "steve.loveless@gmail.com"
|
21
21
|
s.homepage = "http://github.com/turboladen/tailor"
|
22
22
|
|
23
|
-
s.extra_rdoc_files = %w(History.
|
23
|
+
s.extra_rdoc_files = %w(History.md README.md)
|
24
24
|
s.files = `git ls-files`.split("\n")
|
25
25
|
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
|
26
26
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tailor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Loveless
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: log_switch
|
@@ -177,8 +177,8 @@ executables:
|
|
177
177
|
- tailor
|
178
178
|
extensions: []
|
179
179
|
extra_rdoc_files:
|
180
|
-
- History.
|
181
|
-
- README.
|
180
|
+
- History.md
|
181
|
+
- README.md
|
182
182
|
files:
|
183
183
|
- .gemtest
|
184
184
|
- .gitignore
|
@@ -188,8 +188,8 @@ files:
|
|
188
188
|
- .travis.yml
|
189
189
|
- Gemfile
|
190
190
|
- Gemfile.lock
|
191
|
-
- History.
|
192
|
-
- README.
|
191
|
+
- History.md
|
192
|
+
- README.md
|
193
193
|
- Rakefile
|
194
194
|
- bin/tailor
|
195
195
|
- features/configurable.feature
|
@@ -236,6 +236,7 @@ files:
|
|
236
236
|
- lib/tailor/rulers/max_code_lines_in_method_ruler.rb
|
237
237
|
- lib/tailor/rulers/max_line_length_ruler.rb
|
238
238
|
- lib/tailor/rulers/spaces_after_comma_ruler.rb
|
239
|
+
- lib/tailor/rulers/spaces_after_conditional_ruler.rb
|
239
240
|
- lib/tailor/rulers/spaces_after_lbrace_ruler.rb
|
240
241
|
- lib/tailor/rulers/spaces_after_lbracket_ruler.rb
|
241
242
|
- lib/tailor/rulers/spaces_after_lparen_ruler.rb
|
@@ -249,12 +250,14 @@ files:
|
|
249
250
|
- lib/tailor/runtime_error.rb
|
250
251
|
- lib/tailor/tailorrc.erb
|
251
252
|
- lib/tailor/version.rb
|
253
|
+
- spec/functional/conditional_spacing_spec.rb
|
252
254
|
- spec/functional/configuration_spec.rb
|
253
255
|
- spec/functional/horizontal_spacing/braces_spec.rb
|
254
256
|
- spec/functional/horizontal_spacing/brackets_spec.rb
|
255
257
|
- spec/functional/horizontal_spacing/comma_spacing_spec.rb
|
256
258
|
- spec/functional/horizontal_spacing/hard_tabs_spec.rb
|
257
259
|
- spec/functional/horizontal_spacing/long_lines_spec.rb
|
260
|
+
- spec/functional/horizontal_spacing/long_methods_spec.rb
|
258
261
|
- spec/functional/horizontal_spacing/parens_spec.rb
|
259
262
|
- spec/functional/horizontal_spacing/trailing_whitespace_spec.rb
|
260
263
|
- spec/functional/horizontal_spacing_spec.rb
|
@@ -269,12 +272,14 @@ files:
|
|
269
272
|
- spec/functional/vertical_spacing_spec.rb
|
270
273
|
- spec/spec_helper.rb
|
271
274
|
- spec/support/bad_indentation_cases.rb
|
275
|
+
- spec/support/conditional_spacing_cases.rb
|
272
276
|
- spec/support/good_indentation_cases.rb
|
273
277
|
- spec/support/horizontal_spacing_cases.rb
|
274
278
|
- spec/support/naming_cases.rb
|
275
279
|
- spec/support/rake_task_config_no_problems.rb
|
276
280
|
- spec/support/rake_task_config_problems.rb
|
277
281
|
- spec/support/vertical_spacing_cases.rb
|
282
|
+
- spec/unit/tailor/cli/options_spec.rb
|
278
283
|
- spec/unit/tailor/cli_spec.rb
|
279
284
|
- spec/unit/tailor/composite_observable_spec.rb
|
280
285
|
- spec/unit/tailor/configuration/file_set_spec.rb
|
@@ -286,7 +291,6 @@ files:
|
|
286
291
|
- spec/unit/tailor/lexed_line_spec.rb
|
287
292
|
- spec/unit/tailor/lexer/token_spec.rb
|
288
293
|
- spec/unit/tailor/lexer_spec.rb
|
289
|
-
- spec/unit/tailor/options_spec.rb
|
290
294
|
- spec/unit/tailor/problem_spec.rb
|
291
295
|
- spec/unit/tailor/reporter_spec.rb
|
292
296
|
- spec/unit/tailor/ruler_spec.rb
|
@@ -319,7 +323,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
319
323
|
version: '0'
|
320
324
|
requirements: []
|
321
325
|
rubyforge_project:
|
322
|
-
rubygems_version: 2.0.
|
326
|
+
rubygems_version: 2.0.3
|
323
327
|
signing_key:
|
324
328
|
specification_version: 4
|
325
329
|
summary: A Ruby style & complexity measurer
|
@@ -335,12 +339,14 @@ test_files:
|
|
335
339
|
- features/support/legacy/long_file_with_indentation.rb
|
336
340
|
- features/support/world.rb
|
337
341
|
- features/valid_ruby.feature
|
342
|
+
- spec/functional/conditional_spacing_spec.rb
|
338
343
|
- spec/functional/configuration_spec.rb
|
339
344
|
- spec/functional/horizontal_spacing/braces_spec.rb
|
340
345
|
- spec/functional/horizontal_spacing/brackets_spec.rb
|
341
346
|
- spec/functional/horizontal_spacing/comma_spacing_spec.rb
|
342
347
|
- spec/functional/horizontal_spacing/hard_tabs_spec.rb
|
343
348
|
- spec/functional/horizontal_spacing/long_lines_spec.rb
|
349
|
+
- spec/functional/horizontal_spacing/long_methods_spec.rb
|
344
350
|
- spec/functional/horizontal_spacing/parens_spec.rb
|
345
351
|
- spec/functional/horizontal_spacing/trailing_whitespace_spec.rb
|
346
352
|
- spec/functional/horizontal_spacing_spec.rb
|
@@ -355,12 +361,14 @@ test_files:
|
|
355
361
|
- spec/functional/vertical_spacing_spec.rb
|
356
362
|
- spec/spec_helper.rb
|
357
363
|
- spec/support/bad_indentation_cases.rb
|
364
|
+
- spec/support/conditional_spacing_cases.rb
|
358
365
|
- spec/support/good_indentation_cases.rb
|
359
366
|
- spec/support/horizontal_spacing_cases.rb
|
360
367
|
- spec/support/naming_cases.rb
|
361
368
|
- spec/support/rake_task_config_no_problems.rb
|
362
369
|
- spec/support/rake_task_config_problems.rb
|
363
370
|
- spec/support/vertical_spacing_cases.rb
|
371
|
+
- spec/unit/tailor/cli/options_spec.rb
|
364
372
|
- spec/unit/tailor/cli_spec.rb
|
365
373
|
- spec/unit/tailor/composite_observable_spec.rb
|
366
374
|
- spec/unit/tailor/configuration/file_set_spec.rb
|
@@ -372,7 +380,6 @@ test_files:
|
|
372
380
|
- spec/unit/tailor/lexed_line_spec.rb
|
373
381
|
- spec/unit/tailor/lexer/token_spec.rb
|
374
382
|
- spec/unit/tailor/lexer_spec.rb
|
375
|
-
- spec/unit/tailor/options_spec.rb
|
376
383
|
- spec/unit/tailor/problem_spec.rb
|
377
384
|
- spec/unit/tailor/reporter_spec.rb
|
378
385
|
- spec/unit/tailor/ruler_spec.rb
|
data/History.rdoc
DELETED
@@ -1,189 +0,0 @@
|
|
1
|
-
=== 1.2.1 2013-03-12
|
2
|
-
|
3
|
-
* gh-134[https://github.com/turboladen/tailor/issues/134]
|
4
|
-
* Turned logging off by default when using bin/tailor. This was a regression
|
5
|
-
introduced in 1.2.0.
|
6
|
-
|
7
|
-
=== 1.2.0 2013-03-06
|
8
|
-
|
9
|
-
* gh-119[https://github.com/turboladen/tailor/issues/119]
|
10
|
-
* AllowInvalidRubyRuler now uses Gem.ruby to use the ruby that tailor was
|
11
|
-
run with.
|
12
|
-
* gh-130[https://github.com/turboladen/tailor/issues/130]
|
13
|
-
* AllowInvalidRubyRuler now handles file names with spaces in them.
|
14
|
-
* gh-131[https://github.com/turboladen/tailor/issues/131]
|
15
|
-
* Added YAML output formatter. Thanks @leandronsp!
|
16
|
-
* gh-133[https://github.com/turboladen/tailor/issues/133]
|
17
|
-
* Added support for Ruby 2.0.0-p0. ...which is actually just accounting for
|
18
|
-
a {fix to Ripper}[https://bugs.ruby-lang.org/issues/6211] that finally got
|
19
|
-
merged in to a Ruby release.
|
20
|
-
|
21
|
-
=== 1.1.5 2013-01-30
|
22
|
-
|
23
|
-
* gh-127[https://github.com/turboladen/tailor/issues/127]
|
24
|
-
* The last fix had SystemExit being displayed to the user at all times (since
|
25
|
-
it should've been getting rescued from when the program exits). Properly
|
26
|
-
rescuing this now for Rake tasks, so it now behaves just like bin/tailor in
|
27
|
-
this respect.
|
28
|
-
|
29
|
-
=== 1.1.4 2013-01-29
|
30
|
-
|
31
|
-
* gh-127[https://github.com/turboladen/tailor/issues/127]
|
32
|
-
* RakeTask now actually does something (works).
|
33
|
-
* tailor should now abort (and let you know) when it can't find the config file
|
34
|
-
that you told it to use. Previously, it would just fall back to default
|
35
|
-
settings.
|
36
|
-
|
37
|
-
=== 1.1.3 2013-01-28
|
38
|
-
|
39
|
-
* gh-121[https://github.com/turboladen/tailor/issues/121]
|
40
|
-
* Camel case methods are now detected properly when used inside of a class.
|
41
|
-
Thanks @jasonku!
|
42
|
-
|
43
|
-
=== 1.1.2 2012-06-01
|
44
|
-
|
45
|
-
* gh-101[https://github.com/turboladen/tailor/issues/101]
|
46
|
-
* Tailor now handles code that uses backslashes to break up statements to
|
47
|
-
multiple lines. Note that this is somewhat of a hack, since Ripper does not
|
48
|
-
tokenize these backslashes--it actually just treats what we see as 2 lines
|
49
|
-
of code as a single line of code. In order to preserve line numbering and
|
50
|
-
indentation tracking, tailor replaces the backslash with a special comment
|
51
|
-
that it can detect and handle accordingly. While this isn't ideal, given
|
52
|
-
the current design, it seemed like the way to deal with this.
|
53
|
-
* gh-103[https://github.com/turboladen/tailor/issues/103]
|
54
|
-
* Tailor now properly handles string interpolation inside string
|
55
|
-
interpolation.
|
56
|
-
|
57
|
-
=== 1.1.1 2012-05-31
|
58
|
-
|
59
|
-
* gh-110[https://github.com/turboladen/tailor/issues/110]
|
60
|
-
* Tailor now exits with 0 if non-error problems are found.
|
61
|
-
|
62
|
-
=== 1.1.0 2012-05-07
|
63
|
-
|
64
|
-
* gh-89[https://github.com/turboladen/tailor/issues/89]
|
65
|
-
* You can now use {Tailor::RakeTask} to create a Rake task.
|
66
|
-
* gh-100[https://github.com/turboladen/tailor/issues/100]
|
67
|
-
* Added {Tailor::Configuration#recursive_file_set}. This lets you do the
|
68
|
-
following in your config file, which will recursively match all files in
|
69
|
-
your current path that end with '_spec.rb':
|
70
|
-
|
71
|
-
Tailor.config do |config|
|
72
|
-
config.recursive_file_set '*_spec.rb', :unit_tests do |style|
|
73
|
-
style.max_line_length 90, level: :warn
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
...which is equivalent to:
|
78
|
-
|
79
|
-
Tailor.config do |config|
|
80
|
-
config.file_set '*/**/*_spec.rb', :unit_tests do |style|
|
81
|
-
style.max_line_length 90, level: :warn
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
* gh-107[https://github.com/turboladen/tailor/issues/107]
|
86
|
-
* Fixed --no-color option.
|
87
|
-
* gh-108[https://github.com/turboladen/tailor/issues/108]
|
88
|
-
* Fixed --create-config, which created style level options with a missing ':'
|
89
|
-
for the Hash value.
|
90
|
-
* Configuration files now don't force you to use the :default file set. If you
|
91
|
-
don't specify any file sets, then the default is used; if you specify file
|
92
|
-
sets, it uses what you specify.
|
93
|
-
* CLI options now override config file options for all file sets (previously,
|
94
|
-
only the :default file set's option would get overridden by the CLI option).
|
95
|
-
|
96
|
-
=== 1.0.1 2012-04-23
|
97
|
-
|
98
|
-
* gh-104[https://github.com/turboladen/tailor/issues/104]:
|
99
|
-
* Fixed incorrect rendering of config file when using `tailor --create-config`.
|
100
|
-
|
101
|
-
=== 1.0.0 2012-04-17
|
102
|
-
|
103
|
-
* Big update to config file.
|
104
|
-
* Fix for indentation checking on nested Hashes.
|
105
|
-
* Fix for overriding default style in config files.
|
106
|
-
* Fix to exit after --show-config.
|
107
|
-
* gh-99[https://github.com/turboladen/tailor/issues/99]
|
108
|
-
* Now warns by default if `ruby -c [file]` fails.
|
109
|
-
* gh-93[https://github.com/turboladen/tailor/issues/93]
|
110
|
-
* 2 'end's on the same line don't cause an indentation error.
|
111
|
-
* gh-92[https://github.com/turboladen/tailor/issues/92]
|
112
|
-
* Users can now turn off a ruler...
|
113
|
-
* CLI: <tt>--my-option off</tt>
|
114
|
-
* Config file: <tt>my_option 1, level: :off</tt>
|
115
|
-
* gh-86[https://github.com/turboladen/tailor/issues/86]
|
116
|
-
* Indentation checking implemented.
|
117
|
-
* gh-68[https://github.com/turboladen/tailor/issues/68]
|
118
|
-
* Spaces aren't improperly detected after a token when the line ends with a
|
119
|
-
backslash.
|
120
|
-
|
121
|
-
=== 1.0.0.alpha2 2012-04-09
|
122
|
-
|
123
|
-
* Fix for when not using a config file.
|
124
|
-
|
125
|
-
=== 1.0.0.alpha 2012-04-09
|
126
|
-
|
127
|
-
* Complete rewrite.
|
128
|
-
* New style checks:
|
129
|
-
* Indentation.
|
130
|
-
* LOC count in a class.
|
131
|
-
* LOC count in a method.
|
132
|
-
* Trailing newlines at EOF.
|
133
|
-
* Other new features:
|
134
|
-
* Configuration file use--both .tailor and ~/.tailorrc--lets you specify
|
135
|
-
groups of files.
|
136
|
-
* Turn checks off via CLI options.
|
137
|
-
|
138
|
-
=== 0.1.5 2011-09-27
|
139
|
-
|
140
|
-
* Fixed post install message to use heredoc instead of %w (<-wth was I thinking?)
|
141
|
-
|
142
|
-
=== 0.1.4 2011-09-27
|
143
|
-
|
144
|
-
* gh-81: Return exit status of 1 if problems were found.
|
145
|
-
* Fixed Rakefile and .gemspec. [sergio-fry]
|
146
|
-
* Removed dependency on hoe for gem building.
|
147
|
-
* Added -v/--version to bin/tailor.
|
148
|
-
* Fixed documenatation indentation.
|
149
|
-
|
150
|
-
=== 0.1.3 2010-12-14
|
151
|
-
|
152
|
-
* Added check for .erb files.
|
153
|
-
|
154
|
-
=== 0.1.2 2010-09-01
|
155
|
-
|
156
|
-
* Added ability to check a single file.
|
157
|
-
|
158
|
-
=== 0.1.0 2010-05-21
|
159
|
-
|
160
|
-
* Added checks for spacing around { and }.
|
161
|
-
* Added check for spacing around ternary ':'.
|
162
|
-
* Colorized error messages to be red.
|
163
|
-
* Problem message are now grouped by file line (when multiple problems per line).
|
164
|
-
* Temporarily removed reporting of # of trailing whitespaces.
|
165
|
-
|
166
|
-
=== 0.0.3 2010-04-26
|
167
|
-
|
168
|
-
* Added checks for spacing around commas.
|
169
|
-
* Added checks for spacing around open/closed parenthesis/brackets.
|
170
|
-
|
171
|
-
=== 0.0.2 2010-04-23
|
172
|
-
|
173
|
-
* Renamed project from ruby_style_checker to Tailor.
|
174
|
-
* Added check for lines > 80 characters.
|
175
|
-
|
176
|
-
=== 0.0.1 2010-04-22
|
177
|
-
|
178
|
-
* Initial release!
|
179
|
-
* Command-line executable takes a directory and checks all files, recursively.
|
180
|
-
* Checks for:
|
181
|
-
* Indentation
|
182
|
-
* Hard-tabs in indentation
|
183
|
-
* Name cases
|
184
|
-
* Snake case class & module names
|
185
|
-
* Camel case method names
|
186
|
-
* Extra whitespace
|
187
|
-
* At the end of lines
|
188
|
-
* On empty lines
|
189
|
-
* After commas
|
data/README.rdoc
DELETED
@@ -1,422 +0,0 @@
|
|
1
|
-
= tailor
|
2
|
-
|
3
|
-
* http://github.com/turboladen/tailor
|
4
|
-
|
5
|
-
{<img src="https://secure.travis-ci.org/turboladen/tailor.png?branch=master" alt="Build Status" />}[http://travis-ci.org/turboladen/tailor]
|
6
|
-
{<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/turboladen/tailor]
|
7
|
-
|
8
|
-
== DESCRIPTION:
|
9
|
-
|
10
|
-
tailor parses Ruby files and measures them with some style and static analysis
|
11
|
-
"rulers". Default values for the Rulers are based on a number of style guides
|
12
|
-
in the Ruby community as well as what seems to be common. More on this here
|
13
|
-
http://wiki.github.com/turboladen/tailor.
|
14
|
-
|
15
|
-
tailor's goal is to help you be consistent with your style, throughout your
|
16
|
-
project, whatever style that may be.
|
17
|
-
|
18
|
-
== FEATURES/PROBLEMS:
|
19
|
-
|
20
|
-
* Checks for bad style in Ruby files
|
21
|
-
* Recursively in a directory, or...
|
22
|
-
* A given file, or...
|
23
|
-
* A glob ('lib/**/*.rb')
|
24
|
-
* Checks for:
|
25
|
-
* Horizontal spacing
|
26
|
-
* Indentation
|
27
|
-
* Use of hard-tabs
|
28
|
-
* Line length
|
29
|
-
* Trailing spaces at the end of lines
|
30
|
-
* Spacing after commas
|
31
|
-
* Spacing before commas
|
32
|
-
* Spacing around { and before }
|
33
|
-
* Spacing after [ and before ]
|
34
|
-
* Spacing after ( and before )
|
35
|
-
* Vertical spacing
|
36
|
-
* Trailing newlines (at the end of the file)
|
37
|
-
* Max code lines in a class/module
|
38
|
-
* Max code lines in a method
|
39
|
-
* Name cases
|
40
|
-
* Snake case class & module names
|
41
|
-
* Camel case method names
|
42
|
-
* Valid Ruby (warns by default)
|
43
|
-
* Configurable
|
44
|
-
* Specify style in
|
45
|
-
* ~./tailorrc
|
46
|
-
* PROJECT_ROOT + .tailor
|
47
|
-
* as CLI options
|
48
|
-
* "File sets" allow for applying different styles to different groups of files
|
49
|
-
* Set problems to :warn or :off instead of :fail
|
50
|
-
* Define custom "Rulers"
|
51
|
-
* CI/Build Integration
|
52
|
-
* (Well, this may be stretching things a bit, but...) Exit 1 on failures
|
53
|
-
|
54
|
-
== SYNOPSIS:
|
55
|
-
|
56
|
-
=== Why style check?
|
57
|
-
|
58
|
-
If you're reading this, there's a good chance you already have your own reasons
|
59
|
-
for doing so. If you're not familiar with static analysis, give tailor a go
|
60
|
-
for a few days and see if you think it improves your code's readability.
|
61
|
-
|
62
|
-
=== What's it do?
|
63
|
-
|
64
|
-
At tailor's inception, there were some other static analysis tools for Ruby,
|
65
|
-
but none which checked style stuff; tailor started off as a means to fill this
|
66
|
-
gap. Since then, a number of those tools have dropped by the wayside due to
|
67
|
-
various Ruby 1.9 incompatibilities, and left a bigger tool gap for Rubyists.
|
68
|
-
Right now it's mostly a style-checker, but might into a tool for analyzing other
|
69
|
-
aspects of your Ruby code.
|
70
|
-
|
71
|
-
=== Since 0.x...
|
72
|
-
|
73
|
-
tailor 1.x is a marked improvment over 0.x. While 0.x provided a few (pretty
|
74
|
-
inconsistent) style checks, its design made the code get all spaghetti-like,
|
75
|
-
with lots of really gnarly regular expression matching, making it a realy bear
|
76
|
-
to add new features and fix bugs. tailor 1.x is completely redesigned to make
|
77
|
-
that whole process much easier.
|
78
|
-
|
79
|
-
=== Measure Stuff
|
80
|
-
|
81
|
-
Check _all_ files in a directory:
|
82
|
-
|
83
|
-
$ tailor path/to/check/
|
84
|
-
|
85
|
-
Check a single file:
|
86
|
-
|
87
|
-
$ tailor file_to_check.rb
|
88
|
-
|
89
|
-
Check only files ending in .rb under the 'test' directory:
|
90
|
-
|
91
|
-
$ tailor test/**/*.rb
|
92
|
-
|
93
|
-
Check defaults (lib/**/*.rb):
|
94
|
-
|
95
|
-
$ tailor
|
96
|
-
|
97
|
-
Printing the results in a output file (if using a formatter that accepts output files, like 'yaml'):
|
98
|
-
|
99
|
-
$ tailor path/to/check --output-file=my-results.yaml
|
100
|
-
$ tailor --output-file=my-results-from-defaults.yaml
|
101
|
-
|
102
|
-
Use defaults via a Rake task (if you have a .tailor file, it'll use those settings):
|
103
|
-
|
104
|
-
require 'tailor/rake_task'
|
105
|
-
|
106
|
-
Tailor::RakeTask.new
|
107
|
-
|
108
|
-
==== On style...
|
109
|
-
|
110
|
-
The features list, above, shows some aspects of style that should be fairly
|
111
|
-
straightforward (as to their meaning and reason), however, others make some big
|
112
|
-
assumptions--particularly the indentation checking "ruler". There are a number
|
113
|
-
of popular indenting conventions... In the case of multi-line parameters to a
|
114
|
-
method, some like do this:
|
115
|
-
|
116
|
-
def a_really_freakin_long_method_name(my_really_long_first_parameter,
|
117
|
-
my_next_param)
|
118
|
-
# ...
|
119
|
-
end
|
120
|
-
|
121
|
-
...while others prefer:
|
122
|
-
|
123
|
-
def a_really_freakin_long_method_name(my_really_long_first_parameter,
|
124
|
-
my_next_param)
|
125
|
-
# ...
|
126
|
-
end
|
127
|
-
|
128
|
-
...and yet some others prefer:
|
129
|
-
|
130
|
-
def a_really_freakin_long_method_name(my_really_long_first_parameter,
|
131
|
-
my_next_param)
|
132
|
-
# ...
|
133
|
-
end
|
134
|
-
|
135
|
-
At this point, tailor only supports the style used in the first example. If
|
136
|
-
this style isn't to your liking, then definitely take a look at the
|
137
|
-
Configurable section here to see how to turn this off. Other styles will
|
138
|
-
probably be supported in the future.
|
139
|
-
|
140
|
-
All that to say, though, that this isn't the only case where tailor makes style
|
141
|
-
assumptions. Another discrepancy in popular styles is with regard to aligning
|
142
|
-
operators in different lines. Some like:
|
143
|
-
|
144
|
-
my_hash[:first][:thing] = 1
|
145
|
-
my_hash[:eleventy][:thing] = 2
|
146
|
-
|
147
|
-
...while others prefer:
|
148
|
-
|
149
|
-
my_hash[:first][:thing] = 1
|
150
|
-
my_hash[:eleventy][:thing] = 2
|
151
|
-
|
152
|
-
...and yet some others prefer:
|
153
|
-
|
154
|
-
my_hash[:first][:thing] = 1
|
155
|
-
my_hash[:eleventy][:thing] = 2
|
156
|
-
|
157
|
-
Again, tailor only supports the first example here.
|
158
|
-
|
159
|
-
The goal is certainly not to force you to use the style that tailor currently
|
160
|
-
uses; it just might not support your style yet. If tailor doesn't support your
|
161
|
-
style, please feel free to take a look at the issues list and make a request.
|
162
|
-
...or fork away!
|
163
|
-
|
164
|
-
=== Configurable:
|
165
|
-
|
166
|
-
Not everyone prefers the same style of, well, anything really. tailor is
|
167
|
-
configurable to allow you to check your code against the style measurements
|
168
|
-
that you want.
|
169
|
-
|
170
|
-
It has default values for each of the "rulers" it uses, but if you want to
|
171
|
-
customize these, there are a number of ways you can do so.
|
172
|
-
|
173
|
-
==== CLI
|
174
|
-
|
175
|
-
At any time, you can tell tailor to show you the configuration that it's going
|
176
|
-
to use by doing:
|
177
|
-
|
178
|
-
$ tailor --show-config
|
179
|
-
|
180
|
-
To see, amongst other options, the style options that you can pass in, do
|
181
|
-
|
182
|
-
$ tailor --help
|
183
|
-
|
184
|
-
If, for example, you want to tell tailor to warn you if any of your code lines
|
185
|
-
are > 100 chars (instead of the default of 80):
|
186
|
-
|
187
|
-
$ tailor --max-line-length 100 lib/
|
188
|
-
|
189
|
-
If you want to simply disable a ruler, just pass +off+ to the option:
|
190
|
-
|
191
|
-
$ tailor --max-line-length off lib/
|
192
|
-
|
193
|
-
==== Configuration File
|
194
|
-
|
195
|
-
While you can drive most tailor options from the command line, configuration
|
196
|
-
files allow for some more flexibility with style rulers, file lists, and
|
197
|
-
(eventually) report formatters. To create one with default settings, do:
|
198
|
-
|
199
|
-
$ tailor --create-config
|
200
|
-
|
201
|
-
With the documentation that's provided in the file, the settings should be
|
202
|
-
straightforward (if they're not, please let me know!). You don't have to specify
|
203
|
-
all of those settings in your config file--those are just rendered so you have
|
204
|
-
a starting ground to tweak with. If you only want to override a single value,
|
205
|
-
you can delete the rest of the code from your config. This would accomplish
|
206
|
-
the same as the <tt>--max-line-length</tt> example above:
|
207
|
-
|
208
|
-
# .tailor
|
209
|
-
Tailor.config do |config|
|
210
|
-
config.file_set 'lib/**/*.rb' do |style|
|
211
|
-
style.max_line_length 100
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
This brings us to the concept of "file sets"...
|
216
|
-
|
217
|
-
===== File Sets
|
218
|
-
|
219
|
-
File sets allow you to use different style rulers against different groups of
|
220
|
-
files. You may, for example, want your Rails app code to allow for longer
|
221
|
-
lines, or fewer code lines in methods... You may want your RSpec code to be
|
222
|
-
more lenient with curly-brace usage... You may just want to specify a few file
|
223
|
-
globs to use the default set of rulers... File sets allow for those sorts of
|
224
|
-
things.
|
225
|
-
|
226
|
-
In the default config file, you see a single parameter being passed to
|
227
|
-
<tt>config.file_set</tt>--this is the glob that defines the list of files for
|
228
|
-
that file set. While you don't see it, +config.file_set+ takes a second
|
229
|
-
optional parameter that allows you to _label_ your style properties, and thus
|
230
|
-
use different sets of style properties for differet sets of files. The label is
|
231
|
-
simply just a name to refer to that file set by; it will show in your report
|
232
|
-
(in the case that problems were found, of course) so you know what set of
|
233
|
-
rulers caused the problem to be found.
|
234
|
-
|
235
|
-
# .tailor
|
236
|
-
Tailor.config do |config|
|
237
|
-
|
238
|
-
# All defaults; implies "default" label
|
239
|
-
config.file_set 'lib/**/*.rb'
|
240
|
-
|
241
|
-
config.file_set 'app/**/*.rb', :rails_app do |style|
|
242
|
-
style.max_line_length 100
|
243
|
-
# All other rulers will use default values
|
244
|
-
end
|
245
|
-
|
246
|
-
# Uses default style, but labelled in the report with "features"
|
247
|
-
config.file_set 'features/**/*.rb', :features
|
248
|
-
|
249
|
-
config.file_set 'spec/**/*.rb', :rspec do |style|
|
250
|
-
style.spaces_after_lbrace false
|
251
|
-
style.spaces_before_lbrace false
|
252
|
-
style.spaces_before_rbrace false
|
253
|
-
# All other rulers will use default values
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
If it suits you better, use "recursive file sets" to get all matching files
|
258
|
-
in your current path. If you wanted to critique all .rb files:
|
259
|
-
|
260
|
-
# .tailor
|
261
|
-
Tailor.config do |config|
|
262
|
-
|
263
|
-
# All defaults; implies "default" label
|
264
|
-
config.recursive_file_set '*.rb'
|
265
|
-
end
|
266
|
-
|
267
|
-
Similarly to the CLI, if you want to turn off a default Ruler, set its problem
|
268
|
-
level to +:off+:
|
269
|
-
|
270
|
-
# .tailor
|
271
|
-
Tailor.config do |config|
|
272
|
-
config.file_set 'lib/**/*.rb do |style|
|
273
|
-
style.indentation_spaces 2, level: :off
|
274
|
-
end
|
275
|
-
end
|
276
|
-
|
277
|
-
|
278
|
-
===== Formatters
|
279
|
-
|
280
|
-
By default Tailor uses the text formatter, printing the results on console. Tailor
|
281
|
-
also provides a YAML formatter, that accepts an output file if using the option
|
282
|
-
--output-file=*.yaml
|
283
|
-
|
284
|
-
# .tailor
|
285
|
-
Tailor.config do |config|
|
286
|
-
config.formatters 'text', 'yaml'
|
287
|
-
|
288
|
-
# just one
|
289
|
-
config.formatters 'text'
|
290
|
-
end
|
291
|
-
|
292
|
-
|
293
|
-
=== Define A Custom Ruler
|
294
|
-
|
295
|
-
While tailor provides a number of Rulers for checking style, it also provides a
|
296
|
-
way for you to add your own rulers without having to delve into its innards. To
|
297
|
-
do this, you need to do the following.
|
298
|
-
|
299
|
-
==== Create the Ruler
|
300
|
-
|
301
|
-
Before jumping in to this, take a look at {Tailor::Ruler} and any of the
|
302
|
-
existing Rulers in +lib/tailor/rulers/+. There are some key things a new Ruler
|
303
|
-
must have:
|
304
|
-
|
305
|
-
* the class name ends with "Ruler"
|
306
|
-
* it inherits {Tailor::Ruler}
|
307
|
-
* it's defined within the {Tailor::Rulers} module
|
308
|
-
* +#initialize+ defines two parameters:
|
309
|
-
1. +config+ sets +@config+ to the "golden rule" value for what you're measuring
|
310
|
-
2. +options+ is a Hash, that should at least be passed the :level => you want
|
311
|
-
the problem to be logged as
|
312
|
-
* +#add_lexer_observers+ gets passed a list of {Tailor::Lexer} event types that
|
313
|
-
the ruler should get notified on
|
314
|
-
* it defines call-back methods for {Tailor::Lexer} to call when it comes across
|
315
|
-
an event of interest
|
316
|
-
* it calls +#measure+ to assess if the criteria it's checking has been met
|
317
|
-
* it adds a {Tailor::Problem} to +@problems+ when one is found in +#measure+
|
318
|
-
|
319
|
-
==== Add the Ruler to the list of Styles
|
320
|
-
|
321
|
-
Internally, this all happens in +lib/tailor/configuration/style.rb+, but you can
|
322
|
-
add infomation about your ruler to your config file. If you created a Ruler:
|
323
|
-
|
324
|
-
# max_lines_in_block.rb
|
325
|
-
class Tailor
|
326
|
-
module Rulers
|
327
|
-
class MaxLinesInBlockRuler < Tailor::Ruler
|
328
|
-
def initialize(config, options)
|
329
|
-
super(config, options)
|
330
|
-
add_lexer_observers :ignored_nl, :kw
|
331
|
-
end
|
332
|
-
|
333
|
-
def ignored_nl_update(lexed_line, lineno, column)
|
334
|
-
# ...
|
335
|
-
end
|
336
|
-
|
337
|
-
def kw_update(token, lexed_line, lineno, column)
|
338
|
-
# ...
|
339
|
-
end
|
340
|
-
|
341
|
-
def measure
|
342
|
-
# ...
|
343
|
-
end
|
344
|
-
|
345
|
-
# ...
|
346
|
-
end
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
...then require this and add it to the Style list of properties:
|
351
|
-
|
352
|
-
# .tailor
|
353
|
-
require 'tailor/configuration/style'
|
354
|
-
require 'max_lines_in_block'
|
355
|
-
|
356
|
-
Tailor::Configuration::Style.define_property :max_lines_in_block
|
357
|
-
|
358
|
-
Tailor.config do |config|
|
359
|
-
config.file_set 'lib/**/*.rb' do |style|
|
360
|
-
style.max_lines_in_block 10, level: :error
|
361
|
-
end
|
362
|
-
end
|
363
|
-
|
364
|
-
Next time you run tailor, your Ruler will get initialized and used.
|
365
|
-
|
366
|
-
=== Using the lib
|
367
|
-
|
368
|
-
Sometimes you could use tailor as a lib, getting the results as a hash
|
369
|
-
and manipulate them according your domain.
|
370
|
-
|
371
|
-
require 'tailor/cli'
|
372
|
-
|
373
|
-
# only results from a specific path
|
374
|
-
tailor = Tailor::CLI.new %w(app/controllers)
|
375
|
-
tailor.result # result should be a hash {"filename" => [problems]}
|
376
|
-
|
377
|
-
# using other file config (hiding path, it'll use from default config)
|
378
|
-
Tailor::CLI.new %w(--config-file=.other-config)
|
379
|
-
Tailor::CLI.new [] # uses file set from .tailor file config
|
380
|
-
|
381
|
-
# printing the results in a output file
|
382
|
-
tailor = Tailor::CLI.new %w(--output-file=results.yaml)
|
383
|
-
tailor.execute!
|
384
|
-
|
385
|
-
== REQUIREMENTS:
|
386
|
-
|
387
|
-
* Rubies (tested)
|
388
|
-
* 1.9.3
|
389
|
-
* 2.0.0
|
390
|
-
* Gems
|
391
|
-
* log_switch
|
392
|
-
* term-ansicolor
|
393
|
-
* text-table
|
394
|
-
|
395
|
-
== INSTALL:
|
396
|
-
|
397
|
-
$ (sudo) gem install tailor
|
398
|
-
|
399
|
-
== LICENSE:
|
400
|
-
|
401
|
-
(The MIT License)
|
402
|
-
|
403
|
-
Copyright (c) 2010-2013 Steve Loveless
|
404
|
-
|
405
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
406
|
-
a copy of this software and associated documentation files (the
|
407
|
-
'Software'), to deal in the Software without restriction, including
|
408
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
409
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
410
|
-
permit persons to whom the Software is furnished to do so, subject to
|
411
|
-
the following conditions:
|
412
|
-
|
413
|
-
The above copyright notice and this permission notice shall be
|
414
|
-
included in all copies or substantial portions of the Software.
|
415
|
-
|
416
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
417
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
418
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
419
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
420
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
421
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
422
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|