Class: CleoQualityReview::GitHubReviewBuilder::InlineComment

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

Overview

Normalized rendered comment that can be mapped onto a PR diff line

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



17
18
19
# File 'lib/cleo_quality_review/github_review_builder.rb', line 17

def body
  @body
end

#lineObject

Returns the value of attribute line

Returns:

  • (Object)

    the current value of line



17
18
19
# File 'lib/cleo_quality_review/github_review_builder.rb', line 17

def line
  @line
end

#pathObject

Returns the value of attribute path

Returns:

  • (Object)

    the current value of path



17
18
19
# File 'lib/cleo_quality_review/github_review_builder.rb', line 17

def path
  @path
end

Instance Method Details

#commentable_on?(diff_map) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/cleo_quality_review/github_review_builder.rb', line 22

def commentable_on?(diff_map)
  valid? && diff_map.commentable?(path, line)
end

#to_review_payload(diff_map:, truncator:) ⇒ Object



26
27
28
29
30
# File 'lib/cleo_quality_review/github_review_builder.rb', line 26

def to_review_payload(diff_map:, truncator:)
  return unless commentable_on?(diff_map)

  { path: path, line: line, side: "RIGHT", body: truncator.call(body) }
end

#valid?Boolean

Returns:

  • (Boolean)


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

def valid?
  path != "" && line.positive? && body != ""
end