Commit ca4090da by Jeremy Mickelson Committed by Cuong Tran

Refactor and simplify returns (#574)

* refactor and simplify returns for annotate_one_file * fix rubocop offenses
parent e84e22de
......@@ -498,7 +498,7 @@ module AnnotateModels
# :before, :top, :after or :bottom. Default is :before.
#
def annotate_one_file(file_name, info_block, position, options = {})
if File.exist?(file_name)
return false unless File.exist?(file_name)
old_content = File.read(file_name)
return false if old_content =~ /#{SKIP_ANNOTATION_PREFIX}.*\n/
......@@ -511,9 +511,8 @@ module AnnotateModels
old_columns = old_header && old_header.scan(column_pattern).sort
new_columns = new_header && new_header.scan(column_pattern).sort
if old_columns == new_columns && !options[:force]
return false
else
return false if old_columns == new_columns && !options[:force]
# Replace inline the old schema info with the new schema info
wrapper_open = options[:wrapper_open] ? "# #{options[:wrapper_open]}\n" : ""
wrapper_close = options[:wrapper_close] ? "# #{options[:wrapper_close]}\n" : ""
......@@ -544,11 +543,7 @@ module AnnotateModels
end
File.open(file_name, 'wb') { |f| f.puts new_content }
return true
end
else
false
end
true
end
def magic_comment_matcher
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment