Difference between revisions of "Verifying Header Comments"
(Add page.) |
(Added categories.) |
||
| Line 15: | Line 15: | ||
# grep -r "Copyright" src/ | grep "java:" | while read line; do f="$(echo "$line" | cut -d: -f1)"; project="$(echo "$line" | cut -d' ' -f3)"; [ $project != "''Sone''" ] && echo "$f: $project"; done | # grep -r "Copyright" src/ | grep "java:" | while read line; do f="$(echo "$line" | cut -d: -f1)"; project="$(echo "$line" | cut -d' ' -f3)"; [ $project != "''Sone''" ] && echo "$f: $project"; done | ||
| + | |||
| + | [[Category:Programming]] | ||
| + | [[Category:Java]] | ||
| + | [[Category:Shell]] | ||
Revision as of 14:07, 17 January 2013
A normal Java source file (in my projects) consists of a header like the following one:
/* * FreenetSone - EditImagePage.java - Copyright © 2010–2012 David Roden * …
It should contain the name of the project and the name of the file. Sometimes, due to refactoring or copy/paste, the filename in the header does not match the name of the file in question. The following bash script will locate those files:
# grep -r "Copyright" src/ | grep "java:" | while read line; do f="$(echo "$line" | cut -d: -f1)"; c="$(echo "$line" | cut -d- -f2 | cut -d' ' -f2)"; f2="$(basename "$f")"; [ "$c" != "$f2" ] && echo "$f: $c"; done
And sometimes you even changed the name of the project at some point in the past. Use the following oneliner to find those files that have a different project name than the one you substitute at the end of the command:
# grep -r "Copyright" src/ | grep "java:" | while read line; do f="$(echo "$line" | cut -d: -f1)"; project="$(echo "$line" | cut -d' ' -f3)"; [ $project != "Sone" ] && echo "$f: $project"; done