Skip to content

Commit

Permalink
Move early returns out of begin blocks
Browse files Browse the repository at this point in the history
returning early from a begin block won't assign the variable, but it
sort of looks like it will. Clearer / more explicit to have the early
returns outside the block.
  • Loading branch information
richardTowers committed Jan 15, 2025
1 parent 0821ecc commit 5e06f8b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/presenters/manual_section_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ def base_path
end

def intro
@intro ||= begin
return nil unless details["body"]
return nil unless details["body"]

@intro ||= begin
intro = Nokogiri::HTML::DocumentFragment.parse(details["body"])

# Strip all content following and including h2
Expand All @@ -29,9 +29,9 @@ def visually_expanded?
end

def main
@main ||= begin
return nil unless details["body"]
return nil unless details["body"]

@main ||= begin
document = Nokogiri::HTML::DocumentFragment.parse(details["body"])

# Identifies all h2's and creates an array of objects from the heading and
Expand Down

0 comments on commit 5e06f8b

Please sign in to comment.