Skip to content

Commit 2aa335e

Browse files
authored
Fix high cognitive complexity of Changelog#to_s (#20)
1 parent 42c263a commit 2aa335e

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

lib/create_github_release/changelog.rb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,28 @@ def body
292292
#
293293
def to_s
294294
String.new.tap do |changelog|
295-
changelog << "#{front_matter}\n\n" unless front_matter.empty?
296-
changelog << release_header
297-
changelog << release_description
298-
changelog << "\n#{body}\n" unless body.empty?
295+
changelog << formatted_front_matter unless front_matter.empty?
296+
changelog << release_header << release_description
297+
changelog << formatted_body unless body.empty?
299298
end
300299
end
301300

302301
private
303302

303+
# The front matter formatted to insert into the changelog
304+
# @return [String] The front matter formatted to insert into the changelog
305+
# @api private
306+
def formatted_front_matter
307+
"#{front_matter}\n\n"
308+
end
309+
310+
# The body formatted to insert into the changelog
311+
# @return [String] The body formatted to insert into the changelog
312+
# @api private
313+
def formatted_body
314+
"\n#{body}\n"
315+
end
316+
304317
# The index of the line in @lines where the front matter begins
305318
# @return [Integer] The index of the line in @lines where the front matter begins
306319
# @api private

0 commit comments

Comments
 (0)