Sha256: c4cdc59d47d41782c62413e4a0bb53dce7b80b802e814b07ddbd24866893d22d

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'colored'
##
# ReekChecker checks the Output of reek for Code Smells
#
# @author dmasur
class ReekChecker
  ##
  # Gives the Checkresult
  #
  # @return [Hash] Checkresult
  # @author dmasur
  def result
    shell_output = `reek app lib -y 2>/dev/null`
    @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
    # 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 = YAML.parse(@shell_output).children.first.children.count
        "#{error_count} Codesmell".yellow
      end
    end

    ##
    # Gives the check output
    #
    # @return [String] Output
    # @author dmasur
    def output
      unless @shell_output.include? '---'
        @shell_output
      else
        ''
      end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rake_check-0.0.1 lib/rake_check/reek_checker.rb