Class: QHelpGenerator
- Inherits:
-
Object
- Object
- QHelpGenerator
- Defined in:
- lib/code_scanning/rules_generator.rb
Instance Method Summary collapse
-
#initialize ⇒ QHelpGenerator
constructor
A new instance of QHelpGenerator.
- #parse_file(path_to_file) ⇒ Object
- #sarif_json ⇒ Object
Constructor Details
#initialize ⇒ QHelpGenerator
Returns a new instance of QHelpGenerator.
6 7 8 |
# File 'lib/code_scanning/rules_generator.rb', line 6 def initialize @formatter = CodeScanning::SarifFormatter.new(nil) end |
Instance Method Details
#parse_file(path_to_file) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/code_scanning/rules_generator.rb', line 10 def parse_file(path_to_file) file = File.open(path_to_file) current_rule = nil file.each_with_index do |line, index| # title: skip next if index.zero? if line[0..2] == "## " current_cop = line[3..-2] current_rule, _index = @formatter.get_rule(current_cop, nil) next end next if current_rule.nil? if line == "\n" && current_rule.help_empty? # Don't start the help text with new lines next end current_rule.append_help(line) end end |
#sarif_json ⇒ Object
33 34 35 |
# File 'lib/code_scanning/rules_generator.rb', line 33 def sarif_json @formatter.sarif_json end |