class Pronto::Rubocop::PatchCop
Attributes
patch[R]
runner[R]
Public Class Methods
new(patch, runner)
click to toggle source
# File lib/pronto/rubocop/patch_cop.rb, line 8 def initialize(patch, runner) @patch = patch @runner = runner end
Public Instance Methods
messages()
click to toggle source
# File lib/pronto/rubocop/patch_cop.rb, line 13 def messages return [] unless valid? offenses.flat_map do |offense| patch .added_lines .select { |line| line.new_lineno == offense.line } .map { |line| OffenseLine.new(self, offense, line).message } end end
processed_source()
click to toggle source
# File lib/pronto/rubocop/patch_cop.rb, line 24 def processed_source @processed_source ||= ::RuboCop::ProcessedSource.from_file( path, rubocop_config.target_ruby_version ) end
registry()
click to toggle source
# File lib/pronto/rubocop/patch_cop.rb, line 31 def registry @registry ||= ::RuboCop::Cop::Registry.new(RuboCop::Cop::Cop.all) end
rubocop_config()
click to toggle source
# File lib/pronto/rubocop/patch_cop.rb, line 35 def rubocop_config @rubocop_config ||= begin store = ::RuboCop::ConfigStore.new store.for(path) end end
Private Instance Methods
offenses()
click to toggle source
# File lib/pronto/rubocop/patch_cop.rb, line 57 def offenses team .inspect_file(processed_source) .sort .reject(&:disabled?) end
path()
click to toggle source
# File lib/pronto/rubocop/patch_cop.rb, line 53 def path @path ||= patch.new_file_full_path.to_s end
team()
click to toggle source
# File lib/pronto/rubocop/patch_cop.rb, line 64 def team @team ||= if ::RuboCop::Cop::Team.respond_to?(:mobilize) # rubocop v0.85.0 and later ::RuboCop::Cop::Team.mobilize(registry, rubocop_config) else ::RuboCop::Cop::Team.new(registry, rubocop_config) end end
valid?()
click to toggle source
# File lib/pronto/rubocop/patch_cop.rb, line 46 def valid? return false if rubocop_config.file_to_exclude?(path) return true if rubocop_config.file_to_include?(path) true end