Sha256: cc9f09165f1bb0bbae2a8c5cf12ec96a7c7112e57bf833cd6257a6108bfafcc8
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
require "open3" # # Common stuff for a linter # module LinterMixin def run offenses = [] applicable_files.each do |file| if clean?(file) print "." else offenses << file print "F" end end print "\n" return if offenses.empty? raise failure_message_for(offenses) end private def applicable_files Open3.capture2("git grep -Il ''")[0].split end def failure_message_for(offenses) msg = "#{self.class.name} detected offenses. " msg += if respond_to?(:fixing_cmd) "Run `#{fixing_cmd(offenses)}` to fix them." else "Affected files: #{offenses.join(' ')}" end msg end end # # Checks trailing new lines in files # class MissingTrailingCarriageReturn include LinterMixin def clean?(file) File.read(file) =~ /\n\Z/m end end require 'rubocop/rake_task' RuboCop::RakeTask.new desc "Lints ActiveAdmin code base" task lint: ["rubocop", "lint:missing_trailing_carriage_return"] namespace :lint do desc "Check for missing trailing new lines" task :missing_trailing_carriage_return do puts "Checking for missing trailing carriage returns..." MissingTrailingCarriageReturn.new.run end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
arbre-1.2.1 | tasks/lint.rake |
arbre-1.2.0 | tasks/lint.rake |
arbre-1.2.0.rc1 | tasks/lint.rake |