Class: Reviewer::Runner::FailedFiles
- Inherits:
-
Object
- Object
- Reviewer::Runner::FailedFiles
- Defined in:
- lib/reviewer/runner/failed_files.rb
Overview
Extracts file paths from tool output so that subsequent re-runs can be scoped to only the files that had issues.
Merges stdout and stderr before scanning because linters (rubocop, reek, etc.) write findings to stdout, not stderr. No common tool splits output with “passing files” on stdout and “failing files” on stderr, so merging is safe. The regex pattern and File.exist? guard filter out any incidental matches.
Constant Summary collapse
- FILE_PATH_PATTERN =
Matches relative path-like tokens at or near the start of a line, allowing leading whitespace for tools that indent output (reek groupings, rspec nesting). Rejects absolute paths (starting with /) to exclude Ruby runtime warnings and gem internals that would otherwise match. Tool findings always use relative paths from the project root. Supports any file extension so non-Ruby tools (eslint, stylelint) also work. File.exist? in to_a provides a final guard.
lib/foo.rb:45:3: C: Style/... (rubocop) test/foo_test.rb:45 (minitest) lib/foo.rb -- message (reek) src/app.js:10:5: error ... (eslint) %r{^\s*([^/\s]\S*\.\w+)(?::\d| -- )}
Instance Attribute Summary collapse
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
-
#initialize(stdout, stderr) ⇒ FailedFiles
constructor
Creates a failed-file extractor from captured tool output.
-
#matched_paths ⇒ Array<String>
All regex-matched paths before filesystem filtering.
-
#to_a ⇒ Array<String>
Regex-matched paths filtered to only those that exist on disk, deduplicated.
Constructor Details
#initialize(stdout, stderr) ⇒ FailedFiles
Creates a failed-file extractor from captured tool output
33 34 35 36 |
# File 'lib/reviewer/runner/failed_files.rb', line 33 def initialize(stdout, stderr) @stdout = stdout @stderr = stderr end |
Instance Attribute Details
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
26 27 28 |
# File 'lib/reviewer/runner/failed_files.rb', line 26 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
26 27 28 |
# File 'lib/reviewer/runner/failed_files.rb', line 26 def stdout @stdout end |
Instance Method Details
#matched_paths ⇒ Array<String>
All regex-matched paths before filesystem filtering. Useful for testing pattern matching without requiring real files on disk.
47 48 49 |
# File 'lib/reviewer/runner/failed_files.rb', line 47 def matched_paths combined_output.scan(FILE_PATH_PATTERN).flatten end |
#to_a ⇒ Array<String>
Regex-matched paths filtered to only those that exist on disk, deduplicated.
40 41 42 |
# File 'lib/reviewer/runner/failed_files.rb', line 40 def to_a matched_paths.select { |path| File.exist?(path) }.uniq end |