You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was just wondering if it's possible to wrap your plug-in inside another one. I'm trying to call the functions inside a common Ruby file (not sure if it's possible, I'm not too familiar with the danger structure)
It's something like this.
def lint(path)
swiftlint.config_file path
end
But I couldn't make it work looks like the DSL isn't available in that context only on Dangerfiles.
The text was updated successfully, but these errors were encountered:
Great question! What we'd need to do is move most of the logic from danger_plugin.rb into a different file, let's call it swiftlint.rb. The way we'd decide what goes where is this:
danger_plugin.rb
Extracts all the necessary context from the Danger DSL.
Calls function(s) in swiftlint.rb and receives all the violations.
Based on violations, make calls to warn, fail, etc.
swiftlint.rb
Gets passed in all the files specified from the Danger DSL (or, your new plugin 😉).
Does the config file and directory setup stuff.
Runs swiftlint and returns the violations.
While you work on this refactor, it will be helpful to keep the unit tests alone. It will be helpful for you to have a set of tests that make sure things are still working, as you refactor the code into two files. Afterward, in a separate commit, you could refactor the unit tests (or open an issue to work on them later, since small PRs are better than big ones).
If you're new to Ruby, this might seem a little challenging. But it's also a great way to learn about the language, and I'm here to answer any questions you have. Good luck!
Hey @ashfurrow again, thanks for taking the time to answer me.
I'll create a branch and start the refactor, I'll keep a PR opened as WIP so I can receive some feedbacks.
I was just wondering if it's possible to wrap your plug-in inside another one. I'm trying to call the functions inside a common Ruby file (not sure if it's possible, I'm not too familiar with the danger structure)
It's something like this.
def lint(path)
swiftlint.config_file path
end
But I couldn't make it work looks like the DSL isn't available in that context only on Dangerfiles.
The text was updated successfully, but these errors were encountered: