Skip to content

Commit

Permalink
String 'concatenation' instead of 'building'
Browse files Browse the repository at this point in the history
  • Loading branch information
iHiD committed Jul 2, 2019
1 parent 4a39f3a commit f51b21e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/analyzers/two_fer/analyze.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module TwoFer
missing_default_param: "ruby.two-fer.missing_default_param", # "There is no correct default param - the tests will fail"
incorrect_default_param: "ruby.two-fer.incorrect_default_param", # "You could set the default value to 'you' to avoid conditionals"
reassigning_param: "ruby.two-fer.reassigning_param", # "You don't need to reassign - use the default param"
string_building: "ruby.two-fer.avoid_string_building", # "Rather than using string building, use interpolation"
string_concatenation: "ruby.two-fer.avoid_string_concatenation", # "Rather than using string building, use interpolation"
kernel_format: "ruby.two-fer.avoid_kernel_format", # "Rather than using the format method, use interpolation"
string_format: "ruby.two-fer.avoid_string_format", # "Rather than using string's format/percentage method, use interpolation"
}
Expand Down Expand Up @@ -84,7 +84,7 @@ def check_for_single_line_solution!
end

# "One for " + name + ", one for me."
approve_if_implicit_return!(:string_building, {name_variable: solution.first_parameter_name}) if solution.uses_string_building?
approve_if_implicit_return!(:string_concatenation, {name_variable: solution.first_parameter_name}) if solution.uses_string_concatenation?

# format("One for %s, one for me.", name)
approve_if_implicit_return!(:kernel_format, {name_variable: solution.first_parameter_name}) if solution.uses_kernel_format?
Expand Down
2 changes: 1 addition & 1 deletion lib/analyzers/two_fer/representation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def string_interpolation_is_correct?
end

# "One for " + name + ", one for me."
def uses_string_building?
def uses_string_concatenation?
loc = single_line_body

loc.method_name == :+ &&
Expand Down
4 changes: 2 additions & 2 deletions test/exercises/two_fer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def self.two_fer(*foos)
# ### 
# Now let's guard against string building
# ###
def test_for_string_building
def test_for_string_concatenation
#skip
source = %q{
class TwoFer
Expand All @@ -160,7 +160,7 @@ def self.two_fer(name="you")
}
results = TwoFer::Analyze.(source)
assert_equal :approve, results[:status]
assert_equal [{comment: "ruby.two-fer.avoid_string_building", params: {name_variable: :name}}], results[:comments]
assert_equal [{comment: "ruby.two-fer.avoid_string_concatenation", params: {name_variable: :name}}], results[:comments]
end

def test_for_kernel_format
Expand Down

0 comments on commit f51b21e

Please sign in to comment.