lib/quality/rake/task.rb in quality-4.0.2 vs lib/quality/rake/task.rb in quality-5.0.0
- old
+ new
@@ -3,10 +3,11 @@
require 'rake'
require 'rake/tasklib'
require 'rbconfig'
require_relative '../runner'
require_relative '../quality_checker'
+require_relative 'config'
module Quality
#
# Defines a task library for running quality's various tools
#
@@ -23,105 +24,45 @@
#
# This will create a task that can be run with:
#
# rake quality
class Task < ::Rake::TaskLib
- # Name of quality task.
- # Defaults to :quality.
- attr_accessor :quality_name
-
- # Name of ratchet task.
- # Defaults to :ratchet.
- attr_accessor :ratchet_name
-
- # Array of strings describing tools to be skipped--e.g., ["cane"]
- #
- # Defaults to []
- attr_accessor :skip_tools
-
- # Log command executation
- #
- # Defaults to false
- attr_accessor :verbose
-
- # Array of directory names which contain ruby files to analyze.
- #
- # Defaults to %w(app lib test spec feature), which translates to *.rb in
- # the base directory, as well as those directories.
- attr_writer :ruby_dirs
-
- # Array of directory names which contain any type of source
- # files to analyze.
- #
- # Defaults to the same as ruby_dirs
- attr_writer :source_dirs
-
- # Relative path to output directory where *_high_water_mark
- # files will be read/written
- #
- # Defaults to .
- attr_accessor :output_dir
-
# Defines a new task, using the name +name+.
def initialize(dsl: ::Rake::Task,
cmd_runner: Kernel,
count_file: File,
count_io: IO,
globber: Dir,
gem_spec: Gem::Specification,
- configuration_writer: File,
quality_checker_class:
- Quality::QualityChecker,
- quality_name: 'quality',
- ratchet_name: 'ratchet')
+ Quality::QualityChecker)
@dsl, @cmd_runner = dsl, cmd_runner
@globber = globber
- @quality_name, @ratchet_name = quality_name, ratchet_name
-
- @skip_tools = []
-
- @verbose = false
-
- @output_dir = 'metrics'
-
- yield self if block_given?
-
- @runner = Quality::Runner.new(self,
+ @config = Quality::Config.new(globber: globber)
+ yield @config if block_given?
+ @runner = Quality::Runner.new(@config,
gem_spec: gem_spec,
quality_checker_class:
quality_checker_class,
count_io: count_io,
- count_file: count_file)
+ count_file: count_file,
+ globber: globber)
define
end
- attr_reader :globber
+ attr_reader :globber, :config
- def ruby_dirs
- @ruby_dirs ||= %w(app lib test spec feature)
- end
+ private
- def source_dirs
- @source_dirs ||= ruby_dirs.clone
+ def quality_name
+ config.quality_name
end
- def source_files_glob(dirs = source_dirs,
- extensions = 'rb,swift,cpp,c,java,py')
- File.join("{#{dirs.join(',')}}", '**', "*.{#{extensions}}")
+ def ratchet_name
+ config.ratchet_name
end
- def ruby_files_glob
- source_files_glob(ruby_dirs, 'rb')
- end
-
- def ruby_files
- @globber.glob('{*.rb,Rakefile}')
- .concat(@globber.glob(ruby_files_glob)).join(' ')
- end
-
- private
-
- def define # :nodoc:
+ def define
desc 'Verify quality has increased or stayed ' \
'the same' unless ::Rake.application.last_comment
@dsl.define_task(quality_name) { @runner.run_quality }
@dsl.define_task(ratchet_name) { @runner.run_ratchet }
@runner.tools.each do |tool|