Effrit now supports a PR checker which alerts if a new dependency is added to a package

Written by
Link to Post

https://www.reddit.com/r/golang/comments/boo8ys/effrit_now_supports_a_pr_checker_which_alerts_if/ by 

Hi folks.

A little while ago I wrote about Effrit. Which calculates some metrics called Afferent and Efferent coupling. It’s an interesting project I’ve been hacking on and as a suggestion from a friend of mine, I added a PR checker which does what the title says.

PR Checker Description.

TL;DR: It will see if there are changes to a package’s import statements as opposed to the one that’s in the repository ATM. If there is a new import statement to a package inside the project (I’m not checking standard libraries) then it will Tag the owner of the package in a comment on the PR.

In a large organisation where there are several people coding around on things, you might want to keep an eye on which packages are brought in as a dependency and why. Maybe they just don’t know that that package doesn’t belong there. A package owner can monitor this by adding a comment in the file:

“`go // Package pkg will save the universe from Thanos. // @package_owner = @Skarlso package pkg

func MyAwesomeFunc() { // Do something interesting. } “`

This way, if a new import statement is added in any of the files in a package, the person is tagged in a comment on the PR to check if it’s okay. If you don’t want this, simply don’t add yourself as an owner.

This requires effrit to be called like this:

effrit check-pr --owner Skarlso --pr-number 7 --repo effrit --project-name effrit

PR number owner and repo can all be obtained from the environment usually.

Anyways. That’s it. It’s a fun little project to hack on if you are looking for something. I’m trying to code in the right way too. So hopefully this will be something interesting once I refactor a bit. 🙂

Cheers, Skarlso

submitted by /u/skarlso
[link] [comments]

Article Tags:
· ·
Article Categories:

Leave a Reply