Skip to content

Commit 7880c89

Browse files
authored
Further reduce the complexity of Changelog@to_s (#21)
1 parent 2aa335e commit 7880c89

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/create_github_release/changelog.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,7 @@ def body
291291
# @return [String] The changelog with the new release details
292292
#
293293
def to_s
294-
String.new.tap do |changelog|
295-
changelog << formatted_front_matter unless front_matter.empty?
296-
changelog << release_header << release_description
297-
changelog << formatted_body unless body.empty?
298-
end
294+
formatted_front_matter + release_header + release_description + formatted_body
299295
end
300296

301297
private
@@ -304,14 +300,14 @@ def to_s
304300
# @return [String] The front matter formatted to insert into the changelog
305301
# @api private
306302
def formatted_front_matter
307-
"#{front_matter}\n\n"
303+
front_matter.empty? ? '' : "#{front_matter}\n\n"
308304
end
309305

310306
# The body formatted to insert into the changelog
311307
# @return [String] The body formatted to insert into the changelog
312308
# @api private
313309
def formatted_body
314-
"\n#{body}\n"
310+
body.empty? ? '' : "\n#{body}\n"
315311
end
316312

317313
# The index of the line in @lines where the front matter begins

0 commit comments

Comments
 (0)