Class: Rubydex::CLI::Command::Lint
- Inherits:
-
Command
- Object
- Command
- Rubydex::CLI::Command::Lint
- Defined in:
- lib/rubydex/cli/command/lint.rb,
lib/rubydex/cli/command/lint/explain.rb
Defined Under Namespace
Classes: Explain
Instance Method Summary collapse
-
#run ⇒ Object
: -> void.
Instance Method Details
#run ⇒ Object
: -> void
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/rubydex/cli/command/lint.rb', line 14 def run if argv.first == "explain" argv.shift require "rubydex/cli/command/lint/explain" Explain.new(argv).run return end do |parser| parser.separator("") parser.separator("Commands:") parser.separator(" explain <RULE> Print documentation for matching linter rules") parser.separator("") parser.separator("Options:") end abort_with_usage("unexpected argument: #{argv.first}") unless argv.empty? workspace_path = current_workspace_path # Keep top-level help lightweight: command discovery loads this file before the native # extension, while linter support is only needed when this command runs. require "rubydex/linter" custom_rules = load_linter_rules(workspace_path) warn_unknown_rules graph = build_graph($stderr, workspace_path:, config:) runner = Rubydex::Linter::Runner.new(graph, custom_rules:, config: linter_config) $stderr.puts("Linting...") diagnostics = runner.run by_severity = diagnostics.group_by { |diagnostic| diagnostic.rule.severity(linter_config) } if diagnostics.empty? print_summary(graph.documents.count, by_severity) return end print_offenses(by_severity, graph) exit(1) if by_severity[Rubydex::Severity::Error]&.any? end |