Skip to content

Commit 8d42434

Browse files
committed
(PUP-11993) Style/WordArray
This commit enables the Style/WordArray cop and fixes 41 autocorrectable offenses.
1 parent 27a5441 commit 8d42434

File tree

28 files changed

+53
-59
lines changed

28 files changed

+53
-59
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -776,12 +776,6 @@ Style/WhileUntilModifier:
776776
- 'lib/puppet/pops/types/p_object_type.rb'
777777
- 'lib/puppet/util/windows/process.rb'
778778

779-
# This cop supports safe auto-correction (--auto-correct).
780-
# Configuration parameters: EnforcedStyle, MinSize, WordRegex.
781-
# SupportedStyles: percent, brackets
782-
Style/WordArray:
783-
Enabled: false
784-
785779
# This cop supports unsafe auto-correction (--auto-correct-all).
786780
# Configuration parameters: EnforcedStyle.
787781
# SupportedStyles: forbid_for_all_comparison_operators, forbid_for_equality_operators_only, require_for_all_comparison_operators, require_for_equality_operators_only

lib/puppet/application/lookup.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class Puppet::Application::Lookup < Puppet::Application
99
RUN_HELP = _("Run 'puppet lookup --help' for more details").freeze
1010
DEEP_MERGE_OPTIONS = '--knock-out-prefix, --sort-merged-arrays, and --merge-hash-arrays'
11-
TRUSTED_INFORMATION_FACTS = ["hostname", "domain", "fqdn", "clientcert"].freeze
11+
TRUSTED_INFORMATION_FACTS = %w[hostname domain fqdn clientcert].freeze
1212

1313
run_mode :server
1414

lib/puppet/coercion.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ def self.boolean(value)
3737
# @raise
3838
# @api private
3939
def self.boolean_values
40-
['true', 'false', 'yes', 'no']
40+
%w[true false yes no]
4141
end
4242
end

lib/puppet/defaults.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def self.initialize_default_settings!(settings)
132132
:log_level => {
133133
:default => 'notice',
134134
:type => :enum,
135-
:values => ["debug","info","notice","warning","err","alert","emerg","crit"],
135+
:values => %w[debug info notice warning err alert emerg crit],
136136
:desc => "Default logging level for messages from Puppet. Allowed values are:
137137
138138
* debug

lib/puppet/external/dot.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,17 @@ def change_tab(t)
100100

101101
# options for graph declaration
102102

103-
GRAPH_OPTS = [
104-
'bgcolor',
105-
'center', 'clusterrank', 'color', 'concentrate',
106-
'fontcolor', 'fontname', 'fontsize',
107-
'label', 'layerseq',
108-
'margin', 'mclimit',
109-
'nodesep', 'nslimit',
110-
'ordering', 'orientation',
111-
'page',
112-
'rank', 'rankdir', 'ranksep', 'ratio',
113-
'size'
103+
GRAPH_OPTS = %w[
104+
bgcolor
105+
center clusterrank color concentrate
106+
fontcolor fontname fontsize
107+
label layerseq
108+
margin mclimit
109+
nodesep nslimit
110+
ordering orientation
111+
page
112+
rank rankdir ranksep ratio
113+
size
114114
]
115115

116116
# a root class for any element in dot notation

lib/puppet/functions.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -685,10 +685,10 @@ class Function3x < InternalFunction
685685
PARAM_NAMES = [
686686
[],
687687
['p0'].freeze,
688-
['p0', 'p1'].freeze,
689-
['p0', 'p1', 'p2'].freeze,
690-
['p0', 'p1', 'p2', 'p3'].freeze,
691-
['p0', 'p1', 'p2', 'p3', 'p4'].freeze
688+
%w[p0 p1].freeze,
689+
%w[p0 p1 p2].freeze,
690+
%w[p0 p1 p2 p3].freeze,
691+
%w[p0 p1 p2 p3 p4].freeze
692692
]
693693

694694
# Creates an anonymous Function3x class that wraps a 3x function

lib/puppet/indirector/facts/facter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def find(request)
5757
def self.setup_search_paths(request)
5858
# Add any per-module fact directories to facter's search path
5959
dirs = request.environment.modulepath.collect do |dir|
60-
['lib', 'plugins'].map do |subdirectory|
60+
%w[lib plugins].map do |subdirectory|
6161
Dir.glob("#{dir}/*/#{subdirectory}/facter")
6262
end
6363
end.flatten + Puppet[:factpath].split(File::PATH_SEPARATOR)

lib/puppet/network/http/handler.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Puppet::Network::HTTP::Handler
1313

1414
# These shouldn't be allowed to be set by clients
1515
# in the query string, for security reasons.
16-
DISALLOWED_KEYS = ["node", "ip"]
16+
DISALLOWED_KEYS = %w[node ip]
1717

1818
def register(routes)
1919
# There's got to be a simpler way to do this, right?

lib/puppet/parser/scope.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Puppet::Parser::Scope
1717
extend Forwardable
1818

1919
# Variables that always exist with nil value even if not set
20-
BUILT_IN_VARS = ['module_name', 'caller_module_name'].freeze
20+
BUILT_IN_VARS = %w[module_name caller_module_name].freeze
2121
EMPTY_HASH = {}.freeze
2222

2323
Puppet::Util.logmethods(self)

lib/puppet/pops/lookup/hiera_config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ def has_default_hierarchy?
723723
@config.include?(KEY_DEFAULT_HIERARCHY)
724724
end
725725

726-
RESERVED_OPTION_KEYS = ['path', 'uri'].freeze
726+
RESERVED_OPTION_KEYS = %w[path uri].freeze
727727

728728
DEFAULT_CONFIG_HASH = {
729729
KEY_VERSION => 5,

0 commit comments

Comments
 (0)