Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a119390
RuboCop: resolve `Style/Alias` issues
orien Dec 19, 2025
cbc4538
RuboCop: resolve `Style/BlockDelimiters` issues
orien Dec 19, 2025
abeb63b
RuboCop: resolve `Style/CaseEquality` issues
orien Dec 19, 2025
3ec4a53
RuboCop: resolve `Style/CommandLiteral` issues
orien Dec 19, 2025
580725c
RuboCop: resolve `Style/ConditionalAssignment` issues
orien Dec 19, 2025
5592cbf
RuboCop: resolve `Style/EachWithObject` issues
orien Dec 19, 2025
ceb75f1
RuboCop: resolve `Style/EmptyLiteral` issues
orien Dec 19, 2025
f0c859d
RuboCop: resolve `Style/EmptyMethod` issues
orien Dec 19, 2025
1778485
RuboCop: resolve `Style/Encoding` issues
orien Dec 19, 2025
0dc5d54
RuboCop: resolve `Style/ExpandPathArguments` issues
orien Dec 19, 2025
f913032
RuboCop: resolve `Style/ExplicitBlockArgument` issues
orien Dec 19, 2025
e940640
RuboCop: resolve `Style/GuardClause` issues
orien Dec 19, 2025
f4ac349
RuboCop: resolve `Style/HashSyntax` issues
orien Dec 19, 2025
9b2a67a
RuboCop: resolve `Style/IfUnlessModifier` issues
orien Dec 19, 2025
3d182c0
RuboCop: resolve `Style/KeywordParametersOrder` issues
orien Dec 19, 2025
cd41174
RuboCop: resolve `Style/MethodCallWithoutArgsParentheses` issues
orien Dec 19, 2025
826bb9c
RuboCop: resolve `Style/MethodDefParentheses` issues
orien Dec 19, 2025
64eff3a
RuboCop: resolve `Style/MultilineIfModifier` issues
orien Dec 19, 2025
a28da69
RuboCop: resolve `Style/NeatedIf` issues
orien Dec 19, 2025
654ccf1
RuboCop: resolve `Style/Next` issues
orien Dec 19, 2025
7bff915
RuboCop: resolve `Style/NumericLiterals` issues
orien Dec 19, 2025
d7ccae6
RuboCop: resolve `Style/ParallelAssignment` issues
orien Dec 19, 2025
b3c41b9
RuboCop: resolve `Style/PercentLiteralDelimiters` issues
orien Dec 19, 2025
ea55e43
RuboCop: resolve `Style/RedundantAssignment` issues
orien Dec 19, 2025
df22612
RuboCop: resolve `Style/RedundantException` issues
orien Dec 19, 2025
4640e02
RuboCop: resolve `Style/RedundantPercentQ` issues
orien Dec 19, 2025
3a37b75
RuboCop: resolve `Style/RedundantRegexpCharacterClass` issues
orien Dec 19, 2025
2673c65
RuboCop: resolve `Style/RedundantRegexpEscape` issues
orien Dec 19, 2025
654fd00
RuboCop: resolve `Style/RedundantReturn` issues
orien Dec 19, 2025
9ce281c
RuboCop: resolve `Style/RedundantSelf` issues
orien Dec 19, 2025
3eabadf
RuboCop: resolve `Style/RegexpLiteral` issues
orien Dec 19, 2025
816dfd8
RuboCop: resolve `Style/RescueStandardError` issues
orien Dec 19, 2025
caf58a7
RuboCop: resolve `Style/SignalException` issues
orien Dec 19, 2025
a830be7
RuboCop: resolve `Style/SymbolArray` issues
orien Dec 19, 2025
fb82167
RuboCop: resolve `Style/TrailingCommaInArguments` issues
orien Dec 19, 2025
d07036d
RuboCop: resolve `Style/TrailingCommaInArrayLiteral` issues
orien Dec 19, 2025
7d278aa
RuboCop: resolve `Style/TrailingCommaInHashLiteral` issues
orien Dec 19, 2025
99315b6
RuboCop: resolve `Style/UnlessElse` issues
orien Dec 19, 2025
0e4d84b
RuboCop: resolve `Style/WordArray` issues
orien Dec 19, 2025
a55a548
RuboCop: resolve `Style/StringLiterals` issues
orien Dec 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
415 changes: 3 additions & 412 deletions .rubocop_todo.yml

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ The format is based on [Keep a Changelog], and this project adheres to

## [Unreleased]

### Changed

- Resolve style issues identified by RuboCop ([#396])

[Unreleased]: https://github.com/envato/stack_master/compare/v2.17.1...HEAD
[#396]: https://github.com/envato/stack_master/pull/396

## [2.17.1] - 2025-12-19

Expand Down
8 changes: 4 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require "bundler/gem_tasks"
require 'bundler/gem_tasks'
require 'bundler/setup'

task :environment do
require 'stack_master'
end

task :console => :environment do
task console: :environment do
require 'pry'
binding.pry
end
Expand All @@ -19,12 +19,12 @@ begin

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = "--format doc"
t.rspec_opts = '--format doc'
end

require 'rubocop/rake_task'
RuboCop::RakeTask.new('rubocop')
rescue LoadError
end

task :default => [:features, :spec, :rubocop]
task default: %i[features spec rubocop]
8 changes: 3 additions & 5 deletions bin/stack_master
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

require 'stack_master'

if ENV['STUB_AWS'] == 'true'
require 'stack_master/testing'
end
require 'stack_master/testing' if ENV['STUB_AWS'] == 'true'

trap("SIGINT") { raise StackMaster::CtrlC }
trap('SIGINT') { raise StackMaster::CtrlC }

begin
StackMaster::CLI.new(ARGV.dup).execute!
rescue StackMaster::CtrlC
StackMaster.stdout.puts "Exiting..."
StackMaster.stdout.puts 'Exiting...'
end
2 changes: 1 addition & 1 deletion example/simple/templates/myapp_vpc.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SparkleFormation.new(:myapp_vpc) do
description "A test VPC template"
description 'A test VPC template'

resources.vpc do
type 'AWS::EC2::VPC'
Expand Down
2 changes: 1 addition & 1 deletion example/simple/templates/myapp_web.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SparkleFormation.new(:myapp_web) do
description "Test web template"
description 'Test web template'

parameters.vpc_id do
description 'VPC ID'
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/parameter_store_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
parameter: {
name: parameter_name,
value: parameter_value,
type: "SecureString",
type: 'SecureString',
version: 1
}
}
Expand Down
6 changes: 2 additions & 4 deletions features/step_definitions/stack_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,18 @@
end

def extract_hash_from_kv_string(string)
string.to_s.split(',').inject({}) do |hash, kv|
string.to_s.split(',').each_with_object({}) do |kv, hash|
key, value = kv.split('=')
hash[key] = value
hash
end
end

Given(/^I stub the following stacks:$/) do |table|
table.hashes.each do |row|
row.symbolize_keys!
row[:parameters] = StackMaster::Utils.hash_to_aws_parameters(extract_hash_from_kv_string(row[:parameters]))
outputs = extract_hash_from_kv_string(row[:outputs]).inject([]) do |array, (k, v)|
outputs = extract_hash_from_kv_string(row[:outputs]).each_with_object([]) do |(k, v), array|
array << OpenStruct.new(output_key: k, output_value: v)
array
end
row[:outputs] = outputs
StackMaster.cloud_formation_driver.add_stack(row)
Expand Down
2 changes: 1 addition & 1 deletion features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
Timecop.return
end

lib = File.join(File.dirname(__FILE__), "../../spec/fixtures/sparkle_pack_integration/my_sparkle_pack/lib")
lib = File.join(File.dirname(__FILE__), '../../spec/fixtures/sparkle_pack_integration/my_sparkle_pack/lib')
$LOAD_PATH << lib
2 changes: 1 addition & 1 deletion lib/stack_master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def skip_account_check?
@non_interactive_answer = 'y'

def base_dir
File.expand_path(File.join(File.dirname(__FILE__), ".."))
File.expand_path(File.join(File.dirname(__FILE__), '..'))
end

def cloud_formation_driver
Expand Down
8 changes: 4 additions & 4 deletions lib/stack_master/aws_driver/cloud_formation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def region
end

def set_region(value)
if region != value
@region = value
@cf = nil
end
return if region == value

@region = value
@cf = nil
end

def_delegators(
Expand Down
14 changes: 7 additions & 7 deletions lib/stack_master/aws_driver/s3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ def upload_files(bucket: nil, prefix: nil, region: nil, files: {})
prefix: prefix,
bucket: bucket
}
).map(&:contents).flatten.inject({}) { |h, obj|
).map(&:contents).flatten.inject({}) do |h, obj|
h.merge(obj.key => obj)
}
end

StackMaster.stdout.puts "Uploading files to S3:"
StackMaster.stdout.puts 'Uploading files to S3:'

files.each do |template, file|
body = file.fetch(:body)
path = file.fetch(:path)
object_key = template.dup
object_key.prepend("#{prefix}/") if prefix
compiled_template_md5 = Digest::MD5.hexdigest(body).to_s
s3_md5 = current_objects[object_key] ? current_objects[object_key].etag.gsub("\"", '') : nil
s3_md5 = current_objects[object_key] ? current_objects[object_key].etag.gsub('"', '') : nil

next if compiled_template_md5 == s3_md5

Expand All @@ -51,14 +51,14 @@ def upload_files(bucket: nil, prefix: nil, region: nil, files: {})
metadata: { md5: compiled_template_md5 }
}
)
StackMaster.stdout.puts "done."
StackMaster.stdout.puts 'done.'
end
end

def url(bucket:, prefix:, region:, template:)
if region == 'us-east-1'
["https://s3.amazonaws.com", bucket, prefix, template].compact.join('/')
elsif region.start_with? "cn-"
['https://s3.amazonaws.com', bucket, prefix, template].compact.join('/')
elsif region.start_with? 'cn-'
["https://s3.#{region}.amazonaws.com.cn", bucket, prefix, template].compact.join('/')
else
["https://s3-#{region}.amazonaws.com", bucket, prefix, template].compact.join('/')
Expand Down
18 changes: 7 additions & 11 deletions lib/stack_master/change_set.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module StackMaster
class ChangeSet
END_STATES = [
'CREATE_COMPLETE',
'DELETE_COMPLETE',
'FAILED'
END_STATES = %w[
CREATE_COMPLETE
DELETE_COMPLETE
FAILED
]

def self.generate_change_set_name(stack_name)
Expand Down Expand Up @@ -50,7 +50,7 @@ def display(io)
@response.changes.each do |change|
display_resource_change(io, change.resource_change)
end
io.puts "========================================"
io.puts '========================================'
end

def failed?
Expand Down Expand Up @@ -84,13 +84,9 @@ def display_resource_change(io, resource_change)
def display_resource_change_detail(io, action_name, color, detail)
target_name = [detail.target.attribute, detail.target.name].compact.join('.')
detail_messages = [target_name]
if action_name == 'Replace'
detail_messages << "#{detail.target.requires_recreation} requires recreation"
end
detail_messages << "#{detail.target.requires_recreation} requires recreation" if action_name == 'Replace'
triggered_by = [detail.change_source, detail.causing_entity].compact.join('.')
if detail.evaluation != 'Static'
triggered_by << "(#{detail.evaluation})"
end
triggered_by << "(#{detail.evaluation})" if detail.evaluation != 'Static'
detail_messages << "Triggered by: #{triggered_by}"
io.puts Rainbow("- #{detail_messages.join('. ')}. ").color(color)
end
Expand Down
Loading