garriguv / danger-ruby-swiftformat

A danger plugin to check Swift formatting using SwiftFormat.
MIT License
39 stars 15 forks source link

NoMethodError when running on CI with Jenkins #37

Closed fabfelici closed 3 years ago

fabfelici commented 3 years ago

Hi, I'm trying to add this plugin to have SwiftFormat on Danger and I faced this issue:

/home/jenkins/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/danger-swiftformat-0.8.0/lib/swiftformat/swiftformat.rb:17:in `check_format': undefined method `empty?' for nil:NilClass (NoMethodError)

It looks like this change broke the behaviour and adding

swiftformat.swiftversion = "5.3"

to Dangerfile fixes the issue but I think it shouldn't be mandatory to specify swiftversion right?.

Also after modifying the Dangerfile to this:

swiftformat.binary_path = "./scripts/swiftformat"
swiftformat.swiftversion = "5.3"
swiftformat.check_format(fail_on_error: true)

I get a different error now:

/home/jenkins/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/danger-swiftformat-0.8.0/lib/swiftformat/swiftformat.rb:31:in `check_format': Error running SwiftFormat: (RuntimeError)
Error: ./scripts/swiftformat: line 3: syntax error: unexpected ")"

Which seems related to this line.

Do you have any idea of what the issue could be? Thank you!

garriguv commented 3 years ago

Hi, yes, you're right! This option shouldn't be mandatory. I'll have a look later today after work.

If you're feeling adventurous, you could open a PR with the fix 😉

garriguv commented 3 years ago

I've just pushed version 0.8.1 which fixes the bug. Thank you for reporting it.