class Danger::DangerReek
Lints Ruby files via [Reek](rubygems.org/gems/reek). Results are sent as inline comments.
@example Running Reek
# Runs Reek on modified and added files in the PR reek.lint
@see blooper05/danger-reek @tags ruby, reek, lint
Public Instance Methods
lint()
click to toggle source
Runs Ruby files through Reek
. @return [Array<Reek::SmellWarning, nil>]
# File lib/reek/plugin.rb, line 21 def lint files_to_lint = fetch_files_to_lint code_smells = run_linter(files_to_lint) warn_each_line(code_smells) end
Private Instance Methods
fetch_files_to_lint()
click to toggle source
# File lib/reek/plugin.rb, line 37 def fetch_files_to_lint files = git.modified_files + git.added_files ::Reek::Source::SourceLocator.new(files).sources end
run_linter(files_to_lint)
click to toggle source
# File lib/reek/plugin.rb, line 29 def run_linter(files_to_lint) configuration = ::Reek::Configuration::AppConfiguration.from_path(nil) files_to_lint.flat_map do |file| examiner = ::Reek::Examiner.new(file, configuration: configuration) examiner.smells end end
warn_each_line(code_smells)
click to toggle source
# File lib/reek/plugin.rb, line 42 def warn_each_line(code_smells) code_smells.each do |smell| message = smell.message.capitalize source = smell.source smell.lines.each do |line| warn(message, file: source, line: line) end end end