Sha256: f37ef3a7ebcbf9f5aef04b4e30b2b3101afc1b50fce0770f0a04708fba19102c

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

#!/usr/bin/env ruby
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
require 'skeptic'
require 'trollop'

opts = Trollop::options do
  opt :lines_per_method,  'Maximum number of lines per method', type: :int
  opt :max_nesting_depth, 'Maximum nesting depth', type: :int
  opt :methods_per_class, 'Maximum number of methods per class', type: :int
  opt :no_semicolons,     'Complain about semicolons', type: :boolean
end
code = File.read ARGV[0]

critic = Skeptic::Critic.new

critic.no_semicolons     = opts[:no_semicolons]
critic.max_nesting_depth = opts[:max_nesting_depth]
critic.methods_per_class = opts[:methods_per_class]
critic.lines_per_method  = opts[:lines_per_method]

critic.criticize code

if critic.criticism.empty?
  puts 'OK'
  exit(0)
else
  messages = Hash.new { |hash, key| hash[key] = [] }

  critic.criticism.each do |message, type|
    messages[type] << message
  end

  messages.each do |type, messages|
    puts type
    messages.each do |message|
      puts "* #{message}"
    end
    puts ""
  end

  exit(1)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
skeptic-0.0.0 bin/skeptic