Module: Carson::Runtime::Lint
- Included in:
- Carson::Runtime
- Defined in:
- lib/carson/runtime/lint.rb
Instance Method Summary collapse
-
#lint_setup!(source:, ref: "main", force: false) ⇒ Object
Prepares canonical lint policy files under ~/.carson/lint from an explicit source.
Instance Method Details
#lint_setup!(source:, ref: "main", force: false) ⇒ Object
Prepares canonical lint policy files under ~/.carson/lint from an explicit source.
9 10 11 12 13 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 54 55 56 57 |
# File 'lib/carson/runtime/lint.rb', line 9 def lint_setup!( source:, ref: "main", force: false ) puts_verbose "" puts_verbose "[Lint Setup]" source_text = source.to_s.strip if source_text.empty? puts_line "ERROR: lint setup requires --source <path-or-git-url>." return EXIT_ERROR end ref_text = ref.to_s.strip ref_text = "main" if ref_text.empty? source_dir, cleanup = lint_setup_source_directory( source: source_text, ref: ref_text ) begin source_coding_dir = File.join( source_dir, "CODING" ) unless Dir.exist?( source_coding_dir ) puts_line "ERROR: source CODING directory not found at #{source_coding_dir}." return EXIT_ERROR end target_coding_dir = ai_coding_dir copy_result = copy_lint_coding_tree( source_coding_dir: source_coding_dir, target_coding_dir: target_coding_dir, force: force ) puts_verbose "lint_setup_source: #{source_text}" puts_verbose "lint_setup_ref: #{ref_text}" if lint_source_git_url?( source: source_text ) puts_verbose "lint_setup_target: #{target_coding_dir}" puts_verbose "lint_setup_created: #{copy_result.fetch( :created )}" puts_verbose "lint_setup_updated: #{copy_result.fetch( :updated )}" puts_verbose "lint_setup_skipped: #{copy_result.fetch( :skipped )}" missing_policy = missing_lint_policy_files if missing_policy.empty? puts_line "OK: lint policy setup is complete." return EXIT_OK end missing_policy.each do |entry| puts_verbose "missing_lint_policy_file: language=#{entry.fetch( :language )} path=#{entry.fetch( :path )}" end puts_line "ACTION: update source CODING policy files, rerun carson lint setup, then rerun carson audit." EXIT_ERROR ensure cleanup&.call end rescue StandardError => e puts_line "ERROR: lint setup failed (#{e.})" EXIT_ERROR end |