Class: OKF::Bundle::Linter

Inherits:
Object
  • Object
show all
Defined in:
lib/okf/bundle/linter.rb,
lib/okf/bundle/linter/report.rb

Overview

Lints a bundle for curation quality — the deterministic subset of the ingest → query → lint loop (overview.md): reachability, backlog, completeness, freshness, provenance, and hygiene. Pure — it reads nothing from disk and works entirely on the in-memory OKF::Bundle, mirroring OKF::Bundle::Validator.

Unlike OKF::Bundle::Validator (the §9 conformance gate, which MUST NOT reject for broken links or missing optional fields), lint never rejects a bundle: it reports :warn and :info findings the spec marks as tolerable, and emits them as structured data (OKF::Bundle::Linter::Report) for a human or agent to act on. Contradictions and semantic staleness are NOT detected here — they need meaning, not structure; the JSON report is the substrate an agent consumes for those passes.

Defined Under Namespace

Classes: Report

Constant Summary collapse

CHECKS =

All checks, in display/registry order. --only/--except select from these.

%i[
  orphan not_in_index disconnected_component unlinked
  missing_concept broken_index_entry
  stub missing_title missing_description missing_timestamp
  stale
  uncited_external broken_citation
  duplicate_title unused_reference_def undefined_reference self_link
].freeze
DEFAULT_MIN_BODY =
50
HUB_LIMIT =
5

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bundle, min_body: DEFAULT_MIN_BODY, stale_before: nil, only: nil, except: nil) ⇒ Linter

Returns a new instance of Linter.



34
35
36
37
38
39
40
41
# File 'lib/okf/bundle/linter.rb', line 34

def initialize(bundle, min_body: DEFAULT_MIN_BODY, stale_before: nil, only: nil, except: nil)
  @bundle = bundle
  @min_body = min_body
  @stale_before = stale_before
  @only = only
  @except = except
  @report = Report.new
end

Class Method Details

.call(bundle, **options) ⇒ Object



30
31
32
# File 'lib/okf/bundle/linter.rb', line 30

def self.call(bundle, **options)
  new(bundle, **options).call
end

Instance Method Details

#callObject



43
44
45
46
47
48
# File 'lib/okf/bundle/linter.rb', line 43

def call
  prepare
  selected_checks.each { |check| send("check_#{check}") }
  fill_stats
  @report
end