class Rubydex::Linter::RuleLoader
Loads project and bundled-gem rules using the Rubydex linter path convention.
Constants
- RULE_GLOB
Public Class Methods
(String workspace_path) → Array[singleton(Rule)]
Source
# File lib/rubydex/linter/rule_loader.rb, line 11 def load(workspace_path) existing_rules = Rule.subclasses rule_files = Dir.glob(RULE_GLOB, base: workspace_path).map do |rule_file| File.expand_path(rule_file, workspace_path) end if ENV["BUNDLE_GEMFILE"] rule_files.concat(Gem.find_latest_files(RULE_GLOB)) end rule_files.each do |rule_file| require rule_file rescue LoadError, SyntaxError => error raise RuleLoadError, "Unable to load linter rules from #{rule_file}: #{error.message}", cause: error end Rule.subclasses - existing_rules end