diff --git a/Gemfile.lock b/Gemfile.lock index d212d23..8ed9c4b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,9 @@ PATH remote: . specs: - clint_eastwood (0.0.5) + clint_eastwood (0.0.6) + flay (~> 2.8.0) + flog (~> 4.4.0) rails_best_practices (~> 1.17.0) reek (~> 4.2.3) rubocop (~> 0.42.0) @@ -31,12 +33,22 @@ GEM thread_safe (~> 0.3, >= 0.3.1) equalizer (0.0.11) erubis (2.7.0) + flay (2.8.0) + erubis (~> 2.7.0) + path_expander (~> 1.0) + ruby_parser (~> 3.0) + sexp_processor (~> 4.0) + flog (4.4.0) + path_expander (~> 1.0) + ruby_parser (~> 3.1, > 3.1.0) + sexp_processor (~> 4.4) i18n (0.7.0) ice_nine (0.11.2) - json (2.0.2) + json (1.8.3) minitest (5.9.0) parser (2.3.1.2) ast (~> 2.2) + path_expander (1.0.0) powerpack (0.1.1) rails_best_practices (1.17.0) activesupport @@ -60,6 +72,8 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.8.1) + ruby_parser (3.8.2) + sexp_processor (~> 4.1) sexp_processor (4.7.0) thor (0.19.1) thread_safe (0.3.5) diff --git a/clint_eastwood.gemspec b/clint_eastwood.gemspec index 43e49b6..85b86a1 100644 --- a/clint_eastwood.gemspec +++ b/clint_eastwood.gemspec @@ -25,6 +25,8 @@ Gem::Specification.new do |spec| spec.add_dependency 'rubocop', '~> 0.42.0' spec.add_dependency 'thor', '~> 0.19.1' spec.add_dependency 'rails_best_practices', '~> 1.17.0' + spec.add_dependency 'flog', '~> 4.4.0' + spec.add_dependency 'flay', '~> 2.8.0' spec.executables = ['clint'] end diff --git a/config/reek.yml b/config/reek_config.reek similarity index 100% rename from config/reek.yml rename to config/reek_config.reek diff --git a/lib/clint_eastwood.rb b/lib/clint_eastwood.rb index ed1182c..f3ca729 100644 --- a/lib/clint_eastwood.rb +++ b/lib/clint_eastwood.rb @@ -1,4 +1,5 @@ require 'clint_eastwood/version' +require 'reek' require 'rails_best_practices' require_relative 'better_rails_best_practices.rb' @@ -18,13 +19,15 @@ class TheEnforcer # @param disable_rbp [Boolean] If true, this stops rails best practices from running # # @returns [TheEnforcer] A new enforcer object - def initialize(path, lint: nil, disable_reek: false, disable_rubocop: false, disable_rbp: false) + def initialize(path, lint: nil, disable_reek: false, disable_rubocop: false, disable_rbp: false, disable_flog: false, disable_flay: false) gem_path = File.expand_path(File.dirname(__FILE__)) @config_path = File.join(gem_path, '../config') @disable_rubocop = disable_rubocop @disable_reek = disable_reek @disable_rbp = disable_rbp + @disable_flog = disable_flog + @disable_flay = disable_flay @base_path = path @lint_paths = lint || %w(app lib config spec) @@ -36,8 +39,10 @@ def enforce reek_result = @disable_reek || reek rubocop_result = @disable_rubocop || rubocop rbp_result = @disable_rbp || rails_best_practices + flog_result = @disable_flog || flog + flay_result = @disable_flay || flay - reek_result && rubocop_result && rbp_result + reek_result && rubocop_result && rbp_result && flog_result && flay_result end private @@ -51,18 +56,9 @@ def locate_config(filename) # Run reek def reek - @reek_config = locate_config('reek.yml') - - reek_command = [] - - @lint_paths.each do |path| - reek_command << File.join(@base_path, path) - end - - reek_command.concat ['--config', "#{@reek_config}"] - - # Reek returns the number of errors, so make sure it's zero - Reek::CLI::Application.new(reek_command).execute == 0 + paths = @lint_paths.map { |p| File.join(@base_path, p) }.join(' ') + configuration = locate_config('reek_config.reek') + system "bundle exec reek --config #{configuration} #{paths}" end # Run rubocop @@ -82,5 +78,19 @@ def rails_best_practices analyzer.output analyzer.runner.errors.size == 0 end + + # Run flog + def flog + paths = @lint_paths.map { |p| File.join(@base_path, p) }.join(' ') + + system "bundle exec flog #{paths}" + end + + # Run flay + def flay + paths = @lint_paths.map { |p| File.join(@base_path, p) }.join(' ') + + system "bundle exec flay #{paths}" + end end end diff --git a/lib/clint_eastwood/cli.rb b/lib/clint_eastwood/cli.rb index 109ab68..a91061e 100644 --- a/lib/clint_eastwood/cli.rb +++ b/lib/clint_eastwood/cli.rb @@ -10,6 +10,8 @@ class CLI < Thor option 'disable-rbp', type: :boolean option 'disable-rubocop', type: :boolean option 'disable-reek', type: :boolean + option 'disable-flog', type: :boolean + option 'disable-flay', type: :boolean option 'warn', type: :boolean default_task :lint @@ -42,13 +44,17 @@ def load_and_configure disable_rbp = options['disable-rbp'] || false disable_rubocop = options['disable-rubocop'] || false disable_reek = options['disable-reek'] || false + disable_flog = options['disable-flog'] || false + disable_flay = options['disable-flay'] || false ClintEastwood::TheEnforcer.new( path, lint: options[:lint], disable_rbp: disable_rbp, disable_rubocop: disable_rubocop, - disable_reek: disable_reek + disable_reek: disable_reek, + disable_flog: disable_flog, + disable_flay: disable_flay ) end end diff --git a/lib/clint_eastwood/version.rb b/lib/clint_eastwood/version.rb index 76ac1a5..1e2135a 100644 --- a/lib/clint_eastwood/version.rb +++ b/lib/clint_eastwood/version.rb @@ -1,4 +1,4 @@ # Clint Eastwood module ClintEastwood - VERSION = '0.0.6' + VERSION = '0.0.7' end