Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Evanczuk committed Apr 20, 2023
1 parent 9eda05a commit 2dd00f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
10 changes: 9 additions & 1 deletion lib/packwerk/file_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ def call(relative_file)
rescue Parsers::ParseError => e
ProcessedFile.new(offenses: [e.result])
rescue StandardError => e
offense = Parsers::ParseResult.new(file: relative_file, message: e.message)
message = <<~MSG
Packwerk encountered an internal error.
For now, you can add this file to `packwerk.yml` `exclude` list.
Please file an issue and include this error message and stacktrace:
#{e.message} #{e.backtrace}"
MSG

offense = Parsers::ParseResult.new(file: relative_file, message: message)
ProcessedFile.new(offenses: [offense])
end

Expand Down
14 changes: 5 additions & 9 deletions test/integration/packwerk/custom_executable_integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,9 @@ class CustomExecutableIntegrationTest < Minitest::Test

test "'packwerk check' does not blow up when parsing files with syntax issues from a false positive association" do
open_app_file(TIMELINE_PATH.join("app", "models", "bad_file.rb")) do |file|
# This is an example of a file that references `belongs_to`, but as an ActiveAdmin API
# rather than as a Rails Association concept
# This is an example of a file that has an object called `belongs_to` that accepts methods
content = <<~CONTENT
require 'rails_helper'
RSpec.describe ActiveAdmin::Resource::BelongsTo do
it "should have an owner" do
expect(belongs_to.owner).to eq post_config
end
end
belongs_to.some_method
CONTENT

file.write(content)
Expand All @@ -149,6 +142,9 @@ class CustomExecutableIntegrationTest < Minitest::Test

assert_match(/Packwerk is inspecting 13 files/, captured_output)
assert_match(%r{components/timeline/app/models/bad_file.rb}, captured_output)
assert_match(/Packwerk encountered an internal error/, captured_output)
assert_match(/For now, you can add this file to `packwerk.yml` `exclude` list./, captured_output)
assert_match(/Please file an issue and include this error message and stacktrace:/, captured_output)
assert_match(/Passed `nil` into T.must/, captured_output)
assert_match(/1 offense detected/, captured_output)
assert_match(/No stale violations detected/, captured_output)
Expand Down

0 comments on commit 2dd00f0

Please sign in to comment.