Skip to content

Instantly share code, notes, and snippets.

@Lockyy
Last active June 6, 2023 16:23
Show Gist options
  • Save Lockyy/e8b27420b4ac094b1c004712449f473b to your computer and use it in GitHub Desktop.
Save Lockyy/e8b27420b4ac094b1c004712449f473b to your computer and use it in GitHub Desktop.
Run Reek on files that've changed in Git
#!/bin/bash
reek --force-exclusion "$@" $(git status --porcelain | sed s/^...//)
@Lockyy
Copy link
Author

Lockyy commented Oct 17, 2018

--porcelain creates a future proof short list of changed files, sed then cuts out the first three characters of each line to ensure we don't have the actual status of each file. This leaves a nice set of changed files to pass into reek.

--force-exclusion means that even if the list of files includes files that are listed as excluded in your reek config file you won't get output for those files.

We then use "$@" to pass through all other parameters. This allows you to use this as your base reek command with modifiers if you want.

@Lockyy
Copy link
Author

Lockyy commented Dec 5, 2018

I should consider using something like git diff --name-only --diff-filter=d develop... to diff off of develop for this. So that I can see issues with my whole branch rather than just the current staging area.

Would be good if it was off of the parent branch rather than just develop however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment