Sha256: 39e9b0e4be82a33e2025ccbad4af8c2e1448170fb15759e00415b9c6e5e69c6c
Contents?: true
Size: 1.84 KB
Versions: 3
Compression:
Stored size: 1.84 KB
Contents
## # ReekChecker checks the Output of reek for Code Smells # # @author dmasur class ReekChecker ## # Gives the Checkresult # # @return [Hash] Checkresult # @author dmasur def result require_dependencies @shell_output = begin `reek app lib -y 2>/dev/null` rescue Errno::ENOENT "Reek not found" end @shell_output = @shell_output.split("\n"). delete_if{|line| line.include?('already initialized constant') }.join("\n") {:type => :reek, :check_output => output, :status => status} end private ## # Require Dependencies # # @author dmasur def require_dependencies require 'reek' require 'colored' require 'yaml' end ## # Gives the Check Status # # @return [String] Checkstatus # @author dmasur def status if @shell_output.empty? 'OK'.green elsif not @shell_output.include? '---' 'N/A'.red else error_count = parsed_output.count "#{error_count} Codesmell".yellow end end ## # Parse the Output through YAML # # @return [Array] SmellWarnings # @author dmasur def parsed_output YAML::load(@shell_output) end ## # Format the SmellWarning for printing # # @return [String] Formated SmellWarning # @author dmasur def self.format_smell smell_warning location = smell_warning.location output = "#{smell_warning.smell["subclass"]}: " output += "#{location["context"]}@#{location["lines"].join(", ")}" return output end ## # Gives the check output # # @return [String] Output # @author dmasur def output if @shell_output.include? '---' parsed_output.map do |smell| ReekChecker.format_smell smell end.join("\n") else @shell_output end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rake_check-0.1.5 | lib/rake_check/reek_checker.rb |
rake_check-0.1.4 | lib/rake_check/reek_checker.rb |
rake_check-0.1.3 | lib/rake_check/reek_checker.rb |