Created
January 23, 2020 14:52
-
-
Save yitznewton/eee6ba99bddfc02d24afb43b45eb95e5 to your computer and use it in GitHub Desktop.
Rubocop exclusion detector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pathname' | |
require 'yaml' | |
def exclusions(config, directory) | |
config.flat_map do |k,v| | |
if k == 'Exclude' | |
v.map { |file_name| Dir.glob(directory.join(file_name)) } | |
elsif v.is_a?(Hash) | |
exclusions(v, directory) | |
else | |
[] | |
end | |
end | |
end | |
STDIN.read.split("\n").each do |config_file_name| | |
File.open(config_file_name, 'r') do |f| | |
pathname = Pathname.new(config_file_name) | |
config = YAML.load(f.read) | |
puts exclusions(config, pathname.parent) | |
end | |
end | |
# find . -name .rubocop.yml | grep -v vendor | ruby rubocop_exclusions.rb | grep -v vendor | grep -v /tmp/ | grep -v db/migrate | grep -v db/fixtures | grep -v test/fixtures | grep -v db/views | grep -v config/locales | grep .rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment