|
# Original script at |
|
# https://gist.github.com/guilhermearaujo/a6e4dbb982fea40a0513 |
|
|
|
##source ~/.bash_profile |
|
export PATH=$PATH:/usr/local/bin/ |
|
|
|
if [ -z "${SCHEME+x}" ] |
|
then |
|
export SCHEME="${PROJECT_NAME}" |
|
fi |
|
|
|
# "Workspace" is actually the project |
|
if [ -z "${WORKSPACE+x}" ] |
|
then |
|
export WORKSPACE="${PROJECT_NAME}.xcodeproj" |
|
fi |
|
|
|
cd "${SOURCE_ROOT}" |
|
|
|
# Check if oclint is installed |
|
if ! which -s oclint-json-compilation-database |
|
then |
|
echo 'error: OCLint not installed, install e.g. with homebrew cask' |
|
exit 2 |
|
fi |
|
|
|
# Cleanup before building |
|
rm -f compile_commands.json |
|
|
|
# Build and analyze |
|
# OCLint Rule Index: https://oclint-docs.readthedocs.io/en/v0.13/rules/index.html |
|
|
|
echo "Starting clean and build..." |
|
xcodebuild -project "${WORKSPACE}" -scheme "${SCHEME}" -configuration Bot \ |
|
clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO > xcodebuild.log |
|
echo "Finished clean and build project." |
|
|
|
oclint-xcodebuild | xcpretty -r json-compilation-database |
|
echo "Built json compilation database at ./compile-commands.json" |
|
|
|
# AssignIvarOutsideAccessors is for version 0.13 |
|
# IvarAssignmentOutsideAccessorsOrInit is for 0.10.3 only |
|
oclint-json-compilation-database -e Janrain -- -max-priority-1=100000 -max-priority-2=100000 -max-priority-3=100000 \ |
|
-disable-rule=InvertedLogic \ |
|
-disable-rule=UnusedMethodParameter \ |
|
-disable-rule=LongLine \ |
|
-disable-rule=LongVariableName \ |
|
-disable-rule=ShortVariableName \ |
|
-disable-rule=UselessParentheses \ |
|
-disable-rule=HighNcssMethod \ |
|
-disable-rule=HighNPathComplexity \ |
|
-disable-rule=LongMethod \ |
|
-disable-rule=LongClass \ |
|
-disable-rule=HighCyclomaticComplexity \ |
|
-disable-rule=TooManyMethods \ |
|
-disable-rule=DeepNestedBlock \ |
|
-disable-rule=AssignIvarOutsideAccessors \ |
|
-disable-rule=IvarAssignmentOutsideAccessorsOrInit | sed 's/\(.*\.\m\{1,2\}:[0-9]*:[0-9]*:\)/\1 warning:/' |
|
|
|
# Final cleanup |
|
rm -f compile_commands.json |
|
rm -f xcodebuild.log |