Class: CleoQualityReview::StickyCommentBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/cleo_quality_review/sticky_comment_builder.rb

Overview

Builds the marker and body for the sticky pull request comment from rendered pr_review JSON

Constant Summary collapse

MARKER_PREFIX =
"<!-- cleo-quality-review:"
MAX_BODY_LENGTH =
3_500
CLEAN_MESSAGE =
"Cleo quality review found no high-confidence issues worth flagging on this change."

Instance Method Summary collapse

Constructor Details

#initialize(rendered_review:) ⇒ StickyCommentBuilder

Returns a new instance of StickyCommentBuilder.

Parameters:

  • rendered_review (String) —

    JSON produced by the pr_review formatter



18
19
20
# File 'lib/cleo_quality_review/sticky_comment_builder.rb', line 18

def initialize(rendered_review:)
  @rendered_review = rendered_review
end

Instance Method Details

#comment_body(commit_sha:) ⇒ String

Returns full comment body, including the hidden marker.

Parameters:

  • commit_sha (String) —

    head commit reviewed to embed in the marker

Returns:

  • (String) —

    full comment body, including the hidden marker



25
26
27
# File 'lib/cleo_quality_review/sticky_comment_builder.rb', line 25

def comment_body(commit_sha:)
  [marker(commit_sha), truncate(display_body)].join("\n\n")
end

#empty? ⇒ Boolean

Returns whether the rendered review has anything worth publishing.

Returns:

  • (Boolean) —

    whether the rendered review has anything worth publishing



31
32
33
# File 'lib/cleo_quality_review/sticky_comment_builder.rb', line 31

def empty?
  body_text.empty?
end