@@ -3,8 +3,8 @@ module TwoFer
3
3
MESSAGES = {
4
4
no_module : "No module or class called TwoFer" ,
5
5
no_method : "No method called two_fer" ,
6
- splat_args : "Rather than using *%s, how about acutally setting a paramater called 'name'?" ,
7
- missing_default_param : "There is not a correct default param - the tests will fail" ,
6
+ splat_args : "Rather than using *%s, how about actually setting a parameter called 'name'?" ,
7
+ missing_default_param : "There is no correct default param - the tests will fail" ,
8
8
incorrect_default_param : "You could set the default value to 'you' to avoid conditionals" ,
9
9
string_building : "Rather than using string building, use interpolation" ,
10
10
kernel_format : "Rather than using the format method, use interpolation" ,
@@ -29,7 +29,7 @@ def analyze!
29
29
check_method_signature!
30
30
31
31
# There is one optimal solution for two-fer which needs
32
- # no commnents and can just be approved. If we have it, then
32
+ # no comments and can just be approved. If we have it, then
33
33
# let's just acknowledge it and get out of here.
34
34
check_for_optimal_solution!
35
35
@@ -40,14 +40,14 @@ def analyze!
40
40
check_for_correct_solution_without_string_interpolaton!
41
41
42
42
# The most common error in twofer is people using conditionals
43
- # to check where the value passed in is nil, rather than using a defaul
43
+ # to check where the value passed in is nil, rather than using a default
44
44
# value. We want to check for conditionals and tell the user about the
45
- # default paramater if we see one.
45
+ # default parameter if we see one.
46
46
check_for_conditional_on_default_argument!
47
47
48
- # Sometiems people specify the names (if name == "Alice" ...). If we
48
+ # Sometimes people specify the names (if name == "Alice" ...). If we
49
49
# do this, suggest using string interpolation to make us of the
50
- # paramter , rather than using a conditional on it.
50
+ # parameter , rather than using a conditional on it.
51
51
# check_for_names!
52
52
53
53
# We don't have any idea about this solution, so let's refer it to a
@@ -68,7 +68,7 @@ def check_structure!
68
68
def check_method_signature!
69
69
# If there is no parameter or it doesn't have a default value,
70
70
# then this solution won't pass the tests.
71
- disapprove! ( :missing_default_param ) if paramaters . size != 1
71
+ disapprove! ( :missing_default_param ) if parameters . size != 1
72
72
73
73
# If they provide a splat, the tests can pass but we
74
74
# should suggest they use a real paramater
@@ -101,7 +101,7 @@ def check_for_optimal_solution!
101
101
end
102
102
103
103
def check_for_correct_solution_without_string_interpolaton!
104
- # If we don't have a correct default argugment or a one line
104
+ # If we don't have a correct default argument or a one line
105
105
# solution then let's just get out of here.
106
106
return unless default_argument_is_optimal?
107
107
return unless one_line_solution?
@@ -133,7 +133,7 @@ def check_for_correct_solution_without_string_interpolaton!
133
133
end
134
134
135
135
# If we have a one-line method that passes the tests, then it's not
136
- # soemthing we've planned for, so let's refer it to a mentor
136
+ # something we've planned for, so let's refer it to a mentor
137
137
return refer_to_mentor!
138
138
end
139
139
@@ -142,11 +142,11 @@ def check_for_conditional_on_default_argument!
142
142
143
143
# If we don't have a conditional, then let's get out of here.
144
144
#
145
- # TODO: We might wnt to refactor this to extract a conditional from the
145
+ # TODO: We might want to refactor this to extract a conditional from the
146
146
# method rather than insist on it being the first line.
147
147
return unless loc . type == :if
148
148
149
- # Get the clause of the conditional (ie the bit after the "if" keyword)
149
+ # Get the clause of the conditional (i.e. the bit after the "if" keyword)
150
150
conditional = extract_conditional_clause ( loc )
151
151
152
152
# Let's warn about using a better default if they `if name == nil`
@@ -155,7 +155,7 @@ def check_for_conditional_on_default_argument!
155
155
disapprove! ( :incorrect_default_param )
156
156
end
157
157
158
- # Same thing but if they do it the other way round, ie `if nil == name`
158
+ # Same thing but if they do it the other way round, i.e. `if nil == name`
159
159
if conditional . receiver == default_argument &&
160
160
is_lvar? ( conditional . first_argument , :name )
161
161
disapprove! ( :incorrect_default_param )
0 commit comments