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
data/lib/tailor/lexed_line.rb
CHANGED
@@ -202,7 +202,6 @@ class Tailor
|
|
202
202
|
# observers that key off ending the line will never get triggered, and thus
|
203
203
|
# style won't get checked for that line.
|
204
204
|
#
|
205
|
-
# @param [Fixnum] column The column that the comment is at.
|
206
205
|
# @param [String] file_text The whole file's worth of text. Required in
|
207
206
|
# order to be able to reconstruct the context in which the line exists.
|
208
207
|
# @return [LexedLine] The current lexed line, but with the trailing comment
|
@@ -235,7 +234,6 @@ class Tailor
|
|
235
234
|
|
236
235
|
# Determines if the current lexed line is just the end of a tstring.
|
237
236
|
#
|
238
|
-
# @param [Array] lexed_line_output The lexed output for the current line.
|
239
237
|
# @return [Boolean] +true+ if the line contains a +:on_tstring_end+ and
|
240
238
|
# not a +:on_tstring_beg+.
|
241
239
|
def end_of_multi_line_string?
|
@@ -269,8 +267,8 @@ class Tailor
|
|
269
267
|
private
|
270
268
|
|
271
269
|
def log(*args)
|
272
|
-
l = begin; lineno; rescue;
|
273
|
-
c = begin; column; rescue;
|
270
|
+
l = begin; lineno; rescue; '<EOF>'; end
|
271
|
+
c = begin; column; rescue; '<EOF>'; end
|
274
272
|
subclass_name = self.class.to_s.sub(/^Tailor::/, '')
|
275
273
|
args.first.insert(0, "<#{subclass_name}> #{l}[#{c}]: ")
|
276
274
|
Tailor::Logger.log(*args)
|
data/lib/tailor/lexer.rb
CHANGED
@@ -23,7 +23,7 @@ class Tailor
|
|
23
23
|
@file_name = file
|
24
24
|
File.open(@file_name, 'r').read
|
25
25
|
else
|
26
|
-
@file_name =
|
26
|
+
@file_name = '<notafile>'
|
27
27
|
file
|
28
28
|
end
|
29
29
|
|
@@ -214,7 +214,7 @@ class Tailor
|
|
214
214
|
#
|
215
215
|
# @param [String] token The token that the lexer matched.
|
216
216
|
def on_ignored_nl(token)
|
217
|
-
log
|
217
|
+
log 'IGNORED_NL'
|
218
218
|
|
219
219
|
current_line = LexedLine.new(super, lineno)
|
220
220
|
ignored_nl_changed
|
@@ -306,7 +306,7 @@ class Tailor
|
|
306
306
|
|
307
307
|
# This is the first thing that exists on a new line--NOT the last!
|
308
308
|
def on_nl(token)
|
309
|
-
log
|
309
|
+
log 'NL'
|
310
310
|
current_line = LexedLine.new(super, lineno)
|
311
311
|
|
312
312
|
nl_changed
|
@@ -560,17 +560,17 @@ class Tailor
|
|
560
560
|
# with line-ending backslashes that break up statements.
|
561
561
|
#
|
562
562
|
# @param [String] file_text The file test to check.
|
563
|
-
# @
|
563
|
+
# @return [String] The altered file text.
|
564
564
|
def sub_line_ending_backslashes(file_text)
|
565
|
-
backslash_replacement =
|
565
|
+
backslash_replacement = '# TAILOR REMOVED BACKSLASH'
|
566
566
|
file_text.gsub!(/\\\s*\n?$/, backslash_replacement)
|
567
|
-
|
567
|
+
|
568
568
|
file_text
|
569
569
|
end
|
570
|
-
|
570
|
+
|
571
571
|
def log(*args)
|
572
|
-
l = begin; lineno; rescue;
|
573
|
-
c = begin; column; rescue;
|
572
|
+
l = begin; lineno; rescue; '<EOF>'; end
|
573
|
+
c = begin; column; rescue; '<EOF>'; end
|
574
574
|
subclass_name = self.class.to_s.sub(/^Tailor::/, '')
|
575
575
|
args.first.insert(0, "<#{subclass_name}> #{l}[#{c}]: ")
|
576
576
|
Tailor::Logger.log(*args)
|
@@ -7,38 +7,38 @@ class Tailor
|
|
7
7
|
# * https://github.com/ruby/ruby/blob/trunk/ext/ripper/eventids2.c
|
8
8
|
# * https://github.com/ruby/ruby/blob/trunk/parse.y
|
9
9
|
module LexerConstants
|
10
|
-
KEYWORDS_TO_INDENT = Set.new [
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
10
|
+
KEYWORDS_TO_INDENT = Set.new %w[
|
11
|
+
begin
|
12
|
+
case
|
13
|
+
class
|
14
|
+
def
|
15
|
+
do
|
16
|
+
else
|
17
|
+
elsif
|
18
|
+
ensure
|
19
|
+
for
|
20
|
+
if
|
21
|
+
module
|
22
|
+
rescue
|
23
|
+
unless
|
24
|
+
until
|
25
|
+
when
|
26
|
+
while
|
27
27
|
]
|
28
28
|
|
29
|
-
CONTINUATION_KEYWORDS = Set.new [
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
CONTINUATION_KEYWORDS = Set.new %w[
|
30
|
+
elsif
|
31
|
+
else
|
32
|
+
ensure
|
33
|
+
rescue
|
34
|
+
when
|
35
35
|
]
|
36
36
|
|
37
|
-
KEYWORDS_AND_MODIFIERS = Set.new [
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
KEYWORDS_AND_MODIFIERS = Set.new %w[
|
38
|
+
if
|
39
|
+
unless
|
40
|
+
until
|
41
|
+
while
|
42
42
|
]
|
43
43
|
|
44
44
|
MODIFIERS = {
|
@@ -68,10 +68,10 @@ class Tailor
|
|
68
68
|
'~>' # gem_version op
|
69
69
|
]
|
70
70
|
|
71
|
-
LOOP_KEYWORDS = Set.new [
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
LOOP_KEYWORDS = Set.new %w[
|
72
|
+
for
|
73
|
+
until
|
74
|
+
while
|
75
75
|
]
|
76
76
|
end
|
77
77
|
end
|
data/lib/tailor/lexer/token.rb
CHANGED
@@ -40,7 +40,7 @@ class Tailor
|
|
40
40
|
#
|
41
41
|
# @return [Boolean]
|
42
42
|
def do_is_for_a_loop?
|
43
|
-
self ==
|
43
|
+
self == 'do' && @options[:loop_with_do]
|
44
44
|
end
|
45
45
|
|
46
46
|
# @return [Boolean]
|
@@ -68,21 +68,21 @@ class Tailor
|
|
68
68
|
line_of_text = @options[:full_line_of_text]
|
69
69
|
log "Line of text: #{line_of_text}"
|
70
70
|
|
71
|
-
|
71
|
+
catch(:result) do
|
72
72
|
sexp_line = Ripper.sexp(line_of_text)
|
73
73
|
|
74
74
|
if sexp_line.nil?
|
75
|
-
msg =
|
76
|
-
msg <<
|
75
|
+
msg = 'sexp line was nil. '
|
76
|
+
msg << 'Perhaps that line is part of a multi-line statement?'
|
77
77
|
log msg
|
78
|
-
log
|
78
|
+
log 'Trying again with the last char removed from the line...'
|
79
79
|
line_of_text.chop!
|
80
80
|
sexp_line = Ripper.sexp(line_of_text)
|
81
81
|
end
|
82
82
|
|
83
83
|
if sexp_line.nil?
|
84
|
-
log
|
85
|
-
log
|
84
|
+
log 'sexp line was nil again.'
|
85
|
+
log 'Trying 1 more time with the last char removed from the line...'
|
86
86
|
line_of_text.chop!
|
87
87
|
sexp_line = Ripper.sexp(line_of_text)
|
88
88
|
end
|
@@ -99,10 +99,8 @@ class Tailor
|
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
102
|
-
|
103
|
-
result
|
104
102
|
end
|
105
|
-
|
103
|
+
|
106
104
|
# @return [Boolean]
|
107
105
|
def fake_backslash_line_end?
|
108
106
|
self =~ /^# TAILOR REMOVED BACKSLASH\n?$/
|
data/lib/tailor/logger.rb
CHANGED
data/lib/tailor/problem.rb
CHANGED
@@ -9,7 +9,10 @@ class Tailor
|
|
9
9
|
include LogSwitch::Mixin
|
10
10
|
|
11
11
|
# @param [Symbol] type The problem type.
|
12
|
-
# @param [
|
12
|
+
# @param [Fixnum] line The line of the file the problem was found on.
|
13
|
+
# @param [Fixnum] column The column of the file line the problem was found on.
|
14
|
+
# @param [String] message The message to tell the user about the problem.
|
15
|
+
# @param [Fixnum] level The severity of the problem.
|
13
16
|
def initialize(type, line, column, message, level)
|
14
17
|
@type = type
|
15
18
|
@line = line
|
data/lib/tailor/rake_task.rb
CHANGED
@@ -124,7 +124,10 @@ class Tailor
|
|
124
124
|
configuration = Tailor::Configuration.new([],
|
125
125
|
Tailor::CLI::Options.parse!(@tailor_opts))
|
126
126
|
configuration.load!
|
127
|
-
|
127
|
+
|
128
|
+
unless formatters.nil? || formatters.empty?
|
129
|
+
configuration.formatters(formatters)
|
130
|
+
end
|
128
131
|
|
129
132
|
configuration
|
130
133
|
end
|
data/lib/tailor/reporter.rb
CHANGED
@@ -44,9 +44,9 @@ class Tailor
|
|
44
44
|
@formatters.each do |formatter|
|
45
45
|
summary = formatter.summary_report(all_problems)
|
46
46
|
if formatter.respond_to?(:accepts_output_file) &&
|
47
|
-
|
48
|
-
|
49
|
-
File.open(opts[:output_file],
|
47
|
+
formatter.accepts_output_file &&
|
48
|
+
!opts[:output_file].empty?
|
49
|
+
File.open(opts[:output_file], 'w') { |f| f.puts summary }
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
data/lib/tailor/ruler.rb
CHANGED
@@ -27,7 +27,7 @@ class Tailor
|
|
27
27
|
# to publish events (in this case, characters or string Ruby constructs) of
|
28
28
|
# interest to its observers. Rulers subscribe to those events so that they
|
29
29
|
# can detect the problems they're looking for. These are defined as a Set in
|
30
|
-
#
|
30
|
+
# +@lexer_observers+. Adding to that list means the Ruler will subscribe to
|
31
31
|
# those events.
|
32
32
|
#
|
33
33
|
# Example:
|
@@ -78,7 +78,7 @@ class Tailor
|
|
78
78
|
# Each ruler should redefine this for its needs.
|
79
79
|
def measure(*args)
|
80
80
|
raise RuntimeError,
|
81
|
-
|
81
|
+
'Ruler#measure called, but should be redefined by a real ruler.'
|
82
82
|
end
|
83
83
|
|
84
84
|
# Converts the {Tailor::Ruler} name to snake case.
|
@@ -10,7 +10,7 @@ class Tailor
|
|
10
10
|
|
11
11
|
def ident_update(token, lexed_line, lineno, column)
|
12
12
|
ident_index = lexed_line.event_index(column)
|
13
|
-
find_event = lexed_line.find { |e| e[1] == :on_kw && e.last ==
|
13
|
+
find_event = lexed_line.find { |e| e[1] == :on_kw && e.last == 'def' }
|
14
14
|
|
15
15
|
if find_event && find_event.any?
|
16
16
|
measure(token, lineno, column)
|
@@ -24,7 +24,7 @@ class Tailor
|
|
24
24
|
# @param [Fixnum] column Column the problem was found on.
|
25
25
|
def measure(token, lineno, column)
|
26
26
|
if token.contains_capital_letter?
|
27
|
-
problem_message =
|
27
|
+
problem_message = 'Camel-case method name found.'
|
28
28
|
|
29
29
|
@problems << Problem.new(problem_type, lineno, column,
|
30
30
|
problem_message, @options[:level])
|
@@ -19,7 +19,7 @@ class Tailor
|
|
19
19
|
# @param [Fixnum] column Column the problem was found on.
|
20
20
|
def measure(token, lineno, column)
|
21
21
|
if token.contains_hard_tab?
|
22
|
-
problem_message =
|
22
|
+
problem_message = 'Hard tab found.'
|
23
23
|
|
24
24
|
@problems << Problem.new(problem_type, lineno, column,
|
25
25
|
problem_message, @options[:level])
|
@@ -16,7 +16,7 @@ class Tailor
|
|
16
16
|
return if previous_event.nil?
|
17
17
|
|
18
18
|
if previous_event[1] == :on_kw &&
|
19
|
-
(previous_event.last ==
|
19
|
+
(previous_event.last == 'class' || previous_event.last == 'module')
|
20
20
|
measure(token, lineno, column)
|
21
21
|
end
|
22
22
|
end
|
@@ -28,7 +28,7 @@ class Tailor
|
|
28
28
|
# @param [Fixnum] column Column the potential problem is on.
|
29
29
|
def measure(token, lineno, column)
|
30
30
|
if token.screaming_snake_case?
|
31
|
-
problem_message =
|
31
|
+
problem_message = 'Screaming-snake-case class/module found.'
|
32
32
|
|
33
33
|
@problems << Problem.new(problem_type, lineno, column,
|
34
34
|
problem_message, @options[:level])
|
@@ -31,14 +31,14 @@ class Tailor
|
|
31
31
|
|
32
32
|
def comment_update(token, lexed_line, file_text, lineno, column)
|
33
33
|
if token.fake_backslash_line_end?
|
34
|
-
log
|
34
|
+
log 'Line was altered by tailor to accommodate trailing backslash'
|
35
35
|
@manager.add_indent_reason(:trailing_backslash, :trailing_backslash,
|
36
36
|
lineno)
|
37
37
|
end
|
38
38
|
|
39
39
|
# trailing comment?
|
40
40
|
if token.ends_with_newline?
|
41
|
-
log
|
41
|
+
log 'Comment ends with newline. Removing comment...'
|
42
42
|
log "Old lexed line: #{lexed_line.inspect}"
|
43
43
|
|
44
44
|
new_lexed_line = lexed_line.remove_trailing_comment(file_text)
|
@@ -46,10 +46,10 @@ class Tailor
|
|
46
46
|
log "New lexed line: #{new_lexed_line.inspect}"
|
47
47
|
|
48
48
|
if new_lexed_line.ends_with_ignored_nl?
|
49
|
-
log
|
49
|
+
log 'New lexed line ends with :on_ignored_nl.'
|
50
50
|
ignored_nl_update(new_lexed_line, lineno, column)
|
51
51
|
elsif new_lexed_line.ends_with_nl?
|
52
|
-
log
|
52
|
+
log 'New lexed line ends with :on_nl.'
|
53
53
|
nl_update(new_lexed_line, lineno, column)
|
54
54
|
end
|
55
55
|
end
|
@@ -69,11 +69,11 @@ class Tailor
|
|
69
69
|
@embexpr_nesting.pop
|
70
70
|
|
71
71
|
if @manager.multi_line_braces?(lineno)
|
72
|
-
log
|
72
|
+
log 'End of multi-line braces!'
|
73
73
|
|
74
74
|
if current_lexed_line.only_embexpr_end?
|
75
75
|
@manager.amount_to_change_this -= 1
|
76
|
-
msg =
|
76
|
+
msg = 'lonely embexpr_end. '
|
77
77
|
msg << "change_this -= 1 -> #{@manager.amount_to_change_this}"
|
78
78
|
log msg
|
79
79
|
end
|
@@ -86,21 +86,21 @@ class Tailor
|
|
86
86
|
log "indent reasons on entry: #{@manager.indent_reasons}"
|
87
87
|
|
88
88
|
if current_lexed_line.only_spaces?
|
89
|
-
log
|
89
|
+
log 'Line of only spaces. Moving on.'
|
90
90
|
# todo: maybe i shouldn't return here? ...do transitions?
|
91
91
|
return
|
92
92
|
end
|
93
93
|
|
94
94
|
if @manager.line_ends_with_single_token_indenter?(current_lexed_line)
|
95
|
-
log
|
95
|
+
log 'Line ends with single-token indent token.'
|
96
96
|
|
97
97
|
unless @manager.in_an_enclosure? &&
|
98
98
|
current_lexed_line.ends_with_comma?
|
99
|
-
log
|
99
|
+
log 'Line-ending single-token indenter found.'
|
100
100
|
token_event = current_lexed_line.last_non_line_feed_event
|
101
101
|
|
102
102
|
unless @manager.line_ends_with_same_as_last token_event
|
103
|
-
msg =
|
103
|
+
msg = 'Line ends with different type of single-token '
|
104
104
|
msg << "indenter: #{token_event}"
|
105
105
|
log msg
|
106
106
|
@manager.add_indent_reason(token_event[1], token_event.last,
|
@@ -124,7 +124,7 @@ class Tailor
|
|
124
124
|
return
|
125
125
|
end
|
126
126
|
|
127
|
-
if token ==
|
127
|
+
if token == 'end'
|
128
128
|
@manager.update_for_closing_reason(:on_kw, lexed_line)
|
129
129
|
return
|
130
130
|
end
|
@@ -166,7 +166,7 @@ class Tailor
|
|
166
166
|
@manager.last_indent_reason_type != :on_lparen &&
|
167
167
|
!@manager.last_indent_reason_type.nil?
|
168
168
|
log "last indent reason type: #{@manager.last_indent_reason_type}"
|
169
|
-
log
|
169
|
+
log 'I think this is a single-token closing line...'
|
170
170
|
|
171
171
|
@manager.update_for_closing_reason(@manager.indent_reasons.
|
172
172
|
last[:event_type], current_lexed_line)
|
@@ -195,20 +195,22 @@ class Tailor
|
|
195
195
|
def rbrace_update(current_lexed_line, lineno, column)
|
196
196
|
# Is this an rbrace that should've been parsed as an embexpr_end?
|
197
197
|
if in_embexpr? && RUBY_VERSION < '2.0.0'
|
198
|
-
msg =
|
199
|
-
msg <<
|
198
|
+
msg = 'Got :rbrace and @embexpr_beg is true. '
|
199
|
+
msg << ' Must be at an @embexpr_end.'
|
200
200
|
log msg
|
201
201
|
@embexpr_nesting.pop
|
202
|
-
@manager.update_for_closing_reason(:on_embexpr_end,
|
202
|
+
@manager.update_for_closing_reason(:on_embexpr_end,
|
203
|
+
current_lexed_line)
|
204
|
+
|
203
205
|
return
|
204
206
|
end
|
205
207
|
|
206
208
|
if @manager.multi_line_braces?(lineno)
|
207
|
-
log
|
209
|
+
log 'End of multi-line braces!'
|
208
210
|
|
209
211
|
if current_lexed_line.only_rbrace?
|
210
212
|
@manager.amount_to_change_this -= 1
|
211
|
-
msg =
|
213
|
+
msg = 'lonely rbrace. '
|
212
214
|
msg << "change_this -= 1 -> #{@manager.amount_to_change_this}"
|
213
215
|
log msg
|
214
216
|
end
|
@@ -219,11 +221,11 @@ class Tailor
|
|
219
221
|
|
220
222
|
def rbracket_update(current_lexed_line, lineno, column)
|
221
223
|
if @manager.multi_line_brackets?(lineno)
|
222
|
-
log
|
224
|
+
log 'End of multi-line brackets!'
|
223
225
|
|
224
226
|
if current_lexed_line.only_rbracket?
|
225
227
|
@manager.amount_to_change_this -= 1
|
226
|
-
msg =
|
228
|
+
msg = 'lonely rbracket. '
|
227
229
|
msg << "change_this -= 1 -> #{@manager.amount_to_change_this}"
|
228
230
|
log msg
|
229
231
|
end
|
@@ -234,11 +236,11 @@ class Tailor
|
|
234
236
|
|
235
237
|
def rparen_update(current_lexed_line, lineno, column)
|
236
238
|
if @manager.multi_line_parens?(lineno)
|
237
|
-
log
|
239
|
+
log 'End of multi-line parens!'
|
238
240
|
|
239
241
|
if current_lexed_line.only_rparen?
|
240
242
|
@manager.amount_to_change_this -= 1
|
241
|
-
msg =
|
243
|
+
msg = 'lonely rparen. '
|
242
244
|
msg << "change_this -= 1 -> #{@manager.amount_to_change_this}"
|
243
245
|
log msg
|
244
246
|
end
|
@@ -275,7 +277,7 @@ class Tailor
|
|
275
277
|
# @param [Fixnum] lineno The line the potential problem is on.
|
276
278
|
# @param [Fixnum] column The column the potential problem is on.
|
277
279
|
def measure(lineno, column)
|
278
|
-
log
|
280
|
+
log 'Measuring...'
|
279
281
|
|
280
282
|
if @manager.actual_indentation != @manager.should_be_at
|
281
283
|
msg = "Line is indented to column #{@manager.actual_indentation}, "
|