module Rubocop::SafeTodoSearcher
Constants
- RUBOCOP_TODO_YML
- VERSION
Public Class Methods
search()
click to toggle source
# File lib/rubocop/safe_todo_searcher.rb, line 20 def search puts generate_header puts horizontal_line puts generate_results puts horizontal_line end
Private Class Methods
generate_header()
click to toggle source
# File lib/rubocop/safe_todo_searcher.rb, line 48 def generate_header [ horizontal_line, header("Rubocop TODO searcher"), title("Version", Rubocop::SafeTodoSearcher::VERSION), title("Date", DateTime.now.strftime("%Y-%m-%d %H:%M:%S")) ] end
generate_results()
click to toggle source
# File lib/rubocop/safe_todo_searcher.rb, line 29 def generate_results File.exist?(RUBOCOP_TODO_YML) ? parse : "#{RUBOCOP_TODO_YML} does not exist" end
header(text)
click to toggle source
# File lib/rubocop/safe_todo_searcher.rb, line 57 def header(text) HighLine.new.color("++++++ #{text} ++++++", :bold) end
horizontal_line(color = :none)
click to toggle source
# File lib/rubocop/safe_todo_searcher.rb, line 65 def horizontal_line(color = :none) HighLine.new.color("--------------------------------------------------", :bold, color) end
parse()
click to toggle source
# File lib/rubocop/safe_todo_searcher.rb, line 33 def parse res = +"" File.open(RUBOCOP_TODO_YML, "r") { |f| YAML.safe_load(f) }&.each_key do |key| res << "#{key}\n" if support_autocorrect?(key) end res end
support_autocorrect?(key)
click to toggle source
# File lib/rubocop/safe_todo_searcher.rb, line 41 def support_autocorrect?(key) cop = Object.const_get "RuboCop::Cop::#{key.gsub(%r{/}, "::")}" cop.support_autocorrect? && cop.new(RuboCop::ConfigLoader.default_configuration).safe_autocorrect? rescue NameError false end
title(title, value, color = :green)
click to toggle source
# File lib/rubocop/safe_todo_searcher.rb, line 61 def title(title, value, color = :green) "#{HighLine.new.color(title, color)}: #{value}" end