Skip to content

Commit

Permalink
Merge pull request #229 from winebarrel/enable_Style/ConditionalAssig…
Browse files Browse the repository at this point in the history
…nment

Enable Style/ConditionalAssignment
  • Loading branch information
winebarrel committed Jun 11, 2018
2 parents 03349b4 + a007ed3 commit 91837ef
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
2 changes: 0 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ Style/ClassAndModuleChildren:
Enabled: false
Style/CommentedKeyword:
Enabled: false
Style/ConditionalAssignment:
Enabled: false
Style/Documentation:
Enabled: false
Style/ExpandPathArguments:
Expand Down
14 changes: 7 additions & 7 deletions lib/ridgepole/cli/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ class << self
def load(config, env = 'development')
config = ENV.fetch(Regexp.last_match(1)) if config =~ /\Aenv:(.+)\z/

if File.exist?(config)
parsed_config = parse_config_file(config)
elsif (expanded = File.expand_path(config)) && File.exist?(expanded)
parsed_config = parse_config_file(expanded)
else
parsed_config = YAML.safe_load(ERB.new(config).result, [], [], true)
end
parsed_config = if File.exist?(config)
parse_config_file(config)
elsif (expanded = File.expand_path(config)) && File.exist?(expanded)
parse_config_file(expanded)
else
YAML.safe_load(ERB.new(config).result, [], [], true)
end

unless parsed_config.is_a?(Hash)
parsed_config = parse_database_url(config)
Expand Down
10 changes: 5 additions & 5 deletions lib/ridgepole/delta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,11 @@ def append_remove_foreign_key(table_name, attrs, buf, _options)
attrs_options = attrs[:options] || {}
fk_name = attrs_options[:name]

if fk_name
target = { name: fk_name }
else
target = attrs.fetch(:to_table)
end
target = if fk_name
{ name: fk_name }
else
attrs.fetch(:to_table)
end

buf.puts(<<-RUBY)
remove_foreign_key(#{table_name.inspect}, #{target.inspect})
Expand Down
20 changes: 10 additions & 10 deletions lib/ridgepole/diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ def scan_options_change(table_name, from, to, table_delta)
def convert_to_primary_key_attrs(column_options)
options = column_options.dup

if options[:id]
type = options.delete(:id)
else
type = Ridgepole::DSLParser::TableDefinition::DEFAULT_PRIMARY_KEY_TYPE
end
type = if options[:id]
options.delete(:id)
else
Ridgepole::DSLParser::TableDefinition::DEFAULT_PRIMARY_KEY_TYPE
end

if %i[integer bigint].include?(type) && !options.key?(:default)
options[:auto_increment] = true
Expand Down Expand Up @@ -199,11 +199,11 @@ def scan_definition_change(from, to, from_indices, table_name, table_options, ta

scan_column_rename(from, to, definition_delta)

if (table_options[:id] == false) || table_options[:primary_key].is_a?(Array)
priv_column_name = nil
else
priv_column_name = table_options[:primary_key] || 'id'
end
priv_column_name = if (table_options[:id] == false) || table_options[:primary_key].is_a?(Array)
nil
else
table_options[:primary_key] || 'id'
end

to.each do |column_name, to_attrs|
if (from_attrs = from.delete(column_name))
Expand Down

0 comments on commit 91837ef

Please sign in to comment.