Skip to content

Commit 31522a8

Browse files
authored
Merge pull request #31 from OpenVoxProject/standardize_tasks
Standardize rake tasks
2 parents 81a579a + db99daf commit 31522a8

File tree

9 files changed

+116
-80
lines changed

9 files changed

+116
-80
lines changed

.rubocop.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -378,11 +378,5 @@ Style/LambdaCall:
378378
Style/LineEndConcatenation:
379379
Enabled: true
380380

381-
Style/MapCompactWithConditionalBlock:
382-
Enabled: true
383-
384381
Style/MapToHash:
385382
Enabled: true
386-
387-
Style/MapToSet:
388-
Enabled: true

.rubocop_todo.yml

Lines changed: 66 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,12 @@ Lint/ConstantDefinitionInBlock:
5151
- 'lib/puppet/type/schedule.rb'
5252
- 'lib/puppet/type/tidy.rb'
5353

54-
Lint/ConstantOverwrittenInRescue: # new in 1.31
55-
Enabled: false
56-
5754
Lint/DeprecatedConstants: # new in 1.8
5855
Enabled: false
5956

6057
Lint/DuplicateBranch: # new in 1.3
6158
Enabled: false
6259

63-
Lint/DuplicateMagicComment: # new in 1.37
64-
Enabled: false
65-
66-
Lint/DuplicateMatchPattern: # new in 1.50
67-
Enabled: false
68-
6960
Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
7061
Enabled: false
7162

@@ -81,21 +72,12 @@ Lint/EmptyInPattern: # new in 1.16
8172
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
8273
Enabled: false
8374

84-
Lint/ItWithoutArgumentsInBlock: # new in 1.59
85-
Enabled: false
86-
8775
Lint/LambdaWithoutLiteralBlock: # new in 1.8
8876
Enabled: false
8977

90-
Lint/LiteralAssignmentInCondition: # new in 1.58
91-
Enabled: false
92-
9378
Lint/MissingSuper:
9479
Enabled: false
9580

96-
Lint/MixedCaseRange: # new in 1.53
97-
Enabled: false
98-
9981
Lint/NestedMethodDefinition:
10082
Exclude:
10183
- 'lib/puppet/pops/types/p_binary_type.rb'
@@ -110,9 +92,6 @@ Lint/NestedMethodDefinition:
11092
- 'lib/puppet/pops/types/types.rb'
11193
- 'lib/puppet/type.rb'
11294

113-
Lint/NonAtomicFileOperation: # new in 1.31
114-
Enabled: false
115-
11695
Lint/NoReturnInBeginEndBlocks: # new in 1.2
11796
Enabled: false
11897

@@ -125,9 +104,6 @@ Lint/OrAssignmentToConstant: # new in 1.9
125104
Lint/RedundantDirGlobSort: # new in 1.8
126105
Enabled: false
127106

128-
Lint/RedundantRegexpQuantifiers: # new in 1.53
129-
Enabled: false
130-
131107
# Unsure how the changes in portage.rb from Lint/RedundantSplatExpansion impact
132108
# the code
133109
Lint/RedundantSplatExpansion:
@@ -137,9 +113,6 @@ Lint/RedundantSplatExpansion:
137113
Lint/RefinementImportMethods: # new in 1.27
138114
Enabled: false
139115

140-
Lint/RequireRangeParentheses: # new in 1.32
141-
Enabled: false
142-
143116
Lint/RequireRelativeSelfPath: # new in 1.22
144117
Enabled: false
145118

@@ -199,9 +172,6 @@ Lint/UnmodifiedReduceAccumulator: # new in 1.1
199172
Lint/UnusedMethodArgument:
200173
Enabled: false
201174

202-
Lint/UselessRescue: # new in 1.43
203-
Enabled: false
204-
205175
Lint/UselessRuby2Keywords: # new in 1.23
206176
Enabled: false
207177

@@ -294,6 +264,9 @@ Performance/UnfreezeString:
294264
Style/AccessModifierDeclarations:
295265
Exclude:
296266
- 'lib/puppet/util/suidmanager.rb'
267+
- 'lib/puppet/util/command_line/trollop.rb'
268+
- 'lib/puppet/util/windows/com.rb'
269+
- 'lib/puppet/util/windows/monkey_patches/process.rb'
297270

298271
# This cop supports safe auto-correction (--auto-correct).
299272
# Configuration parameters: EnforcedStyle.
@@ -791,3 +764,66 @@ Style/ZeroLengthPredicate:
791764
# URISchemes: http, https
792765
Layout/LineLength:
793766
Max: 582
767+
768+
Style/CaseLikeIf:
769+
Exclude:
770+
- 'lib/puppet/provider/package/pip.rb'
771+
- 'lib/puppet/provider/package/portupgrade.rb'
772+
- 'lib/puppet/transaction/report.rb'
773+
774+
Style/EmptyCaseCondition:
775+
Exclude:
776+
- 'lib/puppet/type.rb'
777+
778+
Gemspec/DateAssignment: # new in 1.10
779+
Enabled: false
780+
Gemspec/RequireMFA: # new in 1.23
781+
Enabled: false
782+
Naming/BlockForwarding: # new in 1.24
783+
Enabled: false
784+
Security/CompoundHash: # new in 1.28
785+
Enabled: false
786+
Security/IoMethods: # new in 1.22
787+
Enabled: false
788+
Style/ArgumentsForwarding: # new in 1.1
789+
Enabled: false
790+
Style/EndlessMethod: # new in 1.8
791+
Enabled: false
792+
Style/HashExcept: # new in 1.7
793+
Enabled: false
794+
Style/InPatternThen: # new in 1.16
795+
Enabled: false
796+
Style/MultilineInPatternThen: # new in 1.16
797+
Enabled: false
798+
Style/NegatedIfElseCondition: # new in 1.2
799+
Enabled: false
800+
Style/NestedFileDirname: # new in 1.26
801+
Enabled: false
802+
Style/NilLambda: # new in 1.3
803+
Enabled: false
804+
Style/NumberedParameters: # new in 1.22
805+
Enabled: false
806+
Style/NumberedParametersLimit: # new in 1.22
807+
Enabled: false
808+
Style/ObjectThen: # new in 1.28
809+
Enabled: false
810+
Style/OpenStructUse: # new in 1.23
811+
Enabled: false
812+
Style/QuotedSymbols: # new in 1.16
813+
Enabled: false
814+
Style/RedundantArgument: # new in 1.4
815+
Enabled: false
816+
Style/RedundantInitialize: # new in 1.27
817+
Enabled: false
818+
Style/RedundantSelfAssignmentBranch: # new in 1.19
819+
Enabled: false
820+
Style/SelectByRegexp: # new in 1.22
821+
Enabled: false
822+
Style/StringChars: # new in 1.12
823+
Enabled: false
824+
Style/SwapValues: # new in 1.1
825+
Enabled: false
826+
Performance/MapMethodChain: # new in 1.19
827+
Enabled: false
828+
RSpec/ChangeByZero: # new in 2.11.0
829+
Enabled: false

Rakefile

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,28 @@ require 'rake'
55
require 'rubygems'
66
require 'rubygems/package_task'
77

8-
def run_command(cmd)
9-
output, status = Open3.capture2e(cmd)
10-
abort "Command failed! Command: #{cmd}, Output: #{output}" unless status.exitstatus.zero?
8+
RED = "\033[31m"
9+
GREEN = "\033[32m"
10+
RESET = "\033[0m"
11+
12+
def run_command(cmd, silent: true, print_command: false, report_status: false)
13+
puts "#{GREEN}Running #{cmd}#{RESET}" if print_command
14+
output = ''
15+
Open3.popen2e(cmd) do |_stdin, stdout_stderr, thread|
16+
stdout_stderr.each do |line|
17+
puts line unless silent
18+
output += line
19+
end
20+
exitcode = thread.value.exitstatus
21+
unless exitcode.zero?
22+
err = "#{RED}Command failed! Command: #{cmd}, Exit code: #{exitcode}"
23+
# Print details if we were running silent
24+
err += "\nOutput:\n#{output}" if silent
25+
err += RESET
26+
abort err
27+
end
28+
puts "#{GREEN}Command finished with status #{exitcode}#{RESET}" if report_status
29+
end
1130
output.chomp
1231
end
1332

lib/puppet/application/agent.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ def log_config
412412
end
413413
end
414414

415-
# rubocop:disable Lint/RedundantStringCoercion
416415
def fingerprint
417416
Puppet::Util::Log.newdestination(:console)
418417
cert_provider = Puppet::X509::CertProvider.new
@@ -432,7 +431,6 @@ def fingerprint
432431
Puppet.log_exception(e, _("Failed to generate fingerprint: %{message}") % { message: e.message })
433432
exit(1)
434433
end
435-
# rubocop:enable Lint/RedundantStringCoercion
436434

437435
def onetime(daemon)
438436
begin

lib/puppet/provider/aix_object.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def numeric_mapping(info = {})
131131

132132
# AIX will do the right validation to ensure numeric attributes
133133
# can't be set to non-numeric values, so no need for the extra clutter.
134-
info[:attribute_to_property] = lambda do |value| # rubocop:disable Style/SymbolProc
134+
info[:attribute_to_property] = lambda do |value|
135135
value.to_i
136136
end
137137

lib/puppet/provider/package/apt.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,11 @@ def install
157157
cmd += install_options if @resource[:install_options]
158158
cmd << :install
159159

160-
# rubocop:disable Style/RedundantCondition
161160
if source
162161
cmd << source
163162
else
164163
cmd << str
165164
end
166-
# rubocop:enable Style/RedundantCondition
167165

168166
unhold if properties[:mark] == :hold
169167
begin

lib/puppet/provider/package/yum.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ def self.latest_package_version(package, disablerepo, enablerepo, disableexclude
110110
# @param disableexcludes [Array<String>] A list of repository excludes to disable for this query
111111
# @return [Hash<String, Array<Hash<String, String>>>] All packages that were
112112
# found with a list of found versions for each package.
113-
# rubocop:disable Layout/SingleLineBlockChain
114113
def self.check_updates(disablerepo, enablerepo, disableexcludes)
115114
args = [command(:cmd), 'check-update']
116115
args.concat(disablerepo.map { |repo| ["--disablerepo=#{repo}"] }.flatten)
@@ -130,7 +129,6 @@ def self.check_updates(disablerepo, enablerepo, disableexcludes)
130129
end
131130
updates
132131
end
133-
# rubocop:enable Layout/SingleLineBlockChain
134132

135133
def self.parse_updates(str)
136134
# Strip off all content that contains Obsoleting, Security: or Update
@@ -229,7 +227,6 @@ def best_version(should)
229227
end
230228
end
231229

232-
# rubocop:disable Layout/SingleLineBlockChain
233230
def available_versions(package_name, disablerepo, enablerepo, disableexcludes)
234231
args = [command(:cmd), 'list', package_name, '--showduplicates']
235232
args.concat(disablerepo.map { |repo| ["--disablerepo=#{repo}"] }.flatten)
@@ -239,11 +236,9 @@ def available_versions(package_name, disablerepo, enablerepo, disableexcludes)
239236
output = execute("#{args.compact.join(' ')} | sed -e '1,/Available Packages/ d' | awk '{print $2}'")
240237
output.split("\n")
241238
end
242-
# rubocop:enable Layout/SingleLineBlockChain
243239

244240
def install
245241
wanted = @resource[:name]
246-
error_level = self.class.error_level
247242
update_command = self.class.update_command
248243
# If not allowing virtual packages, do a query to ensure a real package exists
249244
unless @resource.allow_virtual?

lib/puppet/resource.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,10 @@ def to_hierayaml
453453
attr.unshift(:ensure)
454454
end
455455

456-
# rubocop:disable Lint/FormatParameterMismatch
457456
attributes = attr.collect { |k|
458457
v = parameters[k]
459458
" %-#{attr_max}s: %s\n" % [k, Puppet::Parameter.format_value_for_display(v)]
460459
}.join
461-
# rubocop:enable Lint/FormatParameterMismatch
462460

463461
" %s:\n%s" % [title, attributes]
464462
end
@@ -490,12 +488,10 @@ def to_manifest
490488
attr.unshift(:ensure)
491489
end
492490

493-
# rubocop:disable Lint/FormatParameterMismatch
494491
attributes = attr.collect { |k|
495492
v = parameters[k]
496493
" %-#{attr_max}s => %s,\n" % [k, Puppet::Parameter.format_value_for_display(v)]
497494
}.join
498-
# rubocop:enable Lint/FormatParameterMismatch
499495

500496
escaped = title.gsub(/'/, "\\\\'")
501497
"%s { '%s':\n%s}" % [type.to_s.downcase, escaped, attributes]

tasks/tag.rake

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
namespace :vox do
2-
desc 'Update version, create tag, and push to origin'
3-
task :tag, [:tag] do |_, args|
4-
abort 'You must provide a tag.' if args[:tag].nil? || args[:tag].empty?
5-
version = args[:tag]
6-
abort "#{version} does not appear to be a valid version string in x.y.z format" unless Gem::Version.correct?(version)
2+
desc 'Update version, create tag, and push to origin'
3+
task :tag, [:tag] do |_, args|
4+
abort 'You must provide a tag.' if args[:tag].nil? || args[:tag].empty?
5+
version = args[:tag]
6+
abort "#{version} does not appear to be a valid version string in x.y.z format" unless Gem::Version.correct?(version)
77

8-
# Update lib/puppet/version.rb and puppet.gemspec
9-
puts "Setting version to #{version}"
10-
data = File.read('lib/puppet/version.rb')
11-
data = data.sub(/PUPPETVERSION = '\d+\.\d+\.\d+'/, "PUPPETVERSION = '#{version}'")
12-
File.write('lib/puppet/version.rb', data)
13-
data = File.read('puppet.gemspec')
14-
data = data.sub(/spec.version = "\d+\.\d+\.\d+"/, "spec.version = \"#{version}\"")
15-
File.write('puppet.gemspec', data)
16-
run_command("git add lib/puppet/version.rb && git add puppet.gemspec && git commit -m 'Set version to #{version}'", true)
8+
# Update lib/puppet/version.rb and puppet.gemspec
9+
puts "Setting version to #{version}"
10+
data = File.read('lib/puppet/version.rb')
11+
data = data.sub(/PUPPETVERSION = '\d+\.\d+\.\d+'/, "PUPPETVERSION = '#{version}'")
12+
File.write('lib/puppet/version.rb', data)
13+
data = File.read('puppet.gemspec')
14+
data = data.sub(/spec.version = "\d+\.\d+\.\d+"/, "spec.version = \"#{version}\"")
15+
File.write('puppet.gemspec', data)
16+
run_command("git add lib/puppet/version.rb && git add puppet.gemspec && git commit -m 'Set version to #{version}'")
1717

18-
# Run git command to get short SHA and one line description of the commit on HEAD
19-
branch = run_command('git rev-parse --abbrev-ref HEAD', true)
20-
sha = run_command('git rev-parse --short HEAD', true)
21-
msg = run_command('git log -n 1 --pretty=%B', true)
18+
# Run git command to get short SHA and one line description of the commit on HEAD
19+
branch = run_command('git rev-parse --abbrev-ref HEAD')
20+
sha = run_command('git rev-parse --short HEAD')
21+
msg = run_command('git log -n 1 --pretty=%B')
2222

23-
puts "Branch: #{branch}"
24-
puts "SHA: #{sha}"
25-
puts "Commit: #{msg}"
23+
puts "Branch: #{branch}"
24+
puts "SHA: #{sha}"
25+
puts "Commit: #{msg}"
2626

27-
run_command("git tag -a #{version} -m '#{version}'")
27+
run_command("git tag -a #{version} -m '#{version}'")
2828

29-
unless !ENV['NOPUSH'].nil?
30-
puts "Pushing to origin"
31-
run_command("git push origin && git push origin #{version}")
32-
end
29+
unless !ENV['NOPUSH'].nil?
30+
puts "Pushing to origin"
31+
run_command("git push origin && git push origin #{version}")
3332
end
34-
end
33+
end
34+
end

0 commit comments

Comments
 (0)