Skip to content

Commit 554eb96

Browse files
authored
Merge pull request #9183 from mhashizume/PUP-11771/main/rubocop-naming
(PUP-11771) Rubocop Naming Cops
2 parents 775592c + 40d11ec commit 554eb96

Some content is hidden

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

44 files changed

+164
-158
lines changed

.rubocop.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,86 @@ Metrics/ParameterLists:
5454

5555
Metrics/PerceivedComplexity:
5656
Enabled: false
57+
58+
Naming/AccessorMethodName:
59+
Enabled: false
60+
61+
Naming/BinaryOperatorParameterName:
62+
Enabled: false
63+
64+
Naming/BlockParameterName:
65+
Exclude:
66+
- 'lib/puppet/util/windows/daemon.rb'
67+
- 'lib/puppet/util/windows/user.rb'
68+
69+
Naming/ClassAndModuleCamelCase:
70+
Exclude:
71+
- 'lib/puppet/ffi/windows/structs.rb'
72+
- 'lib/puppet/pops/validation/checker4_0.rb'
73+
- 'lib/puppet/pops/validation/validator_factory_4_0.rb'
74+
- 'lib/puppet/util/windows/root_certs.rb'
75+
- 'lib/puppet/util/windows/security.rb'
76+
- 'lib/puppet/util/windows/user.rb'
77+
78+
Naming/ConstantName:
79+
Exclude:
80+
- 'lib/puppet/graph/relationship_graph.rb'
81+
- 'lib/puppet/indirector/hiera.rb'
82+
- 'lib/puppet/provider/package/sun.rb'
83+
- 'lib/puppet/resource/type.rb'
84+
- 'lib/puppet/type/schedule.rb'
85+
- 'lib/puppet/type/tidy.rb'
86+
- 'lib/puppet/util.rb'
87+
- 'lib/puppet/util/colors.rb'
88+
- 'lib/puppet/util/execution.rb'
89+
- 'lib/puppet/util/symbolic_file_mode.rb'
90+
- 'lib/puppet/util/tagging.rb'
91+
- 'lib/puppet/util/windows/adsi.rb'
92+
- 'lib/puppet/util/windows/sid.rb'
93+
- 'lib/puppet/util/yaml.rb'
94+
95+
Naming/HeredocDelimiterNaming:
96+
Enabled: false
97+
98+
# Exclude existing violations to avoid breaking changes
99+
Naming/MemoizedInstanceVariableName:
100+
Exclude:
101+
- 'lib/puppet/module_tool/applications/installer.rb'
102+
- 'lib/puppet/pops/types/type_factory.rb'
103+
- 'lib/puppet/provider/package/portage.rb'
104+
- 'lib/puppet/resource.rb'
105+
106+
Naming/MethodName:
107+
Exclude:
108+
- 'lib/puppet/functions/**/*'
109+
- 'lib/puppet/parser/ast/pops_bridge.rb'
110+
- 'lib/puppet/pops/**/*'
111+
- 'lib/puppet/util/windows/**/*'
112+
113+
Naming/MethodParameterName:
114+
Enabled: false
115+
116+
Naming/PredicateName:
117+
ForbiddenPrefixes: []
118+
119+
Naming/RescuedExceptionsVariableName:
120+
Enabled: false
121+
122+
Naming/VariableName:
123+
Exclude:
124+
- 'ext/windows/service/daemon.rb'
125+
- 'lib/puppet/agent.rb'
126+
- 'lib/puppet/application/describe.rb'
127+
- 'lib/puppet/pops/lookup/hiera_config.rb'
128+
- 'lib/puppet/pops/validation/checker4_0.rb'
129+
- 'lib/puppet/provider/package/pip.rb'
130+
- 'lib/puppet/provider/package/windows/exe_package.rb'
131+
- 'lib/puppet/provider/package/windows/msi_package.rb'
132+
- 'lib/puppet/ssl/ssl_provider.rb'
133+
- 'lib/puppet/util/windows/adsi.rb'
134+
- 'lib/puppet/util/windows/daemon.rb'
135+
- 'lib/puppet/util/windows/error.rb'
136+
- 'lib/puppet/util/windows/user.rb'
137+
138+
Naming/VariableNumber:
139+
Enabled: false

.rubocop_todo.yml

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -643,104 +643,6 @@ Lint/ToJSON:
643643
Lint/UnusedMethodArgument:
644644
Enabled: false
645645

646-
Naming/AccessorMethodName:
647-
Enabled: false
648-
649-
# This cop supports safe auto-correction (--auto-correct).
650-
Naming/BinaryOperatorParameterName:
651-
Enabled: false
652-
653-
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
654-
Naming/BlockParameterName:
655-
Exclude:
656-
- 'lib/puppet/util/windows/daemon.rb'
657-
- 'lib/puppet/util/windows/user.rb'
658-
659-
# Configuration parameters: AllowedNames.
660-
# AllowedNames: module_parent
661-
Naming/ClassAndModuleCamelCase:
662-
Exclude:
663-
- 'lib/puppet/ffi/windows/structs.rb'
664-
- 'lib/puppet/pops/validation/checker4_0.rb'
665-
- 'lib/puppet/pops/validation/validator_factory_4_0.rb'
666-
- 'lib/puppet/util/windows/root_certs.rb'
667-
- 'lib/puppet/util/windows/security.rb'
668-
- 'lib/puppet/util/windows/user.rb'
669-
670-
Naming/ConstantName:
671-
Exclude:
672-
- 'lib/puppet/graph/relationship_graph.rb'
673-
- 'lib/puppet/indirector/hiera.rb'
674-
- 'lib/puppet/provider/package/sun.rb'
675-
- 'lib/puppet/resource/type.rb'
676-
- 'lib/puppet/type/schedule.rb'
677-
- 'lib/puppet/type/tidy.rb'
678-
- 'lib/puppet/util.rb'
679-
- 'lib/puppet/util/colors.rb'
680-
- 'lib/puppet/util/execution.rb'
681-
- 'lib/puppet/util/symbolic_file_mode.rb'
682-
- 'lib/puppet/util/tagging.rb'
683-
- 'lib/puppet/util/windows/adsi.rb'
684-
- 'lib/puppet/util/windows/sid.rb'
685-
- 'lib/puppet/util/yaml.rb'
686-
687-
# Configuration parameters: ForbiddenDelimiters.
688-
# ForbiddenDelimiters: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$))
689-
Naming/HeredocDelimiterNaming:
690-
Enabled: false
691-
692-
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
693-
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
694-
Naming/MemoizedInstanceVariableName:
695-
Enabled: false
696-
697-
# Configuration parameters: EnforcedStyle, AllowedPatterns, IgnoredPatterns.
698-
# SupportedStyles: snake_case, camelCase
699-
Naming/MethodName:
700-
Enabled: false
701-
702-
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
703-
# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
704-
Naming/MethodParameterName:
705-
Enabled: false
706-
707-
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
708-
# NamePrefix: is_, has_, have_
709-
# ForbiddenPrefixes: is_, has_, have_
710-
# AllowedMethods: is_a?
711-
# MethodDefinitionMacros: define_method, define_singleton_method
712-
Naming/PredicateName:
713-
Enabled: false
714-
715-
# This cop supports safe auto-correction (--auto-correct).
716-
# Configuration parameters: PreferredName.
717-
Naming/RescuedExceptionsVariableName:
718-
Enabled: false
719-
720-
# Configuration parameters: EnforcedStyle, AllowedIdentifiers.
721-
# SupportedStyles: snake_case, camelCase
722-
Naming/VariableName:
723-
Exclude:
724-
- 'ext/windows/service/daemon.rb'
725-
- 'lib/puppet/agent.rb'
726-
- 'lib/puppet/application/describe.rb'
727-
- 'lib/puppet/pops/lookup/hiera_config.rb'
728-
- 'lib/puppet/pops/validation/checker4_0.rb'
729-
- 'lib/puppet/provider/package/pip.rb'
730-
- 'lib/puppet/provider/package/windows/exe_package.rb'
731-
- 'lib/puppet/provider/package/windows/msi_package.rb'
732-
- 'lib/puppet/ssl/ssl_provider.rb'
733-
- 'lib/puppet/util/windows/adsi.rb'
734-
- 'lib/puppet/util/windows/daemon.rb'
735-
- 'lib/puppet/util/windows/error.rb'
736-
- 'lib/puppet/util/windows/user.rb'
737-
738-
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers.
739-
# SupportedStyles: snake_case, normalcase, non_integer
740-
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339
741-
Naming/VariableNumber:
742-
Enabled: false
743-
744646
# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols.
745647
# SupportedStyles: inline, group
746648
Style/AccessModifierDeclarations:

lib/puppet/etc.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def group
132132
# these fields as well. API compatible with Etc::Passwd. Because Struct.new
133133
# defines a new Class object, we memoize to avoid superfluous extra Class
134134
# instantiations.
135+
# rubocop:disable Naming/MemoizedInstanceVariableName
135136
def puppet_etc_passwd_class
136137
@password_class ||= Struct.new(*Etc::Passwd.members, *Etc::Passwd.members.map { |member| "canonical_#{member}".to_sym })
137138
end
@@ -145,6 +146,7 @@ def puppet_etc_passwd_class
145146
def puppet_etc_group_class
146147
@group_class ||= Struct.new(*Etc::Group.members, *Etc::Group.members.map { |member| "canonical_#{member}".to_sym })
147148
end
149+
# rubocop:enable Naming/MemoizedInstanceVariableName
148150

149151
# Utility method for overriding the String values of a struct returned by
150152
# the Etc module to UTF-8. Structs returned by the ruby Etc module contain

lib/puppet/feature/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ module WindowsSymlink
5757
require 'ffi'
5858
extend FFI::Library
5959

60-
def self.is_implemented
60+
def self.is_implemented # rubocop:disable Naming/PredicateName
6161
begin
6262
ffi_lib :kernel32
6363
attach_function :CreateSymbolicLinkW, [:lpwstr, :lpwstr, :dword], :boolean

lib/puppet/forge.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ def prepare
195195
# Obtain a suitable temporary path for unpacking tarballs
196196
#
197197
# @return [Pathname] path to temporary unpacking location
198+
# rubocop:disable Naming/MemoizedInstanceVariableName
198199
def tmpdir
199200
@dir ||= Dir.mktmpdir(name, Puppet::Forge::Cache.base_path)
200201
end
@@ -204,6 +205,7 @@ def tmpfile
204205
f.binmode
205206
end
206207
end
208+
# rubocop:enable Naming/MemoizedInstanceVariableName
207209

208210
def download(uri, destination)
209211
response = @source.make_http_request(uri, destination)

lib/puppet/functions/defined.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
required_repeated_param 'Variant[String, Type[CatalogEntry], Type[Type[CatalogEntry]]]', :vals
108108
end
109109

110-
def is_defined(scope, *vals)
110+
def is_defined(scope, *vals) # rubocop:disable Naming/PredicateName
111111
vals.any? do |val|
112112
case val
113113
when String

lib/puppet/module_tool/applications/installer.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -395,18 +395,6 @@ def resolve_install_conflicts(graph, is_dependency = false)
395395
end
396396
end
397397
end
398-
399-
#
400-
# Check if a file is a vaild module package.
401-
# ---
402-
# FIXME: Checking for a valid module package should be more robust and
403-
# use the actual metadata contained in the package. 03132012 - Hightower
404-
# +++
405-
#
406-
def is_module_package?(name)
407-
filename = File.expand_path(name)
408-
filename =~ /.tar.gz$/
409-
end
410398
end
411399
end
412400
end

lib/puppet/module_tool/applications/unpacker.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ def move_into(dir)
9393
#
9494
# @api private
9595
# @return [String] path to temporary unpacking location
96+
# rubocop:disable Naming/MemoizedInstanceVariableName
9697
def tmpdir
9798
@dir ||= Dir.mktmpdir('tmp', Puppet::Forge::Cache.base_path)
9899
end
100+
# rubocop:enable Naming/MemoizedInstanceVariableName
99101
end
100102
end
101103
end

lib/puppet/module_tool/applications/upgrader.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,15 @@ def installed_release.priority
220220
end
221221

222222
private
223+
# rubocop:disable Naming/MemoizedInstanceVariableName
223224
def module_repository
224225
@repo ||= Puppet::Forge.new(Puppet[:module_repository])
225226
end
226227

227228
def installed_modules_source
228229
@installed ||= Puppet::ModuleTool::InstalledModules.new(@environment)
229230
end
231+
# rubocop:enable Naming/MemoizedInstanceVariableName
230232

231233
def installed_modules
232234
installed_modules_source.modules

lib/puppet/module_tool/local_tarball.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ def prepare
7676
# Obtain a suitable temporary path for unpacking tarballs
7777
#
7878
# @return [String] path to temporary unpacking location
79+
# rubocop:disable Naming/MemoizedInstanceVariableName
7980
def tmpdir
8081
@dir ||= Dir.mktmpdir('local-tarball', Puppet::Forge::Cache.base_path)
8182
end
83+
# rubocop:enable Naming/MemoizedInstanceVariableName
8284

8385
def unpack(file, destination)
8486
begin

0 commit comments

Comments
 (0)