Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running SwiftFormat: Empty output. #39

Open
ffittschen opened this issue Feb 11, 2021 · 2 comments
Open

Error running SwiftFormat: Empty output. #39

ffittschen opened this issue Feb 11, 2021 · 2 comments

Comments

@ffittschen
Copy link

Hi 👋🏻 Lately, we are increasingly seeing the following error message when running SwiftFormat using this Danger plugin.

bundler: failed to load command: danger (/Users/ci/.rbenv/versions/2.7.2/bin/danger)
Danger::DSLError: 
[!] Invalid `Dangerfile` file: Error running SwiftFormat: Empty output.
 #  from Dangerfile:5
 #  -------------------------------------------
 #    swiftformat.exclude = %w(Carthage/** **/*.generated.swift xcodetemplates/**)
 >    swiftformat.check_format(fail_on_error: true)
 #  
 #  -------------------------------------------

  /Users/ci/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/danger-swiftformat-0.8.1/lib/swiftformat/swiftformat.rb:33:in `check_format'
  /Users/ci/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/danger-swiftformat-0.8.1/lib/swiftformat/plugin.rb:54:in `check_format'
  Dangerfile:5:in `eval_file'
  /Users/ci/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/danger-8.2.2/lib/danger/danger_core/dangerfile.rb:311:in `eval'
  /Users/ci/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/danger-8.2.2/lib/danger/danger_core/dangerfile.rb:311:in `eval_file'
  /Users/ci/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/danger-8.2.2/lib/danger/danger_core/dangerfile.rb:204:in `block in parse'
  /Users/ci/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/danger-8.2.2/lib/danger/danger_core/dangerfile.rb:201:in `instance_eval'
  /Users/ci/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/danger-8.2.2/lib/danger/danger_core/dangerfile.rb:201:in `parse'
  /Users/ci/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/danger-8.2.2/lib/danger/danger_core/dangerfile.rb:287:in `run'
  /Users/ci/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/danger-8.2.2/lib/danger/danger_core/executor.rb:29:in `run'
  /Users/ci/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/danger-8.2.2/lib/danger/commands/runner.rb:73:in `run'
  /Users/ci/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
  /Users/ci/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/danger-8.2.2/bin/danger:5:in `<top (required)>'
  /Users/ci/.rbenv/versions/2.7.2/bin/danger:23:in `load'
  /Users/ci/.rbenv/versions/2.7.2/bin/danger:23:in `<top (required)>'
[!] The exception involves the following plugins:
 -  danger-swiftformat
Error: Process completed with exit code 1.

After investigating this error a bit, I'd like to understand why the error is raised in the case of:

  • swift files not empty
  • status is successful
  • stdout is empty
  • stderr is empty

Sadly I can't reproduce this case locally, as stderr is never empty for me, but I think we could handle this case more gracefully than raising an Error. The danger-ruby-swiftlint gem is handling this case by just returning an empty hash, i.e. no issues to report.

https://github.com/ashfurrow/danger-ruby-swiftlint/blob/master/lib/danger_plugin.rb#L167-L169

Do you think we could follow this approach?

@garriguv
Copy link
Owner

garriguv commented Feb 16, 2021

Hi,

First off, thank you for the detailed issue 👍

I agree with you: we should not fail builds if the output of the command is empty. If you're up for creating the PR, that would be great 😃
If not, let me know and I'll have a look in the coming days.

@ffittschen
Copy link
Author

Great, I'll create a PR in the coming days 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants