metz-scan 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/metz_scan/analyzers/package_map.rb +1 -1
- data/lib/metz_scan/analyzers/test_calls_private_method/receiver_resolution.rb +3 -3
- data/lib/metz_scan/analyzers/test_calls_private_method/scope_resolution.rb +1 -1
- data/lib/metz_scan/commands/report.rb +16 -3
- data/lib/metz_scan/commands/scan/auto_fix.rb +49 -51
- data/lib/metz_scan/commands/scan/check_failure.rb +42 -0
- data/lib/metz_scan/commands/scan/config_disables.rb +83 -0
- data/lib/metz_scan/commands/scan/config_exclusions.rb +66 -30
- data/lib/metz_scan/commands/scan/exclude_entries.rb +5 -0
- data/lib/metz_scan/commands/scan/exclude_entry_locator.rb +15 -5
- data/lib/metz_scan/commands/scan/exclude_provenance.rb +7 -2
- data/lib/metz_scan/commands/scan/execution_config_store.rb +142 -0
- data/lib/metz_scan/commands/scan/ignored_cli_options_note.rb +35 -0
- data/lib/metz_scan/commands/scan/inherited_include_rewriter.rb +43 -0
- data/lib/metz_scan/commands/scan/inline_directive_locator.rb +38 -11
- data/lib/metz_scan/commands/scan/json_guidance.rb +81 -0
- data/lib/metz_scan/commands/scan/offense_extractor.rb +29 -7
- data/lib/metz_scan/commands/scan/path_scoped_include_note.rb +73 -0
- data/lib/metz_scan/commands/scan/project_analyzer_offenses.rb +21 -5
- data/lib/metz_scan/commands/scan/project_analyzer_runner.rb +21 -23
- data/lib/metz_scan/commands/scan/project_config_scope.rb +85 -28
- data/lib/metz_scan/commands/scan/rubocop_failure.rb +38 -0
- data/lib/metz_scan/commands/scan/rubocop_invocation.rb +141 -0
- data/lib/metz_scan/commands/scan/runner.rb +103 -49
- data/lib/metz_scan/commands/scan/sarif_rule_descriptors.rb +6 -24
- data/lib/metz_scan/commands/scan/suppression_ledger.rb +51 -14
- data/lib/metz_scan/commands/scan/suppression_ledger_formatter.rb +7 -1
- data/lib/metz_scan/commands/scan/target_ruby_version.rb +3 -2
- data/lib/metz_scan/commands/scan.rb +43 -21
- data/lib/metz_scan/project_index/rubydex_backend/method_visibility.rb +3 -0
- data/lib/metz_scan/version.rb +1 -1
- data/metz-scan.gemspec +9 -2
- metadata +16 -15
- data/lib/metz_scan/calibration/project_analyzer_evidence_runner/artifact_writer.rb +0 -51
- data/lib/metz_scan/calibration/project_analyzer_evidence_runner/baseline_delta.rb +0 -231
- data/lib/metz_scan/calibration/project_analyzer_evidence_runner/collaborators.rb +0 -76
- data/lib/metz_scan/calibration/project_analyzer_evidence_runner/markdown_renderer.rb +0 -353
- data/lib/metz_scan/calibration/project_analyzer_evidence_runner/readiness_catalog.rb +0 -127
- data/lib/metz_scan/calibration/project_analyzer_evidence_runner/summary.rb +0 -333
- data/lib/metz_scan/calibration/project_analyzer_evidence_runner/target_set.rb +0 -139
- data/lib/metz_scan/calibration/project_analyzer_evidence_runner.rb +0 -64
- data/lib/metz_scan/calibration/rubydex_drift_formatter.rb +0 -91
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require "psych"
|
|
4
4
|
require "rubocop"
|
|
5
5
|
|
|
6
|
+
require "metz_scan/commands/scan/config_disables"
|
|
6
7
|
require "metz_scan/commands/scan/config_exclusions"
|
|
7
8
|
require "metz_scan/commands/scan/inline_directive_locator"
|
|
8
9
|
require "metz_scan/commands/scan/project_config_scope"
|
|
@@ -11,34 +12,71 @@ module MetzScan
|
|
|
11
12
|
module Commands
|
|
12
13
|
class Scan
|
|
13
14
|
# Default mode asks RuboCop to --display-suppressed, then partitions every
|
|
14
|
-
# offense: a project per-cop Exclude hides it
|
|
15
|
-
# inline disable also covers it), else an inline
|
|
16
|
-
# it is live. Hidden offenses leave `files` and
|
|
17
|
-
# project wrote a suppression for are listed under
|
|
15
|
+
# offense: a project `Enabled: false` or per-cop Exclude hides it
|
|
16
|
+
# (credited even when an inline disable also covers it), else an inline
|
|
17
|
+
# directive hides it, else it is live. Hidden offenses leave `files` and
|
|
18
|
+
# the counts; the ones a project wrote a suppression for are listed under
|
|
19
|
+
# `suppressions`. Project analyzer offenses go through the same partition
|
|
20
|
+
# (see partition!), with `# metz-scan:disable` as their inline directive.
|
|
18
21
|
class SuppressionLedger
|
|
19
22
|
SORT_KEYS = %w[path line column cop_name].freeze
|
|
23
|
+
STORE_KEY = :metz_scan_suppression_ledger_store
|
|
20
24
|
|
|
21
|
-
def self.
|
|
22
|
-
|
|
25
|
+
def self.with_store(store)
|
|
26
|
+
previous = Thread.current[STORE_KEY]
|
|
27
|
+
Thread.current[STORE_KEY] = store
|
|
28
|
+
yield
|
|
29
|
+
ensure
|
|
30
|
+
Thread.current[STORE_KEY] = previous
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.apply(report, store: nil, rubocop_store: nil)
|
|
34
|
+
new(report, config_sources(store, rubocop_store)).apply
|
|
23
35
|
rescue RuboCop::Error, Psych::Exception
|
|
24
|
-
|
|
36
|
+
# Invalid project config leaves no project config to honor, matching
|
|
37
|
+
# the forced-default target-discovery fallback.
|
|
38
|
+
new(report, []).apply
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.config_sources(store, rubocop_store)
|
|
42
|
+
scope_store = store || Thread.current[STORE_KEY] || ProjectConfigScope.store
|
|
43
|
+
[ConfigDisables.new(scope_store, rubocop_store: rubocop_store),
|
|
44
|
+
ConfigExclusions.new(scope_store, rubocop_store: rubocop_store)]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Project analyzer offenses join the report after RuboCop's (in every
|
|
48
|
+
# scan mode): partitions `offenses_by_path`, adds its records to the
|
|
49
|
+
# report's ledger (created under --all-cops only when a record exists),
|
|
50
|
+
# and returns the live offenses by display path.
|
|
51
|
+
def self.partition!(report, offenses_by_path, store: nil, rubocop_store: nil)
|
|
52
|
+
files = offenses_by_path.map { |path, live| { "path" => Runner.display_path(path), "offenses" => live } }
|
|
53
|
+
partitioned = apply({ "files" => files, "summary" => {} }, store: store, rubocop_store: rubocop_store)
|
|
54
|
+
add_records(report, partitioned["suppressions"])
|
|
55
|
+
partitioned["files"].to_h { |file| file.values_at("path", "offenses") }.reject { |_path, live| live.empty? }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def self.add_records(report, new_records)
|
|
59
|
+
records = sort(Array(report["suppressions"]) + new_records)
|
|
60
|
+
report["suppressions"] = records if report.key?("suppressions") || records.any?
|
|
25
61
|
end
|
|
26
62
|
|
|
27
|
-
def
|
|
63
|
+
def self.sort(records) = records.sort_by { |record| record.values_at(*SORT_KEYS) }
|
|
64
|
+
|
|
65
|
+
def initialize(report, config_sources)
|
|
28
66
|
@report = report
|
|
29
|
-
@
|
|
67
|
+
@config_sources = config_sources
|
|
30
68
|
@directives = InlineDirectiveLocator.new
|
|
31
69
|
@records = []
|
|
32
70
|
end
|
|
33
71
|
|
|
34
72
|
def apply
|
|
35
73
|
files = Array(report["files"]).map { |file| file.merge("offenses" => live_offenses(file)) }
|
|
36
|
-
recount(report.merge("files" => files, "suppressions" =>
|
|
74
|
+
recount(report.merge("files" => files, "suppressions" => self.class.sort(records)))
|
|
37
75
|
end
|
|
38
76
|
|
|
39
77
|
private
|
|
40
78
|
|
|
41
|
-
attr_reader :report, :
|
|
79
|
+
attr_reader :report, :config_sources, :directives, :records
|
|
42
80
|
|
|
43
81
|
def live_offenses(file)
|
|
44
82
|
path = file.fetch("path")
|
|
@@ -49,9 +87,8 @@ module MetzScan
|
|
|
49
87
|
end
|
|
50
88
|
|
|
51
89
|
def suppression_source(path, offense)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
directives if offense["suppressed"]
|
|
90
|
+
config_source = config_sources.find { |source| source.scoped_off?(path, offense) }
|
|
91
|
+
config_source || (directives if offense["suppressed"] || directives.analyzer_disabled?(path, offense))
|
|
55
92
|
end
|
|
56
93
|
|
|
57
94
|
# Hidden offenses with no project-written suppression (stock-default
|
|
@@ -32,7 +32,13 @@ module MetzScan
|
|
|
32
32
|
return "inline disable at line #{record.dig('directive', 'line')}" unless record.fetch("config")
|
|
33
33
|
|
|
34
34
|
config = record.fetch("config")
|
|
35
|
-
"#{[config.fetch('path'), config.fetch('line')].compact.join(':')}
|
|
35
|
+
"#{[config.fetch('path'), config.fetch('line')].compact.join(':')} #{config_setting(record)}"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def config_setting(record)
|
|
39
|
+
return "Enabled: false" if record.fetch("suppressed_by") == "config_disabled"
|
|
40
|
+
|
|
41
|
+
"Exclude \"#{record.dig('config', 'pattern')}\""
|
|
36
42
|
end
|
|
37
43
|
|
|
38
44
|
def reason(record)
|
|
@@ -10,10 +10,11 @@ module MetzScan
|
|
|
10
10
|
|
|
11
11
|
module_function
|
|
12
12
|
|
|
13
|
-
def with_project_config(paths, all_cops:, &)
|
|
13
|
+
def with_project_config(paths, all_cops:, store: nil, &)
|
|
14
14
|
return yield if all_cops
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
version = ProjectConfigScope::TargetRubyVersion.new(paths, store: store || ProjectConfigScope.store).version
|
|
17
|
+
EnvOverride.new(version).with_env(&)
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
class EnvOverride
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
require "json"
|
|
4
4
|
require "optparse"
|
|
5
|
+
require "stringio"
|
|
5
6
|
|
|
6
7
|
require_relative "../version"
|
|
8
|
+
require_relative "scan/check_failure"
|
|
7
9
|
require_relative "scan/compliance_scorecard"
|
|
8
10
|
require_relative "scan/runner"
|
|
9
11
|
require_relative "scan/project_analyzer_runner"
|
|
@@ -11,6 +13,8 @@ require_relative "scan/text_renderer"
|
|
|
11
13
|
require_relative "scan/sarif_renderer"
|
|
12
14
|
require_relative "scan/github_annotations_renderer"
|
|
13
15
|
require_relative "scan/auto_fix"
|
|
16
|
+
require_relative "scan/ignored_cli_options_note"
|
|
17
|
+
require_relative "scan/json_guidance"
|
|
14
18
|
require_relative "../cli"
|
|
15
19
|
|
|
16
20
|
module MetzScan
|
|
@@ -93,7 +97,6 @@ module MetzScan
|
|
|
93
97
|
class Scan
|
|
94
98
|
USAGE = ScanOptions::USAGE
|
|
95
99
|
VALID_FORMATS = ScanOptions::VALID_FORMATS
|
|
96
|
-
RENDERERS = { "sarif" => SarifRenderer, "gh-annotations" => GithubAnnotationsRenderer }.freeze
|
|
97
100
|
|
|
98
101
|
def self.run(argv, stdout:, stderr:)
|
|
99
102
|
new(stdout: stdout, stderr: stderr).run(argv)
|
|
@@ -108,8 +111,8 @@ module MetzScan
|
|
|
108
111
|
handle_options(parse_options(argv))
|
|
109
112
|
rescue OptionParser::ParseError => e
|
|
110
113
|
parser_error(e)
|
|
111
|
-
rescue
|
|
112
|
-
|
|
114
|
+
rescue *CheckFailure::INTERNAL_ERRORS => e
|
|
115
|
+
CheckFailure.new(stderr).report(e)
|
|
113
116
|
end
|
|
114
117
|
|
|
115
118
|
private
|
|
@@ -134,35 +137,59 @@ module MetzScan
|
|
|
134
137
|
end
|
|
135
138
|
|
|
136
139
|
def dispatch(options)
|
|
137
|
-
return
|
|
140
|
+
return auto_fix(options) if options.auto_fix
|
|
138
141
|
|
|
139
142
|
scan(options)
|
|
140
143
|
end
|
|
141
144
|
|
|
145
|
+
def auto_fix(options)
|
|
146
|
+
AutoFix.new(stdout: stdout, stderr: stderr).run(options)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# The report reaches stdout only after every step succeeded; see CheckFailure.
|
|
142
150
|
def scan(options)
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
151
|
+
run_scan(options, options.all_cops ? {} : TargetFileDiscovery.scan_scope(options.paths))
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def run_scan(options, scope)
|
|
155
|
+
parsed = build_report(options, scope)
|
|
156
|
+
stdout.write(rendered(parsed, options))
|
|
157
|
+
IgnoredCliOptionsNote.print_note(stderr)
|
|
147
158
|
Runner.exit_code_for(parsed)
|
|
148
159
|
end
|
|
149
160
|
|
|
150
|
-
def
|
|
161
|
+
def build_report(options, scope)
|
|
162
|
+
parsed = checked_report(options, scope)
|
|
163
|
+
merge_project_analyzers(parsed, options, scope)
|
|
151
164
|
ComplianceScorecard.add_to_summary!(parsed)
|
|
165
|
+
parsed
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def checked_report(options, scope)
|
|
169
|
+
parsed = Runner.invoke(options.paths, all_cops: options.all_cops, stderr: stderr, **scope)
|
|
170
|
+
raise CheckFailure::NoFilesScanned, options.paths if parsed.dig("summary", "inspected_file_count").zero?
|
|
171
|
+
|
|
172
|
+
parsed
|
|
152
173
|
end
|
|
153
174
|
|
|
154
|
-
def merge_project_analyzers(parsed, options)
|
|
155
|
-
|
|
175
|
+
def merge_project_analyzers(parsed, options, scope)
|
|
176
|
+
opts = { default_output: !options.project_analyzers, all_cops: options.all_cops, **scope }
|
|
177
|
+
ProjectAnalyzerRunner.merge!(parsed, options.paths, **opts)
|
|
156
178
|
end
|
|
157
179
|
|
|
158
|
-
def
|
|
159
|
-
{
|
|
180
|
+
def rendered(parsed, options)
|
|
181
|
+
StringIO.new.tap { |out| render(out, parsed, options) }.string
|
|
160
182
|
end
|
|
161
183
|
|
|
162
|
-
|
|
163
|
-
|
|
184
|
+
# Text and SARIF render the compacted report so live output matches `report` on the saved JSON.
|
|
185
|
+
def render(out, parsed, options)
|
|
186
|
+
format = options.format
|
|
187
|
+
return GithubAnnotationsRenderer.new(out, parsed).render if format == "gh-annotations"
|
|
188
|
+
|
|
189
|
+
JsonGuidance.compact!(parsed, all_cops: options.all_cops)
|
|
190
|
+
return out.puts JSON.generate(parsed) if format == "json"
|
|
164
191
|
|
|
165
|
-
|
|
192
|
+
(format == "sarif" ? SarifRenderer : TextRenderer).new(out, parsed).render
|
|
166
193
|
end
|
|
167
194
|
|
|
168
195
|
def parser_error(err)
|
|
@@ -191,11 +218,6 @@ module MetzScan
|
|
|
191
218
|
stderr.puts "metz-scan scan: invalid --format '#{fmt}'. Valid formats: text, json, sarif, gh-annotations."
|
|
192
219
|
CLI::USAGE_ERROR
|
|
193
220
|
end
|
|
194
|
-
|
|
195
|
-
def runner_error(err)
|
|
196
|
-
stderr.puts "metz-scan scan: RuboCop failed: #{err.message}"
|
|
197
|
-
2
|
|
198
|
-
end
|
|
199
221
|
end
|
|
200
222
|
end
|
|
201
223
|
end
|
|
@@ -5,6 +5,9 @@ require "rubocop"
|
|
|
5
5
|
module MetzScan
|
|
6
6
|
class ProjectIndex
|
|
7
7
|
class RubydexBackend
|
|
8
|
+
# AST overlay for `module_function` visibility: Rubydex 0.2.8 aborted on
|
|
9
|
+
# that form. Rubydex 0.3.0 and later resolve it, but the overlay stays as
|
|
10
|
+
# the conservative path.
|
|
8
11
|
module MethodVisibility
|
|
9
12
|
def visibility_for(declaration, attributes)
|
|
10
13
|
return module_function_visibility(attributes) if module_function_method?(attributes)
|
data/lib/metz_scan/version.rb
CHANGED
data/metz-scan.gemspec
CHANGED
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
|
15
15
|
spec.homepage = "https://github.com/fuentesjr/metz-scan"
|
|
16
16
|
spec.license = "MIT"
|
|
17
17
|
|
|
18
|
-
spec.required_ruby_version = ">=
|
|
18
|
+
spec.required_ruby_version = ">= 4.0"
|
|
19
19
|
|
|
20
20
|
spec.metadata["source_code_uri"] = spec.homepage
|
|
21
21
|
spec.metadata["documentation_uri"] = "#{spec.homepage}/blob/main/README.md"
|
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.metadata["bug_tracker_uri"] = "#{spec.homepage}/issues"
|
|
24
24
|
spec.metadata["github_repo"] = "ssh://github.com/fuentesjr/metz-scan"
|
|
25
25
|
spec.metadata["github_package_uri"] = "https://github.com/users/fuentesjr/packages/rubygems/package/metz-scan"
|
|
26
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
|
26
27
|
|
|
27
28
|
# Resolve files from the gemspec directory so evaluation is CWD-independent.
|
|
28
29
|
# Do not raise when the entrypoint is absent: Dependabot evaluates gemspecs in
|
|
@@ -38,5 +39,11 @@ Gem::Specification.new do |spec|
|
|
|
38
39
|
spec.executables = ["metz-scan"]
|
|
39
40
|
spec.require_paths = ["lib"]
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
# The requirement is not the add_dependency argument. Dependabot's
|
|
43
|
+
# GemspecSanitizer replaces a call argument that interpolates a VERSION
|
|
44
|
+
# constant with a bare version, and Gem::Requirement.parse reads a bare
|
|
45
|
+
# version as "=". That drifts the lockfile PATH entry and a frozen install
|
|
46
|
+
# exits 16.
|
|
47
|
+
rubocop_metz_requirement = "~> #{MetzScan::VERSION}"
|
|
48
|
+
spec.add_dependency "rubocop-metz", rubocop_metz_requirement
|
|
42
49
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: metz-scan
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Salvador Fuentes Jr
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rubocop-metz
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - "~>"
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 0.7.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
25
|
+
version: 0.7.0
|
|
26
26
|
description: metz-scan is the user-facing CLI for the Sandi-Metz-inspired code-quality
|
|
27
27
|
toolchain. It runs RuboCop with the rubocop-metz plugin and renders developer-friendly
|
|
28
28
|
reports.
|
|
@@ -98,15 +98,6 @@ files:
|
|
|
98
98
|
- lib/metz_scan/analyzers/test_calls_private_method/scope_facts.rb
|
|
99
99
|
- lib/metz_scan/analyzers/test_calls_private_method/scope_resolution.rb
|
|
100
100
|
- lib/metz_scan/analyzers/test_calls_private_method/triage.rb
|
|
101
|
-
- lib/metz_scan/calibration/project_analyzer_evidence_runner.rb
|
|
102
|
-
- lib/metz_scan/calibration/project_analyzer_evidence_runner/artifact_writer.rb
|
|
103
|
-
- lib/metz_scan/calibration/project_analyzer_evidence_runner/baseline_delta.rb
|
|
104
|
-
- lib/metz_scan/calibration/project_analyzer_evidence_runner/collaborators.rb
|
|
105
|
-
- lib/metz_scan/calibration/project_analyzer_evidence_runner/markdown_renderer.rb
|
|
106
|
-
- lib/metz_scan/calibration/project_analyzer_evidence_runner/readiness_catalog.rb
|
|
107
|
-
- lib/metz_scan/calibration/project_analyzer_evidence_runner/summary.rb
|
|
108
|
-
- lib/metz_scan/calibration/project_analyzer_evidence_runner/target_set.rb
|
|
109
|
-
- lib/metz_scan/calibration/rubydex_drift_formatter.rb
|
|
110
101
|
- lib/metz_scan/cli.rb
|
|
111
102
|
- lib/metz_scan/commands/explain.rb
|
|
112
103
|
- lib/metz_scan/commands/project_analyzers.rb
|
|
@@ -114,14 +105,21 @@ files:
|
|
|
114
105
|
- lib/metz_scan/commands/rules.rb
|
|
115
106
|
- lib/metz_scan/commands/scan.rb
|
|
116
107
|
- lib/metz_scan/commands/scan/auto_fix.rb
|
|
108
|
+
- lib/metz_scan/commands/scan/check_failure.rb
|
|
117
109
|
- lib/metz_scan/commands/scan/compliance_scorecard.rb
|
|
110
|
+
- lib/metz_scan/commands/scan/config_disables.rb
|
|
118
111
|
- lib/metz_scan/commands/scan/config_exclusions.rb
|
|
119
112
|
- lib/metz_scan/commands/scan/exclude_entries.rb
|
|
120
113
|
- lib/metz_scan/commands/scan/exclude_entry_locator.rb
|
|
121
114
|
- lib/metz_scan/commands/scan/exclude_provenance.rb
|
|
115
|
+
- lib/metz_scan/commands/scan/execution_config_store.rb
|
|
122
116
|
- lib/metz_scan/commands/scan/github_annotations_renderer.rb
|
|
117
|
+
- lib/metz_scan/commands/scan/ignored_cli_options_note.rb
|
|
118
|
+
- lib/metz_scan/commands/scan/inherited_include_rewriter.rb
|
|
123
119
|
- lib/metz_scan/commands/scan/inline_directive_locator.rb
|
|
120
|
+
- lib/metz_scan/commands/scan/json_guidance.rb
|
|
124
121
|
- lib/metz_scan/commands/scan/offense_extractor.rb
|
|
122
|
+
- lib/metz_scan/commands/scan/path_scoped_include_note.rb
|
|
125
123
|
- lib/metz_scan/commands/scan/project_analyzer_breakdown.rb
|
|
126
124
|
- lib/metz_scan/commands/scan/project_analyzer_metadata.rb
|
|
127
125
|
- lib/metz_scan/commands/scan/project_analyzer_offenses.rb
|
|
@@ -131,6 +129,8 @@ files:
|
|
|
131
129
|
- lib/metz_scan/commands/scan/project_analyzer_triage_formatter.rb
|
|
132
130
|
- lib/metz_scan/commands/scan/project_analyzer_triage_priority.rb
|
|
133
131
|
- lib/metz_scan/commands/scan/project_config_scope.rb
|
|
132
|
+
- lib/metz_scan/commands/scan/rubocop_failure.rb
|
|
133
|
+
- lib/metz_scan/commands/scan/rubocop_invocation.rb
|
|
134
134
|
- lib/metz_scan/commands/scan/runner.rb
|
|
135
135
|
- lib/metz_scan/commands/scan/sarif_renderer.rb
|
|
136
136
|
- lib/metz_scan/commands/scan/sarif_rule_descriptors.rb
|
|
@@ -158,6 +158,7 @@ metadata:
|
|
|
158
158
|
bug_tracker_uri: https://github.com/fuentesjr/metz-scan/issues
|
|
159
159
|
github_repo: ssh://github.com/fuentesjr/metz-scan
|
|
160
160
|
github_package_uri: https://github.com/users/fuentesjr/packages/rubygems/package/metz-scan
|
|
161
|
+
rubygems_mfa_required: 'true'
|
|
161
162
|
rdoc_options: []
|
|
162
163
|
require_paths:
|
|
163
164
|
- lib
|
|
@@ -165,14 +166,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
165
166
|
requirements:
|
|
166
167
|
- - ">="
|
|
167
168
|
- !ruby/object:Gem::Version
|
|
168
|
-
version: '
|
|
169
|
+
version: '4.0'
|
|
169
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
171
|
requirements:
|
|
171
172
|
- - ">="
|
|
172
173
|
- !ruby/object:Gem::Version
|
|
173
174
|
version: '0'
|
|
174
175
|
requirements: []
|
|
175
|
-
rubygems_version:
|
|
176
|
+
rubygems_version: 4.0.20
|
|
176
177
|
specification_version: 4
|
|
177
178
|
summary: Sandi-Metz-inspired CLI wrapper around RuboCop.
|
|
178
179
|
test_files: []
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "fileutils"
|
|
4
|
-
require "json"
|
|
5
|
-
require "time"
|
|
6
|
-
|
|
7
|
-
module MetzScan
|
|
8
|
-
module Calibration
|
|
9
|
-
module ProjectAnalyzerEvidenceRunner
|
|
10
|
-
class ArtifactWriter
|
|
11
|
-
def initialize(summary:, output_dir:, run_id:)
|
|
12
|
-
@summary = summary
|
|
13
|
-
@output_dir = output_dir
|
|
14
|
-
@run_id = run_id || "project-analyzer-evidence-#{Time.now.utc.strftime('%Y%m%d-%H%M%S')}"
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def call
|
|
18
|
-
FileUtils.mkdir_p(run_dir)
|
|
19
|
-
write_json
|
|
20
|
-
write_markdown
|
|
21
|
-
artifacts
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
private
|
|
25
|
-
|
|
26
|
-
attr_reader :summary, :output_dir, :run_id
|
|
27
|
-
|
|
28
|
-
def write_json
|
|
29
|
-
File.write(artifacts.fetch("json"), "#{JSON.pretty_generate(persisted_summary)}\n")
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def write_markdown
|
|
33
|
-
File.write(artifacts.fetch("markdown"), MarkdownRenderer.new(persisted_summary).call)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def persisted_summary
|
|
37
|
-
summary.merge("artifacts" => artifacts)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def artifacts
|
|
41
|
-
{ "directory" => run_dir, "json" => File.join(run_dir, "summary.json"),
|
|
42
|
-
"markdown" => File.join(run_dir, "summary.md") }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def run_dir
|
|
46
|
-
File.join(File.expand_path(output_dir), run_id)
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|