Skip to content
This repository has been archived by the owner on Aug 1, 2020. It is now read-only.

Commit

Permalink
Cleaned up some style and aded docs for allow_unnecessary_interpolation.
Browse files Browse the repository at this point in the history
Closes gh-148
  • Loading branch information
turboladen committed Jan 23, 2014
1 parent f415d7f commit 48729f6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ project, whatever style that may be.
* Camel case method names
* Common syntax
* Conditionals wrapped in parentheses
* Unnecessary interpolation in strings
* Valid Ruby (warns by default)
* Configurable
* Specify style in
Expand Down
6 changes: 3 additions & 3 deletions lib/tailor/rulers/allow_unnecessary_interpolation_ruler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ def nl_update(lexed_line, lineno, column)
each_string(@tokens).each do |string|
measure(line_number(@tokens.first), string)
end

reset_tokens
end

# Checks if variables are interpolated unnecessarily
# Checks if variables are interpolated unnecessarily.
#
# @param [Array] tokens The filtered tokens
# @param [Array] tokens The filtered tokens.
def measure(lineno, tokens)
return if @config
if no_content?(tokens) and one_expression?(tokens)
Expand Down Expand Up @@ -81,7 +82,6 @@ def reset_tokens
def string_tokens(lexed_line)
lexed_line.select { |t| EVENTS.include?(t[1]) }
end

end
end
end
4 changes: 4 additions & 0 deletions lib/tailor/tailorrc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
# wrapped in parentheses.
# Default: true
#
# allow_unnecessary_interpolation
# Checks for unnecessary interpolation in strings.
# Default: false
#
Tailor.config do |config|
config.formatters "<%= formatters.join(', ') %>"
config.file_set '<%= file_list %>' do |style|<% style.each do |rule, value| %>
Expand Down

0 comments on commit 48729f6

Please sign in to comment.