Add and apply EmptyLineAfterGuardClause rule
We were inconsistent on this one. I consider it particularly useful when a method starts with a `return` statement. In other cases, we probably shouldn't have a guard rule in the middle of a method in any case, but that's a different refactoring.
This commit is contained in:
@@ -17,6 +17,7 @@ class RemoteCensusApi
|
||||
def extract_value(path_value)
|
||||
path = parse_response_path(path_value)
|
||||
return nil unless path.present?
|
||||
|
||||
@body.dig(*path)
|
||||
end
|
||||
|
||||
@@ -29,8 +30,10 @@ class RemoteCensusApi
|
||||
path_value = Setting["remote_census.response.date_of_birth"]
|
||||
str = extract_value(path_value)
|
||||
return nil unless str.present?
|
||||
|
||||
day, month, year = str.match(/(\d\d?)\D(\d\d?)\D(\d\d\d?\d?)/)[1..3]
|
||||
return nil unless day.present? && month.present? && year.present?
|
||||
|
||||
Time.zone.local(year.to_i, month.to_i, day.to_i).to_date
|
||||
end
|
||||
|
||||
@@ -111,6 +114,7 @@ class RemoteCensusApi
|
||||
to_set = path.empty? ? structure : structure.dig(*path)
|
||||
|
||||
return unless to_set
|
||||
|
||||
to_set[final_key] = value
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user