Class: Ace::Lint::Organisms::LintDoctor
- Inherits:
-
Object
- Object
- Ace::Lint::Organisms::LintDoctor
- Defined in:
- lib/ace/lint/organisms/lint_doctor.rb
Overview
Diagnostic tool for checking linting configuration health Checks validator availability, config files, and pattern coverage
Defined Under Namespace
Classes: DiagnosticResult
Instance Attribute Summary collapse
-
#diagnostics ⇒ Object
readonly
Returns the value of attribute diagnostics.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#project_root ⇒ Object
readonly
Returns the value of attribute project_root.
Instance Method Summary collapse
-
#check_config_files ⇒ Array<DiagnosticResult>
Check if configured config files exist.
-
#check_pattern_coverage ⇒ Array<DiagnosticResult>
Check pattern coverage in groups configuration.
-
#check_validator_availability ⇒ Array<DiagnosticResult>
Check if all configured validators are available.
-
#diagnose ⇒ Array<DiagnosticResult>
Run all diagnostic checks.
-
#errors ⇒ Array<DiagnosticResult>
Get all errors.
-
#errors? ⇒ Boolean
Check if there are any errors.
-
#initialize(project_root: Dir.pwd, groups: nil) ⇒ LintDoctor
constructor
Initialize doctor with configuration.
-
#warnings ⇒ Array<DiagnosticResult>
Get all warnings.
-
#warnings? ⇒ Boolean
Check if there are any warnings.
Constructor Details
#initialize(project_root: Dir.pwd, groups: nil) ⇒ LintDoctor
Initialize doctor with configuration
36 37 38 39 40 |
# File 'lib/ace/lint/organisms/lint_doctor.rb', line 36 def initialize(project_root: Dir.pwd, groups: nil) @project_root = project_root @groups = groups @diagnostics = [] end |
Instance Attribute Details
#diagnostics ⇒ Object (readonly)
Returns the value of attribute diagnostics.
31 32 33 |
# File 'lib/ace/lint/organisms/lint_doctor.rb', line 31 def diagnostics @diagnostics end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
31 32 33 |
# File 'lib/ace/lint/organisms/lint_doctor.rb', line 31 def groups @groups end |
#project_root ⇒ Object (readonly)
Returns the value of attribute project_root.
31 32 33 |
# File 'lib/ace/lint/organisms/lint_doctor.rb', line 31 def project_root @project_root end |
Instance Method Details
#check_config_files ⇒ Array<DiagnosticResult>
Check if configured config files exist
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/ace/lint/organisms/lint_doctor.rb', line 99 def check_config_files results = [] # Check for each validator's config Atoms::ValidatorRegistry.registered_validators.each do |name| config = Atoms::ConfigLocator.locate(name, project_root: @project_root) case config[:source] when :explicit if config[:exists] results << DiagnosticResult.new( category: :config, level: :info, message: "#{name}: using explicit config at #{config[:path]}", details: {validator: name, source: :explicit, path: config[:path]} ) # Validate YAML syntax yaml_error = validate_yaml_syntax(config[:path], name) results << yaml_error if yaml_error else results << DiagnosticResult.new( category: :config, level: :error, message: "#{name}: explicit config not found at #{config[:path]}", details: {validator: name, source: :explicit, path: config[:path], exists: false} ) end when :ace_config results << DiagnosticResult.new( category: :config, level: :info, message: "#{name}: using .ace/lint config at #{config[:path]}", details: {validator: name, source: :ace_config, path: config[:path]} ) # Validate YAML syntax yaml_error = validate_yaml_syntax(config[:path], name) results << yaml_error if yaml_error when :native results << DiagnosticResult.new( category: :config, level: :info, message: "#{name}: using native config at #{config[:path]}", details: {validator: name, source: :native, path: config[:path]} ) # Validate YAML syntax yaml_error = validate_yaml_syntax(config[:path], name) results << yaml_error if yaml_error when :gem_defaults results << DiagnosticResult.new( category: :config, level: :info, message: "#{name}: using gem default config", details: {validator: name, source: :gem_defaults, path: config[:path]} ) when :none results << DiagnosticResult.new( category: :config, level: :info, message: "#{name}: using tool defaults (no config file)", details: {validator: name, source: :none} ) end end @diagnostics.concat(results) results end |
#check_pattern_coverage ⇒ Array<DiagnosticResult>
Check pattern coverage in groups configuration
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/ace/lint/organisms/lint_doctor.rb', line 169 def check_pattern_coverage return [] unless @groups results = [] # Check for default group unless @groups.key?(:default) || @groups.key?("default") results << DiagnosticResult.new( category: :pattern, level: :warning, message: "No 'default' group defined - some files may not be matched", details: {issue: :no_default_group} ) end # Check for overlapping patterns (info only) all_patterns = [] @groups.each do |name, config| patterns = config[:patterns] || config["patterns"] || [] patterns.each do |pattern| all_patterns << {group: name, pattern: pattern} end end # Info about configured groups @groups.each do |name, config| validators = config[:validators] || config["validators"] || [] patterns = config[:patterns] || config["patterns"] || [] results << DiagnosticResult.new( category: :pattern, level: :info, message: "Group '#{name}': #{validators.join(", ")} for #{patterns.size} pattern(s)", details: {group: name, validators: validators, pattern_count: patterns.size} ) end @diagnostics.concat(results) results end |
#check_validator_availability ⇒ Array<DiagnosticResult>
Check if all configured validators are available
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/ace/lint/organisms/lint_doctor.rb', line 56 def check_validator_availability results = [] # Check registered validators Atoms::ValidatorRegistry.registered_validators.each do |name| results << if Atoms::ValidatorRegistry.available?(name) DiagnosticResult.new( category: :validator, level: :info, message: "#{name}: available", details: {validator: name, status: :available} ) else DiagnosticResult.new( category: :validator, level: :warning, message: "#{name}: not installed", details: {validator: name, status: :unavailable} ) end end # Check configured validators in groups if @groups configured_validators = collect_configured_validators configured_validators.each do |name| unless Atoms::ValidatorRegistry.available?(name) results << DiagnosticResult.new( category: :validator, level: :warning, message: "Configured validator '#{name}' is not available", details: {validator: name, status: :configured_unavailable} ) end end end @diagnostics.concat(results) results end |
#diagnose ⇒ Array<DiagnosticResult>
Run all diagnostic checks
44 45 46 47 48 49 50 51 52 |
# File 'lib/ace/lint/organisms/lint_doctor.rb', line 44 def diagnose @diagnostics = [] check_validator_availability check_config_files check_pattern_coverage if @groups @diagnostics end |
#errors ⇒ Array<DiagnosticResult>
Get all errors
224 225 226 |
# File 'lib/ace/lint/organisms/lint_doctor.rb', line 224 def errors @diagnostics.select(&:error?) end |
#errors? ⇒ Boolean
Check if there are any errors
212 213 214 |
# File 'lib/ace/lint/organisms/lint_doctor.rb', line 212 def errors? @diagnostics.any?(&:error?) end |
#warnings ⇒ Array<DiagnosticResult>
Get all warnings
230 231 232 |
# File 'lib/ace/lint/organisms/lint_doctor.rb', line 230 def warnings @diagnostics.select(&:warning?) end |
#warnings? ⇒ Boolean
Check if there are any warnings
218 219 220 |
# File 'lib/ace/lint/organisms/lint_doctor.rb', line 218 def warnings? @diagnostics.any?(&:warning?) end |