class Cane::RakeTask
end
cane.add_threshold ‘coverage/covered_percent’, :>=, 99
cane.no_style = true
cane.doc_glob = ‘lib/*/.rb’
cane.abc_max = 10
Cane::RakeTask.new(:quality) do |cane|
desc “Run code quality checks”
Examples
Creates a rake task to run cane with given configuration.
def add_threshold(file, operator, value)
Add a threshold check. If the file exists and it contains a number,
def add_threshold(file, operator, value) if operator == :>= @options[:gte] << [file, value] end end
def canefile=(file)
def canefile=(file) canefile = Cane::CLI::Parser.new canefile.parser.parse!(canefile.read_options_from_file(file)) options.merge! canefile.options end
def initialize(task_name = nil)
def initialize(task_name = nil) self.name = task_name || :cane @gte = [] @options = Cane::CLI.default_options if block_given? yield self else self.canefile = './.cane' end unless ::Rake.application.last_description desc %(Check code quality metrics with cane) end task name do require 'cane/cli' abort unless Cane.run(options) end end
def use(check, options = {})
def use(check, options = {}) @options.merge!(options) @options[:checks] = @options[:checks] + [check] end