Module: ParseWarning
- Defined in:
- lib/spm_version_updates/parse_warning.rb
Overview
Builds the structured records used to report ‘.package(…)` declarations that the manifest parser had to skip, plus the pre-filled GitHub issue link shown alongside them. The manifest snippet is redacted and shown in the report only — never embedded in the issue URL, where it could leak private repository URLs through logs or referrer headers.
Constant Summary collapse
- ISSUE_URL =
"https://github.com/hbmartin/github-action-spm_version_updates/issues/new"- SNIPPET_LIMIT =
200- REASONS =
{ "unrecognized_requirement" => "its version requirement was not recognized", "unbalanced_parentheses" => "it has unbalanced parentheses, so the remainder of this manifest was not scanned" }.freeze
Class Method Summary collapse
-
.describe_reason(record) ⇒ String
The reason as a readable phrase.
-
.issue_link(record) ⇒ String
A GitHub new-issue URL pre-filled with everything except the manifest content, which the template asks the reporter to paste in themselves.
-
.record(reason:, source:, snippet:) ⇒ Hash
Type / reason / source / snippet / message, string-keyed.
Class Method Details
.describe_reason(record) ⇒ String
Returns the reason as a readable phrase.
50 51 52 53 |
# File 'lib/spm_version_updates/parse_warning.rb', line 50 def self.describe_reason(record) reason = record["reason"] REASONS.fetch(reason, reason) end |
.issue_link(record) ⇒ String
A GitHub new-issue URL pre-filled with everything except the manifest content, which the template asks the reporter to paste in themselves.
39 40 41 42 43 44 45 46 |
# File 'lib/spm_version_updates/parse_warning.rb', line 39 def self.issue_link(record) reason = record["reason"] query = URI.encode_www_form( title: "Manifest parse failure: #{reason}", body: issue_body(reason) ) "#{ISSUE_URL}?#{query}" end |
.record(reason:, source:, snippet:) ⇒ Hash
Returns type / reason / source / snippet / message, string-keyed.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/spm_version_updates/parse_warning.rb', line 24 def self.record(reason:, source:, snippet:) reason = reason.to_s { "type" => "parse_warning", "reason" => reason, "source" => source, "snippet" => truncated_snippet(snippet), "message" => (reason, source) } end |