Last active
November 26, 2020 11:09
-
-
Save jonreid/1258076 to your computer and use it in GitHub Desktop.
Terminal command to help you find preprocessor code smells in Objective-C code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . \( \( -name "*.[chm]" -o -name "*.mm" \) -o -name "*.cpp" \) -print0 | xargs -0 egrep -n '^\w*\#' | egrep -v '(import|pragma|else|endif|HC_SHORTHAND|MOCKITO_SHORTHAND)' |
You might want to exclude 'include' statements in your script as well. Legacy C code will trigger false positives otherwise.
EDIT: Oh duh, just read the first point about preprocessor smells, but legacy code gets a pass.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This command examines source files from the current directory down, showing preprocessor use that you should double-check.
See "9 Code Smells of Preprocessor Use" https://qualitycoding.org/xcode-preprocessor-macros/