Class: RuboCop::Cop::Prompt::InvalidFormat
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Prompt::InvalidFormat
- Defined in:
- lib/rubocop/cop/prompt/invalid_format.rb
Overview
Checks that system: blocks start with a Markdown heading.
This cop identifies code in classes, modules, or methods with “prompt” in their names and ensures that any system: blocks begin with a Markdown heading (# text).
Constant Summary collapse
- MSG =
"system: block should start with a Markdown heading (# text)"
Instance Method Summary collapse
Instance Method Details
#on_pair(node) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rubocop/cop/prompt/invalid_format.rb', line 27 def on_pair(node) return unless system_pair?(node) return unless in_prompt_context?(node) value_node = node.children[1] content = extract_content(value_node) return if content.nil? || content.strip.empty? return if starts_with_markdown_heading?(content) add_offense(node) end |