Skip to content

Instantly share code, notes, and snippets.

@atomic-penguin
Created June 21, 2012 20:35
Show Gist options
  • Save atomic-penguin/2968356 to your computer and use it in GitHub Desktop.
Save atomic-penguin/2968356 to your computer and use it in GitHub Desktop.
Foodcritic FC001 fixer script.
#!/bin/bash
if [ "$#" -eq 0 ]; then
echo "Usage: `basename $0` <cookbook directory>"
elif [ "$#" -eq 1 ]; then
find $1 -name "*[.md|.rb]" ! -name "*.git" ! -name "*.erb" | xargs perl -p -e 's!\[:([a-z0-9_]+)\]![\x27$1\x27]!gi' -i
echo "Commit message:"
echo "FC001: Use strings in preference to symbols to access node attributes"
fi
@fooforge
Copy link

Hi,

thanks for the script, Eric! I forked it so that erb templates get ignored. Otherwise definitions like apache2's web_app definition will fail.
Here's some additional background: CHEF-2748 (params currently is a hash and not a hash with indifferent access) and an apache2 pull request.

Would be better to test for the params hash though instead of ignoring all erb templates, but I'm not enough of a regex guru.

Best regards,
Mike

@kevinkarwaski
Copy link

Super handy! Thanks!

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