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

[Question] Add danger-ruby-swift-lint as dependency in other gem #136

Open
wellavelino opened this issue Oct 11, 2019 · 2 comments
Open

Comments

@wellavelino
Copy link

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.

@ashfurrow
Copy link
Owner

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!

@wellavelino
Copy link
Author

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.

👍

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