Class: CleoQualityReview::Run

Inherits:
Struct
  • Object
show all
Defined in:
lib/cleo_quality_review/run.rb

Overview

Value object representing a quality review run with its configuration and results

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#artifactsRunArtifacts? (readonly)

Returns artifacts associated with this run.

Returns:

  • (RunArtifacts, nil)

    artifacts associated with this run



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
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
# File 'lib/cleo_quality_review/run.rb', line 27

Run = Struct.new(
  :timestamp,
  :review_id,
  :base_ref,
  :format,
  :checks,
  :target_files,
  :ruby_files,
  :run_directory,
  :results,
  :artifacts,
  :log,
  keyword_init: true,
) do
  ##
  # Convert the run to a hash representation
  # @return [Hash{Symbol => Object}]
  def to_h
    {
      timestamp: timestamp,
      review_id: review_id,
      base_ref: comparison_base_ref,
      format: format,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
      run_directory: run_directory,
      changes_diff: artifacts&.changes_diff,
      check_outputs: check_outputs,
      findings: Array(results).map(&:to_h),
    }
  end

  ##
  # Build array of check output hashes for serialization
  # @return [Array<Hash{Symbol => String}>]
  def check_outputs
    return [] unless artifacts

    artifacts.raw_check_output_records.map(&:to_h)
  end

  ##
  # Build manifest data for artifact persistence
  # @return [Hash{Symbol => Object}]
  def manifest_data
    {
      review_id: review_id,
      base_ref: comparison_base_ref,
      timestamp: timestamp,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
    }
  end

  private

  def comparison_base_ref
    base_ref || GitDiffBase::DEFAULT_BASE_REF
  end
end

#base_refObject

Returns the value of attribute base_ref

Returns:

  • (Object)

    the current value of base_ref



27
28
29
# File 'lib/cleo_quality_review/run.rb', line 27

def base_ref
  @base_ref
end

#checksArray<String> (readonly)

Returns names of checks that were run.

Returns:

  • (Array<String>)

    names of checks that were run



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
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
# File 'lib/cleo_quality_review/run.rb', line 27

Run = Struct.new(
  :timestamp,
  :review_id,
  :base_ref,
  :format,
  :checks,
  :target_files,
  :ruby_files,
  :run_directory,
  :results,
  :artifacts,
  :log,
  keyword_init: true,
) do
  ##
  # Convert the run to a hash representation
  # @return [Hash{Symbol => Object}]
  def to_h
    {
      timestamp: timestamp,
      review_id: review_id,
      base_ref: comparison_base_ref,
      format: format,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
      run_directory: run_directory,
      changes_diff: artifacts&.changes_diff,
      check_outputs: check_outputs,
      findings: Array(results).map(&:to_h),
    }
  end

  ##
  # Build array of check output hashes for serialization
  # @return [Array<Hash{Symbol => String}>]
  def check_outputs
    return [] unless artifacts

    artifacts.raw_check_output_records.map(&:to_h)
  end

  ##
  # Build manifest data for artifact persistence
  # @return [Hash{Symbol => Object}]
  def manifest_data
    {
      review_id: review_id,
      base_ref: comparison_base_ref,
      timestamp: timestamp,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
    }
  end

  private

  def comparison_base_ref
    base_ref || GitDiffBase::DEFAULT_BASE_REF
  end
end

#formatString (readonly)

Returns output format (human, agent, github).

Returns:

  • (String)

    output format (human, agent, github)



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
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
# File 'lib/cleo_quality_review/run.rb', line 27

Run = Struct.new(
  :timestamp,
  :review_id,
  :base_ref,
  :format,
  :checks,
  :target_files,
  :ruby_files,
  :run_directory,
  :results,
  :artifacts,
  :log,
  keyword_init: true,
) do
  ##
  # Convert the run to a hash representation
  # @return [Hash{Symbol => Object}]
  def to_h
    {
      timestamp: timestamp,
      review_id: review_id,
      base_ref: comparison_base_ref,
      format: format,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
      run_directory: run_directory,
      changes_diff: artifacts&.changes_diff,
      check_outputs: check_outputs,
      findings: Array(results).map(&:to_h),
    }
  end

  ##
  # Build array of check output hashes for serialization
  # @return [Array<Hash{Symbol => String}>]
  def check_outputs
    return [] unless artifacts

    artifacts.raw_check_output_records.map(&:to_h)
  end

  ##
  # Build manifest data for artifact persistence
  # @return [Hash{Symbol => Object}]
  def manifest_data
    {
      review_id: review_id,
      base_ref: comparison_base_ref,
      timestamp: timestamp,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
    }
  end

  private

  def comparison_base_ref
    base_ref || GitDiffBase::DEFAULT_BASE_REF
  end
end

#logObject

Returns the value of attribute log

Returns:

  • (Object)

    the current value of log



27
28
29
# File 'lib/cleo_quality_review/run.rb', line 27

def log
  @log
end

#resultsArray<Result> (readonly)

Returns findings from the quality checks.

Returns:

  • (Array<Result>)

    findings from the quality checks



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
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
# File 'lib/cleo_quality_review/run.rb', line 27

Run = Struct.new(
  :timestamp,
  :review_id,
  :base_ref,
  :format,
  :checks,
  :target_files,
  :ruby_files,
  :run_directory,
  :results,
  :artifacts,
  :log,
  keyword_init: true,
) do
  ##
  # Convert the run to a hash representation
  # @return [Hash{Symbol => Object}]
  def to_h
    {
      timestamp: timestamp,
      review_id: review_id,
      base_ref: comparison_base_ref,
      format: format,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
      run_directory: run_directory,
      changes_diff: artifacts&.changes_diff,
      check_outputs: check_outputs,
      findings: Array(results).map(&:to_h),
    }
  end

  ##
  # Build array of check output hashes for serialization
  # @return [Array<Hash{Symbol => String}>]
  def check_outputs
    return [] unless artifacts

    artifacts.raw_check_output_records.map(&:to_h)
  end

  ##
  # Build manifest data for artifact persistence
  # @return [Hash{Symbol => Object}]
  def manifest_data
    {
      review_id: review_id,
      base_ref: comparison_base_ref,
      timestamp: timestamp,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
    }
  end

  private

  def comparison_base_ref
    base_ref || GitDiffBase::DEFAULT_BASE_REF
  end
end

#review_idString (readonly)

Returns deterministic identifier for the reviewed diff.

Returns:

  • (String)

    deterministic identifier for the reviewed diff



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
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
# File 'lib/cleo_quality_review/run.rb', line 27

Run = Struct.new(
  :timestamp,
  :review_id,
  :base_ref,
  :format,
  :checks,
  :target_files,
  :ruby_files,
  :run_directory,
  :results,
  :artifacts,
  :log,
  keyword_init: true,
) do
  ##
  # Convert the run to a hash representation
  # @return [Hash{Symbol => Object}]
  def to_h
    {
      timestamp: timestamp,
      review_id: review_id,
      base_ref: comparison_base_ref,
      format: format,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
      run_directory: run_directory,
      changes_diff: artifacts&.changes_diff,
      check_outputs: check_outputs,
      findings: Array(results).map(&:to_h),
    }
  end

  ##
  # Build array of check output hashes for serialization
  # @return [Array<Hash{Symbol => String}>]
  def check_outputs
    return [] unless artifacts

    artifacts.raw_check_output_records.map(&:to_h)
  end

  ##
  # Build manifest data for artifact persistence
  # @return [Hash{Symbol => Object}]
  def manifest_data
    {
      review_id: review_id,
      base_ref: comparison_base_ref,
      timestamp: timestamp,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
    }
  end

  private

  def comparison_base_ref
    base_ref || GitDiffBase::DEFAULT_BASE_REF
  end
end

#ruby_filesArray<String> (readonly)

Returns Ruby file paths that were analyzed.

Returns:

  • (Array<String>)

    Ruby file paths that were analyzed



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
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
# File 'lib/cleo_quality_review/run.rb', line 27

Run = Struct.new(
  :timestamp,
  :review_id,
  :base_ref,
  :format,
  :checks,
  :target_files,
  :ruby_files,
  :run_directory,
  :results,
  :artifacts,
  :log,
  keyword_init: true,
) do
  ##
  # Convert the run to a hash representation
  # @return [Hash{Symbol => Object}]
  def to_h
    {
      timestamp: timestamp,
      review_id: review_id,
      base_ref: comparison_base_ref,
      format: format,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
      run_directory: run_directory,
      changes_diff: artifacts&.changes_diff,
      check_outputs: check_outputs,
      findings: Array(results).map(&:to_h),
    }
  end

  ##
  # Build array of check output hashes for serialization
  # @return [Array<Hash{Symbol => String}>]
  def check_outputs
    return [] unless artifacts

    artifacts.raw_check_output_records.map(&:to_h)
  end

  ##
  # Build manifest data for artifact persistence
  # @return [Hash{Symbol => Object}]
  def manifest_data
    {
      review_id: review_id,
      base_ref: comparison_base_ref,
      timestamp: timestamp,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
    }
  end

  private

  def comparison_base_ref
    base_ref || GitDiffBase::DEFAULT_BASE_REF
  end
end

#run_directoryString (readonly)

Returns path to the directory containing run artifacts.

Returns:

  • (String)

    path to the directory containing run artifacts



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
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
# File 'lib/cleo_quality_review/run.rb', line 27

Run = Struct.new(
  :timestamp,
  :review_id,
  :base_ref,
  :format,
  :checks,
  :target_files,
  :ruby_files,
  :run_directory,
  :results,
  :artifacts,
  :log,
  keyword_init: true,
) do
  ##
  # Convert the run to a hash representation
  # @return [Hash{Symbol => Object}]
  def to_h
    {
      timestamp: timestamp,
      review_id: review_id,
      base_ref: comparison_base_ref,
      format: format,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
      run_directory: run_directory,
      changes_diff: artifacts&.changes_diff,
      check_outputs: check_outputs,
      findings: Array(results).map(&:to_h),
    }
  end

  ##
  # Build array of check output hashes for serialization
  # @return [Array<Hash{Symbol => String}>]
  def check_outputs
    return [] unless artifacts

    artifacts.raw_check_output_records.map(&:to_h)
  end

  ##
  # Build manifest data for artifact persistence
  # @return [Hash{Symbol => Object}]
  def manifest_data
    {
      review_id: review_id,
      base_ref: comparison_base_ref,
      timestamp: timestamp,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
    }
  end

  private

  def comparison_base_ref
    base_ref || GitDiffBase::DEFAULT_BASE_REF
  end
end

#target_filesArray<String> (readonly)

Returns file paths that were analyzed.

Returns:

  • (Array<String>)

    file paths that were analyzed



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
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
# File 'lib/cleo_quality_review/run.rb', line 27

Run = Struct.new(
  :timestamp,
  :review_id,
  :base_ref,
  :format,
  :checks,
  :target_files,
  :ruby_files,
  :run_directory,
  :results,
  :artifacts,
  :log,
  keyword_init: true,
) do
  ##
  # Convert the run to a hash representation
  # @return [Hash{Symbol => Object}]
  def to_h
    {
      timestamp: timestamp,
      review_id: review_id,
      base_ref: comparison_base_ref,
      format: format,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
      run_directory: run_directory,
      changes_diff: artifacts&.changes_diff,
      check_outputs: check_outputs,
      findings: Array(results).map(&:to_h),
    }
  end

  ##
  # Build array of check output hashes for serialization
  # @return [Array<Hash{Symbol => String}>]
  def check_outputs
    return [] unless artifacts

    artifacts.raw_check_output_records.map(&:to_h)
  end

  ##
  # Build manifest data for artifact persistence
  # @return [Hash{Symbol => Object}]
  def manifest_data
    {
      review_id: review_id,
      base_ref: comparison_base_ref,
      timestamp: timestamp,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
    }
  end

  private

  def comparison_base_ref
    base_ref || GitDiffBase::DEFAULT_BASE_REF
  end
end

#timestampInteger (readonly)

Returns epoch milliseconds when the run started.

Returns:

  • (Integer)

    epoch milliseconds when the run started



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
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
# File 'lib/cleo_quality_review/run.rb', line 27

Run = Struct.new(
  :timestamp,
  :review_id,
  :base_ref,
  :format,
  :checks,
  :target_files,
  :ruby_files,
  :run_directory,
  :results,
  :artifacts,
  :log,
  keyword_init: true,
) do
  ##
  # Convert the run to a hash representation
  # @return [Hash{Symbol => Object}]
  def to_h
    {
      timestamp: timestamp,
      review_id: review_id,
      base_ref: comparison_base_ref,
      format: format,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
      run_directory: run_directory,
      changes_diff: artifacts&.changes_diff,
      check_outputs: check_outputs,
      findings: Array(results).map(&:to_h),
    }
  end

  ##
  # Build array of check output hashes for serialization
  # @return [Array<Hash{Symbol => String}>]
  def check_outputs
    return [] unless artifacts

    artifacts.raw_check_output_records.map(&:to_h)
  end

  ##
  # Build manifest data for artifact persistence
  # @return [Hash{Symbol => Object}]
  def manifest_data
    {
      review_id: review_id,
      base_ref: comparison_base_ref,
      timestamp: timestamp,
      checks: checks,
      target_files: target_files,
      ruby_files: ruby_files,
    }
  end

  private

  def comparison_base_ref
    base_ref || GitDiffBase::DEFAULT_BASE_REF
  end
end

Instance Method Details

#check_outputsArray<Hash{Symbol => String}>

Build array of check output hashes for serialization

Returns:

  • (Array<Hash{Symbol => String}>)


63
64
65
66
67
# File 'lib/cleo_quality_review/run.rb', line 63

def check_outputs
  return [] unless artifacts

  artifacts.raw_check_output_records.map(&:to_h)
end

#manifest_dataHash{Symbol => Object}

Build manifest data for artifact persistence

Returns:

  • (Hash{Symbol => Object})


72
73
74
75
76
77
78
79
80
81
# File 'lib/cleo_quality_review/run.rb', line 72

def manifest_data
  {
    review_id: review_id,
    base_ref: comparison_base_ref,
    timestamp: timestamp,
    checks: checks,
    target_files: target_files,
    ruby_files: ruby_files,
  }
end

#to_hHash{Symbol => Object}

Convert the run to a hash representation

Returns:

  • (Hash{Symbol => Object})


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/cleo_quality_review/run.rb', line 44

def to_h
  {
    timestamp: timestamp,
    review_id: review_id,
    base_ref: comparison_base_ref,
    format: format,
    checks: checks,
    target_files: target_files,
    ruby_files: ruby_files,
    run_directory: run_directory,
    changes_diff: artifacts&.changes_diff,
    check_outputs: check_outputs,
    findings: Array(results).map(&:to_h),
  }
end