tailor 1.4.0 → 1.4.1

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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -3
  3. data/Gemfile.lock +39 -31
  4. data/History.md +220 -207
  5. data/README.md +58 -45
  6. data/features/step_definitions/indentation_steps.rb +1 -1
  7. data/lib/tailor/reporter.rb +19 -7
  8. data/lib/tailor/rulers/spaces_before_lbrace_ruler.rb +0 -1
  9. data/lib/tailor/rulers/spaces_before_rbrace_ruler.rb +0 -1
  10. data/lib/tailor/rulers/spaces_in_empty_braces_ruler.rb +0 -1
  11. data/lib/tailor/version.rb +1 -1
  12. data/spec/functional/conditional_parentheses_spec.rb +1 -1
  13. data/spec/functional/conditional_spacing_spec.rb +1 -1
  14. data/spec/functional/configuration_spec.rb +61 -52
  15. data/spec/functional/horizontal_spacing/braces_spec.rb +134 -134
  16. data/spec/functional/horizontal_spacing/brackets_spec.rb +34 -36
  17. data/spec/functional/horizontal_spacing/comma_spacing_spec.rb +25 -27
  18. data/spec/functional/horizontal_spacing/hard_tabs_spec.rb +42 -42
  19. data/spec/functional/horizontal_spacing/long_lines_spec.rb +15 -17
  20. data/spec/functional/horizontal_spacing/long_methods_spec.rb +4 -4
  21. data/spec/functional/horizontal_spacing/parens_spec.rb +45 -45
  22. data/spec/functional/horizontal_spacing/trailing_whitespace_spec.rb +7 -8
  23. data/spec/functional/horizontal_spacing_spec.rb +10 -11
  24. data/spec/functional/indentation_spacing/argument_alignment_spec.rb +33 -62
  25. data/spec/functional/indentation_spacing/bad_indentation_spec.rb +176 -179
  26. data/spec/functional/indentation_spacing_spec.rb +13 -14
  27. data/spec/functional/naming/camel_case_methods_spec.rb +4 -6
  28. data/spec/functional/naming/screaming_snake_case_classes_spec.rb +28 -31
  29. data/spec/functional/naming_spec.rb +3 -3
  30. data/spec/functional/rake_task_spec.rb +9 -28
  31. data/spec/functional/string_interpolation_spec.rb +1 -1
  32. data/spec/functional/string_quoting_spec.rb +1 -1
  33. data/spec/functional/vertical_spacing/class_length_spec.rb +4 -6
  34. data/spec/functional/vertical_spacing/method_length_spec.rb +15 -17
  35. data/spec/functional/vertical_spacing_spec.rb +3 -3
  36. data/spec/spec_helper.rb +2 -0
  37. data/spec/support/argument_alignment_cases.rb +32 -32
  38. data/spec/support/conditional_parentheses_cases.rb +26 -26
  39. data/spec/support/good_indentation_cases.rb +205 -205
  40. data/spec/support/horizontal_spacing_cases.rb +53 -54
  41. data/spec/support/line_indentation_cases.rb +20 -20
  42. data/spec/support/naming_cases.rb +12 -12
  43. data/spec/support/string_interpolation_cases.rb +17 -17
  44. data/spec/support/string_quoting_cases.rb +12 -12
  45. data/spec/support/vertical_spacing_cases.rb +8 -8
  46. data/spec/unit/tailor/cli/options_spec.rb +20 -14
  47. data/spec/unit/tailor/cli_spec.rb +29 -43
  48. data/spec/unit/tailor/composite_observable_spec.rb +1 -1
  49. data/spec/unit/tailor/configuration/file_set_spec.rb +10 -11
  50. data/spec/unit/tailor/configuration/style_spec.rb +41 -42
  51. data/spec/unit/tailor/configuration_spec.rb +14 -12
  52. data/spec/unit/tailor/formatter_spec.rb +3 -3
  53. data/spec/unit/tailor/formatters/yaml_spec.rb +12 -13
  54. data/spec/unit/tailor/lexed_line_spec.rb +67 -69
  55. data/spec/unit/tailor/lexer/token_spec.rb +7 -7
  56. data/spec/unit/tailor/lexer_spec.rb +24 -24
  57. data/spec/unit/tailor/problem_spec.rb +12 -12
  58. data/spec/unit/tailor/reporter_spec.rb +8 -9
  59. data/spec/unit/tailor/ruler_spec.rb +10 -10
  60. data/spec/unit/tailor/rulers/indentation_spaces_ruler/indentation_manager_spec.rb +90 -86
  61. data/spec/unit/tailor/rulers/indentation_spaces_ruler_spec.rb +13 -13
  62. data/spec/unit/tailor/rulers/spaces_after_comma_ruler_spec.rb +4 -4
  63. data/spec/unit/tailor/rulers/spaces_after_lbrace_ruler_spec.rb +19 -19
  64. data/spec/unit/tailor/rulers/spaces_before_lbrace_ruler_spec.rb +6 -6
  65. data/spec/unit/tailor/rulers/spaces_before_rbrace_ruler_spec.rb +6 -6
  66. data/spec/unit/tailor/rulers_spec.rb +1 -1
  67. data/spec/unit/tailor/version_spec.rb +1 -2
  68. data/spec/unit/tailor_spec.rb +2 -2
  69. data/tailor.gemspec +3 -3
  70. metadata +20 -6
@@ -2,8 +2,8 @@ H_SPACING_OK = {}
2
2
 
3
3
  H_SPACING_OK['short_line_no_newline'] = '#' * 79
4
4
  H_SPACING_OK['short_line_newline_at_81'] =
5
- %Q{'#{'#' * 78}'
6
- }
5
+ %('#{'#' * 78}'
6
+ )
7
7
 
8
8
  =begin
9
9
  H_SPACING_OK['line_split_by_backslash'] =
@@ -17,120 +17,119 @@ end}
17
17
  #-------------------------------------------------------------------------------
18
18
  # Comma spacing
19
19
  #-------------------------------------------------------------------------------
20
- H_SPACING_OK['space_after_comma_in_array'] = %Q{[1, 2]}
20
+ H_SPACING_OK['space_after_comma_in_array'] = %([1, 2])
21
21
 
22
- H_SPACING_OK['trailing_comma'] = %Q{def thing(one, two,
22
+ H_SPACING_OK['trailing_comma'] = %(def thing(one, two,
23
23
  three)
24
- end}
24
+ end)
25
25
 
26
26
  H_SPACING_OK['trailing_comma_with_trailing_comment'] =
27
- %Q{def thing(one, two, # Comment!
27
+ %(def thing(one, two, # Comment!
28
28
  three)
29
- end}
29
+ end)
30
30
 
31
- H_SPACING_OK['no_before_comma_in_array'] = %Q{[1, 2]}
31
+ H_SPACING_OK['no_before_comma_in_array'] = %([1, 2])
32
32
  H_SPACING_OK['line_ends_with_backslash'] =
33
- %Q{{ :thing => a_thing,\\
34
- :thing2 => another_thing }}
33
+ %({ :thing => a_thing,\\
34
+ :thing2 => another_thing })
35
35
 
36
36
  #-------------------------------------------------------------------------------
37
37
  # Braces
38
38
  #-------------------------------------------------------------------------------
39
- H_SPACING_OK['empty_hash'] = %Q{{}}
40
- H_SPACING_OK['single_line_hash'] = %Q{{ :one => 'one' }}
41
- H_SPACING_OK['single_line_hash_lonely_braces'] = %Q{{
39
+ H_SPACING_OK['empty_hash'] = %({})
40
+ H_SPACING_OK['single_line_hash'] = %({ :one => 'one' })
41
+ H_SPACING_OK['single_line_hash_lonely_braces'] = %({
42
42
  :one => 'one'
43
- }}
43
+ })
44
44
 
45
45
  H_SPACING_OK['hash_as_param_in_parens'] =
46
- %Q{add_headers({ content_length: new_body.length })}
46
+ %(add_headers({ content_length: new_body.length }))
47
47
 
48
- H_SPACING_OK['two_line_hash'] = %Q{{ :one =>
49
- 'one' }}
48
+ H_SPACING_OK['two_line_hash'] = %({ :one =>
49
+ 'one' })
50
50
 
51
- H_SPACING_OK['two_line_hash_trailing_comment'] = %Q{{ :one => # comment
52
- 'one' }}
51
+ H_SPACING_OK['two_line_hash_trailing_comment'] = %({ :one => # comment
52
+ 'one' })
53
53
 
54
- H_SPACING_OK['three_line_hash'] = %Q{{ :one =>
54
+ H_SPACING_OK['three_line_hash'] = %({ :one =>
55
55
  'one', :two =>
56
- 'two' }}
56
+ 'two' })
57
57
 
58
- H_SPACING_OK['single_line_block'] = %Q{1..10.times { |n| puts number }}
59
- H_SPACING_OK['multi_line_braces_block'] = %Q{1..10.times { |n|
60
- puts number }}
58
+ H_SPACING_OK['single_line_block'] = %(1..10.times { |n| puts number })
59
+ H_SPACING_OK['multi_line_braces_block'] = %(1..10.times { |n|
60
+ puts number })
61
61
 
62
- H_SPACING_OK['multi_line_qword_using_braces'] = %Q{%w{
62
+ H_SPACING_OK['multi_line_qword_using_braces'] = %(%w{
63
63
  foo
64
64
  bar
65
65
  baz
66
66
  }.each do |whatevs|
67
67
  bla
68
- end}
68
+ end)
69
69
 
70
70
  H_SPACING_OK['empty_hash_in_multi_line_statement'] =
71
- %Q{if true
71
+ %(if true
72
72
  {}
73
- end}
73
+ end)
74
74
 
75
75
  H_SPACING_OK['multi_line_hash_in_multi_line_statement'] =
76
- %Q{if true
76
+ %(if true
77
77
  options = {
78
78
  one: 1
79
79
  }
80
- end}
80
+ end)
81
81
 
82
- H_SPACING_OK['single_line_string_interp'] = %Q{`\#{IFCONFIG} | grep \#{ip}`}
82
+ H_SPACING_OK['single_line_string_interp'] = %(`\#{IFCONFIG} | grep \#{ip}`)
83
83
  H_SPACING_OK['single_line_block_in_string_interp'] =
84
- %Q{"I did this \#{1..10.times { |n| n }} times."}
84
+ %("I did this \#{1..10.times { |n| n }} times.")
85
85
 
86
86
  H_SPACING_OK['empty_hash_in_string_in_block'] =
87
- %Q{[1].map { |n| { :first => "\#{n}-\#{{}}" } }}
87
+ %([1].map { |n| { :first => "\#{n}-\#{{}}" } })
88
88
 
89
89
  H_SPACING_OK['string_interp_with_colonop'] =
90
- %Q{"\#{::Rails.root + 'file'}"}
90
+ %("\#{::Rails.root + 'file'}")
91
91
 
92
92
 
93
93
 
94
94
  #-------------------------------------------------------------------------------
95
95
  # Brackets
96
96
  #-------------------------------------------------------------------------------
97
- H_SPACING_OK['empty_array'] = %Q{[]}
98
- H_SPACING_OK['simple_array'] = %Q{[1, 2, 3]}
99
- H_SPACING_OK['two_d_array'] = %Q{[[1, 2, 3], ['a', 'b', 'c']]}
100
- H_SPACING_OK['hash_key_reference'] = %Q{thing[:one]}
97
+ H_SPACING_OK['empty_array'] = %([])
98
+ H_SPACING_OK['simple_array'] = %([1, 2, 3])
99
+ H_SPACING_OK['two_d_array'] = %([[1, 2, 3], ['a', 'b', 'c']])
100
+ H_SPACING_OK['hash_key_reference'] = %(thing[:one])
101
101
  H_SPACING_OK['array_of_symbols'] =
102
- %Q{transition [:active, :reactivated] => :opened}
102
+ %(transition [:active, :reactivated] => :opened)
103
103
  H_SPACING_OK['array_of_hashes'] =
104
- %Q{[ { :one => [[1, 2, 3], ['a', 'b', 'c']] },
105
- { :two => [[4, 5, 6], ['d', 'e', 'f']] }]}
104
+ %([ { :one => [[1, 2, 3], ['a', 'b', 'c']] },
105
+ { :two => [[4, 5, 6], ['d', 'e', 'f']] }])
106
106
 
107
107
  H_SPACING_OK['simple_array_lonely_brackets'] =
108
- %Q{[
108
+ %([
109
109
  1, 2,
110
110
  3
111
- ]}
111
+ ])
112
112
 
113
113
  H_SPACING_OK['simple_nested_array_lonely_brackets'] =
114
- %Q{def thing
114
+ %(def thing
115
115
  [
116
116
  1, 2,
117
117
  3
118
118
  ]
119
- end}
120
-
119
+ end)
121
120
 
122
121
  H_SPACING_OK['empty_array_in_multi_line_statement'] =
123
- %Q{if true
122
+ %(if true
124
123
  []
125
- end}
124
+ end)
126
125
 
127
126
  #-------------------------------------------------------------------------------
128
127
  # Parens
129
128
  #-------------------------------------------------------------------------------
130
- H_SPACING_OK['empty_parens'] = %Q{def thing(); end}
131
- H_SPACING_OK['simple_method_call'] = %Q{thing(one, two)}
132
- H_SPACING_OK['multi_line_method_call'] = %Q{thing(one,
133
- two)}
134
- H_SPACING_OK['multi_line_method_call_lonely_parens'] = %Q{thing(
129
+ H_SPACING_OK['empty_parens'] = %(def thing(); end)
130
+ H_SPACING_OK['simple_method_call'] = %(thing(one, two))
131
+ H_SPACING_OK['multi_line_method_call'] = %(thing(one,
132
+ two))
133
+ H_SPACING_OK['multi_line_method_call_lonely_parens'] = %(thing(
135
134
  one, two
136
- )}
135
+ ))
@@ -1,11 +1,11 @@
1
1
  LINE_INDENT = {}
2
2
 
3
3
  LINE_INDENT['hash_spans_lines'] =
4
- %q{db_connection = { :host => "localhost", :username => 'root',
5
- :password => node['db']['password'] }}
4
+ %(db_connection = { :host => "localhost", :username => 'root',
5
+ :password => node['db']['password'] })
6
6
 
7
7
  LINE_INDENT['if_else'] =
8
- %q{case "foo"
8
+ %(case "foo"
9
9
  when "foo"
10
10
  if node["foo"]["version"].to_f >= 5.5
11
11
  default['foo']['service_name'] = "foo"
@@ -14,28 +14,28 @@ when "foo"
14
14
  default['foo']['service_name'] = "food"
15
15
  default['foo']['pid_file'] = "/var/run/food/food.pid"
16
16
  end
17
- end}
17
+ end)
18
18
 
19
19
  LINE_INDENT['line_continues_at_same_indentation'] =
20
- %q{if someconditional_that == is_really_long.function().stuff() or
20
+ %(if someconditional_that == is_really_long.function().stuff() or
21
21
  another_condition == some_thing
22
22
  puts "boop"
23
- end}
23
+ end)
24
24
 
25
25
  LINE_INDENT['line_continues_further_indented'] =
26
- %q{if someconditional_that == is_really_long.function().stuff() or
26
+ %(if someconditional_that == is_really_long.function().stuff() or
27
27
  another_condition == some_thing
28
28
  puts "boop"
29
- end}
29
+ end)
30
30
 
31
31
  LINE_INDENT['line_continues_without_nested_statements'] =
32
- %q{attribute "foo/password",
32
+ %(attribute "foo/password",
33
33
  :display_name => "Password",
34
34
  :description => "Randomly generated password",
35
- :default => "randomly generated"}
35
+ :default => "randomly generated")
36
36
 
37
37
  LINE_INDENT['minitest_test_cases'] =
38
- %q{describe "foo" do
38
+ %q(describe "foo" do
39
39
  it 'includes the disk_free_limit configuration setting' do
40
40
  file("#{node['foo']['config_root']}/foo.config").
41
41
  must_match /\{disk_free_limit, \{mem_relative, #{node['foo']['df']}/
@@ -44,28 +44,28 @@ LINE_INDENT['minitest_test_cases'] =
44
44
  file("#{node['foo']['config_root']}/foo.config").
45
45
  must_match /\{vm_memory_high_watermark, #{node['foo']['vm']}/
46
46
  end
47
- end}
47
+ end)
48
48
 
49
49
  LINE_INDENT['nested_blocks'] =
50
- %q{node['foo']['client']['packages'].each do |foo_pack|
50
+ %(node['foo']['client']['packages'].each do |foo_pack|
51
51
  package foo_pkg do
52
52
  action :install
53
53
  end
54
- end}
54
+ end)
55
55
 
56
56
  LINE_INDENT['one_assignment_per_line'] =
57
- %q{default['foo']['bar']['apt_key_id'] = 'BD2EFD2A'
57
+ %(default['foo']['bar']['apt_key_id'] = 'BD2EFD2A'
58
58
  default['foo']['bar']['apt_uri'] = "http://repo.example.com/apt"
59
- default['foo']['bar']['apt_keyserver'] = "keys.example.net"}
59
+ default['foo']['bar']['apt_keyserver'] = "keys.example.net")
60
60
 
61
61
  LINE_INDENT['parameters_continuation_indent_across_lines'] =
62
- %q{def something(waka, baka, bing,
62
+ %(def something(waka, baka, bing,
63
63
  bla, goop, foop)
64
64
  stuff
65
- end}
65
+ end)
66
66
 
67
67
  LINE_INDENT['parameters_no_continuation_indent_across_lines'] =
68
- %q{def something(waka, baka, bing,
68
+ %(def something(waka, baka, bing,
69
69
  bla, goop, foop)
70
70
  stuff
71
- end}
71
+ end)
@@ -1,26 +1,26 @@
1
1
  NAMING_OK = {}
2
2
 
3
3
  NAMING_OK['single_word_method'] =
4
- %Q{def thing
5
- end}
4
+ %(def thing
5
+ end)
6
6
 
7
7
  NAMING_OK['two_word_method'] =
8
- %Q{def thing_one
9
- end}
8
+ %(def thing_one
9
+ end)
10
10
 
11
11
  #-------------------------------------------------------------------------------
12
12
  NAMING_OK['single_word_class'] =
13
- %Q{class Thing
14
- end}
13
+ %(class Thing
14
+ end)
15
15
 
16
16
  NAMING_OK['single_word_module'] =
17
- %Q{module Thing
18
- end}
17
+ %(module Thing
18
+ end)
19
19
 
20
20
  NAMING_OK['two_word_class'] =
21
- %Q{class ThingOne
22
- end}
21
+ %(class ThingOne
22
+ end)
23
23
 
24
24
  NAMING_OK['two_word_module'] =
25
- %Q{module ThingOne
26
- end}
25
+ %(module ThingOne
26
+ end)
@@ -1,45 +1,45 @@
1
1
  INTERPOLATION = {}
2
2
 
3
3
  INTERPOLATION['one_variable_interpolated_only'] =
4
- %q{puts "#{bing}"
5
- }
4
+ %q(puts "#{bing}"
5
+ )
6
6
 
7
7
  INTERPOLATION['mixed_content_and_expression'] =
8
- %q{puts "hello: #{bing}"
9
- }
8
+ %q(puts "hello: #{bing}"
9
+ )
10
10
 
11
11
  INTERPOLATION['no_string'] =
12
- %q{puts bing
13
- }
12
+ %q(puts bing
13
+ )
14
14
 
15
15
  INTERPOLATION['two_variables'] =
16
- %q{puts "#{bing}#{bar}"
17
- }
16
+ %q(puts "#{bing}#{bar}"
17
+ )
18
18
 
19
19
  INTERPOLATION['two_strings_with_unnecessary_interpolation'] =
20
- %q{puts "#{foo}" + "#{bar}"
21
- }
20
+ %q(puts "#{foo}" + "#{bar}"
21
+ )
22
22
 
23
23
  INTERPOLATION['multiline_string_with_unnecessary_interpolation'] =
24
- %q{puts "#{foo +
24
+ %q(puts "#{foo +
25
25
  bar -
26
26
  baz}"
27
- }
27
+ )
28
28
 
29
29
  INTERPOLATION['multiline_word_list'] =
30
- %q{%w{
30
+ %q(%w{
31
31
  foo
32
32
  bar
33
33
  baz
34
- }}
34
+ })
35
35
 
36
36
  INTERPOLATION['nested_interpolation'] =
37
- %q[def friendly_time(time)
37
+ %q(def friendly_time(time)
38
38
  if hours < 24
39
39
  "#{(hours > 0) ? "#{hours} hour" : '' }#{(hours > 1) ? 's' : ''}" +
40
40
  " #{(mins > 0) ? "#{mins} minute" : '' }#{(mins > 1) ? 's' : ''}" +
41
- " #{seconds} second#{(seconds > 1) ? "s" : ''} ago"
41
+ " #{seconds} second#{(seconds > 1) ? 's' : ''} ago"
42
42
  else
43
43
  time.to_s
44
44
  end
45
- end]
45
+ end)
@@ -1,25 +1,25 @@
1
1
  QUOTING = {}
2
2
 
3
3
  QUOTING['single_quotes_no_interpolation'] =
4
- %q{foo = 'bar'
5
- }
4
+ %q(foo = 'bar'
5
+ )
6
6
 
7
7
  QUOTING['double_quotes_with_interpolation'] =
8
- %q{foo = "bar#{baz}"
9
- }
8
+ %q(foo = "bar#{baz}"
9
+ )
10
10
 
11
11
  QUOTING['double_quotes_no_interpolation'] =
12
- %q{foo = "bar"
13
- }
12
+ %q(foo = "bar"
13
+ )
14
14
 
15
15
  QUOTING['double_quotes_no_interpolation_twice'] =
16
- %q{foo = "bar" + "baz"
17
- }
16
+ %q(foo = "bar" + "baz"
17
+ )
18
18
 
19
19
  QUOTING['escape_sequence'] =
20
- %q{foo = "bar\n"
21
- }
20
+ %q(foo = "bar\n"
21
+ )
22
22
 
23
23
  QUOTING['nested_quotes'] =
24
- %q{foo = "foo#{bar('baz')}"
25
- }
24
+ %q(foo = "foo#{bar('baz')}"
25
+ )
@@ -4,33 +4,33 @@ V_SPACING_OK = {}
4
4
  # Class length
5
5
  #-------------------------------------------------------------------------------
6
6
  V_SPACING_OK['class_five_code_lines'] =
7
- %Q{class Party
7
+ %(class Party
8
8
  include Clowns
9
9
 
10
10
  def barrel_roll
11
11
  end
12
- end}
12
+ end)
13
13
 
14
14
  V_SPACING_OK['embedded_class_five_code_lines'] =
15
- %Q{class Party
15
+ %(class Party
16
16
  class Pizza
17
17
  include Cheese
18
18
  end
19
- end}
19
+ end)
20
20
 
21
21
  #-------------------------------------------------------------------------------
22
22
  # Method length
23
23
  #-------------------------------------------------------------------------------
24
24
  V_SPACING_OK['method_3_code_lines'] =
25
- %Q{def thing
25
+ %(def thing
26
26
 
27
27
 
28
28
  puts 'hi'
29
- end}
29
+ end)
30
30
 
31
31
  V_SPACING_OK['embedded_method_3_code_lines'] =
32
- %Q{def outter_thing
32
+ %(def outter_thing
33
33
  def thing; puts 'hi'; end
34
34
 
35
35
 
36
- end}
36
+ end)