Skip to content

Commit 340038f

Browse files
committed
Naming/MethodName
Pops implements the visitor pattern and that relies on the convention of methods being namedoperation_Class. This commit excludes puppet/functions, puppet/pops, and puppet/util/windows from the Rubocop Naming/MethodName cop. Additionally, this commit updates the rpm_compareEVR methods in both Puppet::Util::Package::Version::Rpm and Puppet::Util::RpmCompare to instead be called rpm_compare_evr to adhere to snake case.
1 parent aca2f4b commit 340038f

File tree

7 files changed

+22
-20
lines changed

7 files changed

+22
-20
lines changed

.rubocop.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,12 @@ Naming/MemoizedInstanceVariableName:
9292
- 'lib/puppet/provider/package/portage.rb'
9393
- 'lib/puppet/resource.rb'
9494

95+
Naming/MethodName:
96+
Exclude:
97+
- 'lib/puppet/functions/**/*'
98+
- 'lib/puppet/parser/ast/pops_bridge.rb'
99+
- 'lib/puppet/pops/**/*'
100+
- 'lib/puppet/util/windows/**/*'
101+
95102
Naming/MethodParameterName:
96103
Enabled: false

.rubocop_todo.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -656,11 +656,6 @@ Naming/BlockParameterName:
656656
- 'lib/puppet/util/windows/daemon.rb'
657657
- 'lib/puppet/util/windows/user.rb'
658658

659-
# Configuration parameters: EnforcedStyle, AllowedPatterns, IgnoredPatterns.
660-
# SupportedStyles: snake_case, camelCase
661-
Naming/MethodName:
662-
Enabled: false
663-
664659
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
665660
# NamePrefix: is_, has_, have_
666661
# ForbiddenPrefixes: is_, has_, have_

lib/puppet/provider/package/rpm.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def insync?(is)
190190

191191
should = resource[:ensure]
192192
is.split(self.class::MULTIVERSION_SEPARATOR).any? do |version|
193-
0 == rpm_compareEVR(should, version)
193+
0 == rpm_compare_evr(should, version)
194194
end
195195
end
196196

lib/puppet/provider/package/yum.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ def install
292292
if @resource[:install_only]
293293
self.debug "Updating package #{@resource[:name]} from version #{current_package[:ensure]} to #{should} as install_only packages are never downgraded"
294294
operation = update_command
295-
elsif rpm_compareEVR(should, current_package[:ensure]) < 0
295+
elsif rpm_compare_evr(should, current_package[:ensure]) < 0
296296
self.debug "Downgrading package #{@resource[:name]} from version #{current_package[:ensure]} to #{should}"
297297
operation = :downgrade
298-
elsif rpm_compareEVR(should, current_package[:ensure]) > 0
298+
elsif rpm_compare_evr(should, current_package[:ensure]) > 0
299299
self.debug "Upgrading package #{@resource[:name]} from version #{current_package[:ensure]} to #{should}"
300300
operation = update_command
301301
end

lib/puppet/util/package/version/rpm.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ def eql?(other)
3939
def <=>(other)
4040
raise ArgumentError, _("Cannot compare, as %{other} is not a Rpm Version") % { other: other } unless other.is_a?(self.class)
4141

42-
rpm_compareEVR(self.to_s, other.to_s)
42+
rpm_compare_evr(self.to_s, other.to_s)
4343
end
4444

4545
private
4646

47-
# overwrite rpm_compareEVR to treat no epoch as zero epoch
47+
# overwrite rpm_compare_evr to treat no epoch as zero epoch
4848
# in order to compare version correctly
4949
#
5050
# returns 1 if a is newer than b,
5151
# 0 if they are identical
5252
# -1 if a is older than b
53-
def rpm_compareEVR(a, b)
53+
def rpm_compare_evr(a, b)
5454
a_hash = rpm_parse_evr(a)
5555
b_hash = rpm_parse_evr(b)
5656

lib/puppet/util/rpm_compare.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def compare_values(s1, s2)
165165
# return 1: a is newer than b
166166
# 0: a and b are the same version
167167
# -1: b is newer than a
168-
def rpm_compareEVR(should, is)
168+
def rpm_compare_evr(should, is)
169169
# pass on to rpm labelCompare
170170
should_hash = rpm_parse_evr(should)
171171
is_hash = rpm_parse_evr(is)

spec/unit/util/rpm_compare_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,35 +91,35 @@ class RpmTest
9191
it { expect(RpmTest.rpmvercmp('1', '0')).to eq(1) }
9292
end
9393

94-
describe '.rpm_compareEVR' do
94+
describe '.rpm_compare_evr' do
9595
it 'evaluates identical version-release as equal' do
96-
expect(RpmTest.rpm_compareEVR('1.2.3-1.el5', '1.2.3-1.el5')).to eq(0)
96+
expect(RpmTest.rpm_compare_evr('1.2.3-1.el5', '1.2.3-1.el5')).to eq(0)
9797
end
9898

9999
it 'evaluates identical version as equal' do
100-
expect(RpmTest.rpm_compareEVR('1.2.3', '1.2.3')).to eq(0)
100+
expect(RpmTest.rpm_compare_evr('1.2.3', '1.2.3')).to eq(0)
101101
end
102102

103103
it 'evaluates identical version but older release as less' do
104-
expect(RpmTest.rpm_compareEVR('1.2.3-1.el5', '1.2.3-2.el5')).to eq(-1)
104+
expect(RpmTest.rpm_compare_evr('1.2.3-1.el5', '1.2.3-2.el5')).to eq(-1)
105105
end
106106

107107
it 'evaluates identical version but newer release as greater' do
108-
expect(RpmTest.rpm_compareEVR('1.2.3-3.el5', '1.2.3-2.el5')).to eq(1)
108+
expect(RpmTest.rpm_compare_evr('1.2.3-3.el5', '1.2.3-2.el5')).to eq(1)
109109
end
110110

111111
it 'evaluates a newer epoch as greater' do
112-
expect(RpmTest.rpm_compareEVR('1:1.2.3-4.5', '1.2.3-4.5')).to eq(1)
112+
expect(RpmTest.rpm_compare_evr('1:1.2.3-4.5', '1.2.3-4.5')).to eq(1)
113113
end
114114

115115
# these tests describe PUP-1244 logic yet to be implemented
116116
it 'evaluates any version as equal to the same version followed by release' do
117-
expect(RpmTest.rpm_compareEVR('1.2.3', '1.2.3-2.el5')).to eq(0)
117+
expect(RpmTest.rpm_compare_evr('1.2.3', '1.2.3-2.el5')).to eq(0)
118118
end
119119

120120
# test cases for PUP-682
121121
it 'evaluates same-length numeric revisions numerically' do
122-
expect(RpmTest.rpm_compareEVR('2.2-405', '2.2-406')).to eq(-1)
122+
expect(RpmTest.rpm_compare_evr('2.2-405', '2.2-406')).to eq(-1)
123123
end
124124
end
125125

0 commit comments

Comments
 (0)