Skip to content

Commit 40d11ec

Browse files
committed
Naming/PredicateName
This commit addresses the Rubocop Naming/PredicateName cop by either exempting public methods with predicate names or renaming private methods.
1 parent 1f8cf4b commit 40d11ec

File tree

15 files changed

+21
-23
lines changed

15 files changed

+21
-23
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ Naming/MethodName:
113113
Naming/MethodParameterName:
114114
Enabled: false
115115

116+
Naming/PredicateName:
117+
ForbiddenPrefixes: []
118+
116119
Naming/RescuedExceptionsVariableName:
117120
Enabled: false
118121

.rubocop_todo.yml

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

646-
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
647-
# NamePrefix: is_, has_, have_
648-
# ForbiddenPrefixes: is_, has_, have_
649-
# AllowedMethods: is_a?
650-
# MethodDefinitionMacros: define_method, define_singleton_method
651-
Naming/PredicateName:
652-
Enabled: false
653-
654646
# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols.
655647
# SupportedStyles: inline, group
656648
Style/AccessModifierDeclarations:

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/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/parameter.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,15 @@ def defaultto(value = nil, &block)
9292
end
9393
end
9494

95+
# rubocop:disable Naming/PredicateName
9596
def sensitive(value = nil, &block)
9697
if block
9798
define_method(:is_sensitive, &block)
9899
else
99100
define_method(:is_sensitive) do value end
100101
end
101102
end
103+
# rubocop:enable Naming/PredicateName
102104

103105
# Produces a documentation string.
104106
# If an enumeration of _valid values_ has been defined, it is appended to the documentation

lib/puppet/pops/validation/checker4_0.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,20 +622,20 @@ def initial_manifest?(path, manifest_setting)
622622
# if none is found.
623623
def get_module_relative_path(file_path, modulepath_directories)
624624
clean_file = file_path.cleanpath.to_s
625-
parent_path = modulepath_directories.find { |path_dir| is_parent_dir_of(path_dir, clean_file) }
625+
parent_path = modulepath_directories.find { |path_dir| is_parent_dir_of?(path_dir, clean_file) }
626626
return NO_PATH if parent_path.nil?
627627

628628
file_path.relative_path_from(Pathname.new(parent_path))
629629
end
630630
private :get_module_relative_path
631631

632-
def is_parent_dir_of(parent_dir, child_dir)
632+
def is_parent_dir_of?(parent_dir, child_dir)
633633
parent_dir_path = Pathname.new(parent_dir)
634634
clean_parent = parent_dir_path.cleanpath.to_s + File::SEPARATOR
635635

636636
return child_dir.start_with?(clean_parent)
637637
end
638-
private :is_parent_dir_of
638+
private :is_parent_dir_of?
639639

640640
def dir_to_names(relative_path)
641641
# Downcasing here because check is case-insensitive

lib/puppet/property.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def property_matches?(current, desired)
403403
# are not already in suitable form.
404404
# @param value [Object] the value to format as a string
405405
# @return [String] a pretty printing string
406-
def is_to_s(value)
406+
def is_to_s(value) # rubocop:disable Naming/PredicateName
407407
self.class.format_value_for_display(value)
408408
end
409409

lib/puppet/property/keyvalue.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def should_to_s(should_value)
3333
hash_to_key_value_s(should_value)
3434
end
3535

36-
def is_to_s(current_value)
36+
def is_to_s(current_value) # rubocop:disable Naming/PredicateName
3737
hash_to_key_value_s(current_value)
3838
end
3939

lib/puppet/property/list.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Property
88
#
99
class List < Property
1010

11-
def is_to_s(currentvalue)
11+
def is_to_s(currentvalue) # rubocop:disable Naming/PredicateName
1212
currentvalue == :absent ? super(currentvalue) : currentvalue.join(delimiter)
1313
end
1414

lib/puppet/provider.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def self.optional_commands(hash)
198198
# @note the name ´has_command´ looks odd in an API context, but makes more sense when seen in the internal
199199
# DSL context where a Provider is declaratively defined.
200200
# @api public
201-
#
201+
# rubocop:disable Naming/PredicateName
202202
def self.has_command(name, path, &block)
203203
name = name.intern
204204
command = CommandDefiner.define(name, path, self, &block)
@@ -210,6 +210,7 @@ def self.has_command(name, path, &block)
210210
return command.execute(*args)
211211
end
212212
end
213+
# rubocop:enable Naming/PredicateName
213214

214215
# Internal helper class when creating commands - undocumented.
215216
# @api private
@@ -230,7 +231,7 @@ def initialize(name, path, confiner)
230231
@custom_environment = {}
231232
end
232233

233-
def is_optional
234+
def is_optional # rubocop:disable Naming/PredicateName
234235
@optional = true
235236
end
236237

0 commit comments

Comments
 (0)