Skip to content

Commit 4a39f3a

Browse files
committed
Bring in line with new schema
1 parent a64a54b commit 4a39f3a

File tree

490 files changed

+74
-3357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

490 files changed

+74
-3357
lines changed

lib/analyzers/two_fer/analyze.rb

+17-20
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ module TwoFer
55
no_method: "ruby.general.no_target_method",
66
incorrect_indentation: "ruby.general.incorrect_indentation",
77
explicit_return: "ruby.general.explicit_return", # "The last line automatically gets returned"
8-
splat_args: "ruby.two_fer.splat_args", # "Rather than using *%s, how about actually setting a parameter called 'name'?"
9-
missing_default_param: "ruby.two_fer.missing_default_param", # "There is no correct default param - the tests will fail"
10-
incorrect_default_param: "ruby.two_fer.incorrect_default_param", # "You could set the default value to 'you' to avoid conditionals"
11-
reassigning_param: "ruby.two_fer.reassigning_param", # "You don't need to reassign - use the default param"
12-
string_building: "ruby.two_fer.avoid_string_building", # "Rather than using string building, use interpolation"
13-
kernel_format: "ruby.two_fer.avoid_kernel_format", # "Rather than using the format method, use interpolation"
14-
string_format: "ruby.two_fer.avoid_string_format", # "Rather than using string's format/percentage method, use interpolation"
8+
splat_args: "ruby.two-fer.splat_args", # "Rather than using *%s, how about actually setting a parameter called 'name'?"
9+
missing_default_param: "ruby.two-fer.missing_default_param", # "There is no correct default param - the tests will fail"
10+
incorrect_default_param: "ruby.two-fer.incorrect_default_param", # "You could set the default value to 'you' to avoid conditionals"
11+
reassigning_param: "ruby.two-fer.reassigning_param", # "You don't need to reassign - use the default param"
12+
string_building: "ruby.two-fer.avoid_string_building", # "Rather than using string building, use interpolation"
13+
kernel_format: "ruby.two-fer.avoid_kernel_format", # "Rather than using the format method, use interpolation"
14+
string_format: "ruby.two-fer.avoid_string_format", # "Rather than using string's format/percentage method, use interpolation"
1515
}
1616

1717
class Analyze < ExerciseAnalyzer
@@ -84,13 +84,13 @@ def check_for_single_line_solution!
8484
end
8585

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

8989
# format("One for %s, one for me.", name)
90-
approve_if_implicit_return!(:kernel_format) if solution.uses_kernel_format?
90+
approve_if_implicit_return!(:kernel_format, {name_variable: solution.first_parameter_name}) if solution.uses_kernel_format?
9191

9292
# "One for %s, one for me." % name
93-
approve_if_implicit_return!(:string_format) if solution.uses_string_format?
93+
approve_if_implicit_return!(:string_format, {name_variable: solution.first_parameter_name}) if solution.uses_string_format?
9494

9595
# If we have a one-line method that passes the tests, then it's not
9696
# something we've planned for, so let's refer it to a mentor
@@ -146,22 +146,19 @@ def check_for_names!
146146
# can probably be extracted to parent
147147
# ###
148148

149-
def approve_if_implicit_return!(msg = nil)
149+
def approve_if_implicit_return!(msg = nil, params = {})
150150
# If we're got a correct solution but they've given an explicit
151151
# return then let's warn them against that.
152152
disapprove!(:explicit_return) if solution.has_explicit_return?
153153

154-
approve_if_whitespace_is_sensible!(msg)
154+
approve_if_whitespace_is_sensible!(msg, params)
155155
end
156156

157-
def approve_if_whitespace_is_sensible!(msg = nil)
157+
def approve_if_whitespace_is_sensible!(msg = nil, params = {})
158158
if solution.indentation_is_sensible?
159-
if msg
160-
self.status = :approve_with_comment
161-
self.comments << MESSAGES[msg]
162-
else
163-
self.status = :approve_as_optimal
164-
end
159+
self.comments << {comment: MESSAGES[msg], params: params} if msg
160+
self.status = :approve
161+
165162
raise FinishedFlowControlException
166163

167164
else
@@ -176,7 +173,7 @@ def refer_to_mentor!
176173
end
177174

178175
def disapprove!(msg, *msg_args)
179-
self.status = :disapprove_with_comment
176+
self.status = :disapprove
180177
if msg_args.length > 0
181178
self.comments << [MESSAGES[msg], *msg_args]
182179
else

0 commit comments

Comments
 (0)