Skip to content

Commit 8c7587e

Browse files
committed
(MAINT) Rubocop: Fix up method parameter naming issues
1 parent 7494362 commit 8c7587e

File tree

4 files changed

+33
-30
lines changed

4 files changed

+33
-30
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,3 +596,6 @@ Style/HashTransformKeys:
596596
Style/HashTransformValues:
597597
Enabled: false # requires Ruby 2.4
598598

599+
Naming/MethodParameterName:
600+
Enabled: true
601+
AllowedNames: [ o ]

lib/puppet-strings/markdown/function.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ def type
3232
end
3333
end
3434

35-
def error_type(r) # rubocop:disable Naming/UncommunicativeMethodParamName
36-
"`#{r.split(' ')[0]}`"
35+
def error_type(type)
36+
"`#{type.split(' ')[0]}`"
3737
end
3838

39-
def error_text(r) # rubocop:disable Naming/UncommunicativeMethodParamName
40-
"#{r.split(' ').drop(1).join(' ')}"
39+
def error_text(text)
40+
"#{text.split(' ').drop(1).join(' ')}"
4141
end
4242
end
4343

lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -144,72 +144,72 @@ def literal(ast)
144144
end
145145

146146
# ----- The following methods are different/additions from the original Literal_evaluator
147-
def literal_Object(o) # rubocop:disable Naming/UncommunicativeMethodParamName
147+
def literal_Object(o)
148148
# Ignore any other object types
149149
end
150150

151-
def literal_AccessExpression(o) # rubocop:disable Naming/UncommunicativeMethodParamName
151+
def literal_AccessExpression(o)
152152
# Extract the raw text of the Access Expression
153153
::Puppet::Pops::Adapters::SourcePosAdapter.adapt(o).extract_text
154154
end
155155

156-
def literal_QualifiedReference(o) # rubocop:disable Naming/UncommunicativeMethodParamName
156+
def literal_QualifiedReference(o)
157157
# Extract the raw text of the Qualified Reference
158158
::Puppet::Pops::Adapters::SourcePosAdapter.adapt(o).extract_text
159159
end
160160

161161
# ----- The following methods are the same as the original Literal_evaluator
162-
def literal_Factory(o) # rubocop:disable Naming/UncommunicativeMethodParamName
162+
def literal_Factory(o)
163163
literal(o.model)
164164
end
165165

166-
def literal_Program(o) # rubocop:disable Naming/UncommunicativeMethodParamName
166+
def literal_Program(o)
167167
literal(o.body)
168168
end
169169

170-
def literal_LiteralString(o) # rubocop:disable Naming/UncommunicativeMethodParamName
170+
def literal_LiteralString(o)
171171
o.value
172172
end
173173

174-
def literal_QualifiedName(o) # rubocop:disable Naming/UncommunicativeMethodParamName
174+
def literal_QualifiedName(o)
175175
o.value
176176
end
177177

178-
def literal_LiteralNumber(o) # rubocop:disable Naming/UncommunicativeMethodParamName
178+
def literal_LiteralNumber(o)
179179
o.value
180180
end
181181

182-
def literal_UnaryMinusExpression(o) # rubocop:disable Naming/UncommunicativeMethodParamName
182+
def literal_UnaryMinusExpression(o)
183183
-1 * literal(o.expr)
184184
end
185185

186-
def literal_LiteralBoolean(o) # rubocop:disable Naming/UncommunicativeMethodParamName
186+
def literal_LiteralBoolean(o)
187187
o.value
188188
end
189189

190-
def literal_LiteralUndef(o) # rubocop:disable Naming/UncommunicativeMethodParamName
190+
def literal_LiteralUndef(o)
191191
nil
192192
end
193193

194-
def literal_LiteralDefault(o) # rubocop:disable Naming/UncommunicativeMethodParamName
194+
def literal_LiteralDefault(o)
195195
:default
196196
end
197197

198-
def literal_LiteralRegularExpression(o) # rubocop:disable Naming/UncommunicativeMethodParamName
198+
def literal_LiteralRegularExpression(o)
199199
o.value
200200
end
201201

202-
def literal_ConcatenatedString(o) # rubocop:disable Naming/UncommunicativeMethodParamName
202+
def literal_ConcatenatedString(o)
203203
# use double quoted string value if there is no interpolation
204204
throw :not_literal unless o.segments.size == 1 && o.segments[0].is_a?(Model::LiteralString)
205205
o.segments[0].value
206206
end
207207

208-
def literal_LiteralList(o) # rubocop:disable Naming/UncommunicativeMethodParamName
208+
def literal_LiteralList(o)
209209
o.values.map { |v| literal(v) }
210210
end
211211

212-
def literal_LiteralHash(o) # rubocop:disable Naming/UncommunicativeMethodParamName
212+
def literal_LiteralHash(o)
213213
o.entries.reduce({}) do |result, entry|
214214
result[literal(entry.key)] = literal(entry.value)
215215
result

lib/puppet-strings/yard/parsers/puppet/parser.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def parse
2828
return
2929
end
3030
@statements ||= (@visitor.visit(::Puppet::Pops::Parser::Parser.new.parse_string(source)) || []).compact
31-
rescue ::Puppet::ParseError => ex
32-
log.error "Failed to parse #{@file}: #{ex.message}"
31+
rescue ::Puppet::ParseError => e
32+
log.error "Failed to parse #{@file}: #{e.message}"
3333
@statements = []
3434
end
3535
@statements.freeze
@@ -44,47 +44,47 @@ def enumerator
4444

4545
private
4646

47-
def transform_Program(o) # rubocop:disable Naming/UncommunicativeMethodParamName
47+
def transform_Program(o)
4848
# Cache the lines of the source text; we'll use this to locate comments
4949
@lines = o.source_text.lines.to_a
5050
o.definitions.map { |d| @visitor.visit(d) }
5151
end
5252

53-
def transform_Factory(o) # rubocop:disable Naming/UncommunicativeMethodParamName
53+
def transform_Factory(o)
5454
@visitor.visit(o.current)
5555
end
5656

57-
def transform_HostClassDefinition(o) # rubocop:disable Naming/UncommunicativeMethodParamName
57+
def transform_HostClassDefinition(o)
5858
statement = PuppetStrings::Yard::Parsers::Puppet::ClassStatement.new(o, @file)
5959
statement.extract_docstring(@lines)
6060
statement
6161
end
6262

63-
def transform_ResourceTypeDefinition(o) # rubocop:disable Naming/UncommunicativeMethodParamName
63+
def transform_ResourceTypeDefinition(o)
6464
statement = PuppetStrings::Yard::Parsers::Puppet::DefinedTypeStatement.new(o, @file)
6565
statement.extract_docstring(@lines)
6666
statement
6767
end
6868

69-
def transform_FunctionDefinition(o) # rubocop:disable Naming/UncommunicativeMethodParamName
69+
def transform_FunctionDefinition(o)
7070
statement = PuppetStrings::Yard::Parsers::Puppet::FunctionStatement.new(o, @file)
7171
statement.extract_docstring(@lines)
7272
statement
7373
end
7474

75-
def transform_PlanDefinition(o) # rubocop:disable Naming/UncommunicativeMethodParamName
75+
def transform_PlanDefinition(o)
7676
statement = PuppetStrings::Yard::Parsers::Puppet::PlanStatement.new(o, @file)
7777
statement.extract_docstring(@lines)
7878
statement
7979
end
8080

81-
def transform_TypeAlias(o) # rubocop:disable Naming/UncommunicativeMethodParamName
81+
def transform_TypeAlias(o)
8282
statement = PuppetStrings::Yard::Parsers::Puppet::DataTypeAliasStatement.new(o, @file)
8383
statement.extract_docstring(@lines)
8484
statement
8585
end
8686

87-
def transform_Object(o) # rubocop:disable Naming/UncommunicativeMethodParamName
87+
def transform_Object(o)
8888
# Ignore anything else (will be compacted out of the resulting array)
8989
end
9090
end

0 commit comments

Comments
 (0)