0

我正在尝试使用 OCLint 作为我的 objc 项目的主要代码分析器。我遵循 OCLint 指南并获得一个名为“compile_commands.json”的 json 文件。但我无法将其生成为 HTML 格式文件?任何人都可以帮助我吗?Athought尝试了十几种方法,但它不起作用。任何帮助表示赞赏。谢谢在此处输入图像描述

这是我的 json 文件的内容,一小部分

{
    "command" : "\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/bin\/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-cache-path=\/Users\/cscv\/Library\/Developer\/Xcode\/DerivedData\/ModuleCache -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DDEBUG=1 -isysroot \/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Developer\/SDKs\/iPhoneOS7.0.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -g -Wno-sign-conversion -miphoneos-version-min=7.0 -iquote \/Users\/cscv\/Library\/Developer\/Xcode\/DerivedData\/iPOS-bpnrfhmrxtknspfladklyclnczrw\/Build\/Intermediates\/IPSignDoc.build\/Debug-iphoneos\/IPSignDoc.build\/IPSignDoc-generated-files.hmap -I\/Users\/cscv\/Library\/Developer\/Xcode\/DerivedData\/iPOS-bpnrfhmrxtknspfladklyclnczrw\/Build\/Intermediates\/IPSignDoc.build\/Debug-iphoneos\/IPSignDoc.build\/IPSignDoc-own-target-headers.hmap -I\/Users\/cscv\/Library\/Developer\/Xcode\/DerivedData\/iPOS-bpnrfhmrxtknspfladklyclnczrw\/Build\/Intermediates\/IPSignDoc.build\/Debug-iphoneos\/IPSignDoc.build\/IPSignDoc-all-target-headers.hmap -iquote \/Users\/cscv\/Library\/Developer\/Xcode\/DerivedData\/iPOS-bpnrfhmrxtknspfladklyclnczrw\/Build\/Intermediates\/IPSignDoc.build\/Debug-iphoneos\/IPSignDoc.build\/IPSignDoc-project-headers.hmap -I\/Users\/cscv\/Library\/Developer\/Xcode\/DerivedData\/iPOS-bpnrfhmrxtknspfladklyclnczrw\/Build\/Products\/Debug-iphoneos\/include -I\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/include -I\/Users\/cscv\/Library\/Developer\/Xcode\/DerivedData\/iPOS-bpnrfhmrxtknspfladklyclnczrw\/Build\/Intermediates\/IPSignDoc.build\/Debug-iphoneos\/IPSignDoc.build\/DerivedSources\/armv7 -I\/Users\/cscv\/Library\/Developer\/Xcode\/DerivedData\/iPOS-bpnrfhmrxtknspfladklyclnczrw\/Build\/Intermediates\/IPSignDoc.build\/Debug-iphoneos\/IPSignDoc.build\/DerivedSources -F\/Users\/cscv\/Library\/Developer\/Xcode\/DerivedData\/iPOS-bpnrfhmrxtknspfladklyclnczrw\/Build\/Products\/Debug-iphoneos -include \/Users\/cscv\/Documents\/WORKSPACE_iPOS_iOS\/Main\/IPSignDoc\/IPSignDoc\/IPSignDoc-Prefix.pch -MMD -MT dependencies -MF \/Users\/cscv\/Library\/Developer\/Xcode\/DerivedData\/iPOS-bpnrfhmrxtknspfladklyclnczrw\/Build\/Intermediates\/IPSignDoc.build\/Debug-iphoneos\/IPSignDoc.build\/Objects-normal\/armv7\/IPSignDoc.d --serialize-diagnostics \/Users\/cscv\/Library\/Developer\/Xcode\/DerivedData\/iPOS-bpnrfhmrxtknspfladklyclnczrw\/Build\/Intermediates\/IPSignDoc.build\/Debug-iphoneos\/IPSignDoc.build\/Objects-normal\/armv7\/IPSignDoc.dia -c \/Users\/cscv\/Documents\/WORKSPACE_iPOS_iOS\/Main\/IPSignDoc\/IPSignDoc\/IPSignDoc.m -o \/Users\/cscv\/Library\/Developer\/Xcode\/DerivedData\/iPOS-bpnrfhmrxtknspfladklyclnczrw\/Build\/Intermediates\/IPSignDoc.build\/Debug-iphoneos\/IPSignDoc.build\/Objects-normal\/armv7\/IPSignDoc.o",
    "file" : "\/Users\/cscv\/Documents\/WORKSPACE_iPOS_iOS\/Main\/IPSignDoc\/IPSignDoc\/IPSignDoc.m",
    "directory" : "\/Users\/cscv\/Documents\/WORKSPACE_iPOS_iOS\/Main\/IPSignDoc"
  },

并使用oclint-json-compilation-database -v oclint_args "-report-type html -o report.html" 但没有任何反应!

4

1 回答 1

1

下面是我用来生成 html 文件的脚本。

OCLINT_HOME 是 oclint 下载文件夹的路径。我已将该文件夹重命名为 oclintrelease。

OCLINT_HOME=/Users/Dheeraj/Downloads/oclintrelease
export PATH=$OCLINT_HOME/bin:$PATH

hash oclint &> /dev/null
if [ $? -eq 1 ]; then
echo >&2 "oclint not found, analyzing stopped"
exit 1
fi

cd ${TARGET_TEMP_DIR}

if [ ! -f compile_commands.json ]; then
echo "[*] compile_commands.json not found, possibly clean was performed"
echo "[*] starting xcodebuild to rebuild the project.."
# clean previous output
if [ -f xcodebuild.log ]; then
rm xcodebuild.log
fi

cd ${SRCROOT}

xcodebuild clean

#build xcodebuild.log
xcodebuild | tee ${TARGET_TEMP_DIR}/xcodebuild.log
#xcodebuild <options>| tee ${TARGET_TEMP_DIR}/xcodebuild.log

echo "[*] transforming xcodebuild.log into compile_commands.json..."
cd ${TARGET_TEMP_DIR}
#transform it into compile_commands.json
oclint-xcodebuild

fi

echo "[*] starting analyzing"
cd ${TARGET_TEMP_DIR}

oclint-json-compilation-database -v oclint_args "-report-type html -o $OCLINT_HOME/report.html"

您的报告将使用上述脚本生成到 OCLINT_HOME 中提供的路径。

如果要在派生数据文件夹中生成报告,请将最后一行替换为:

oclint-json-compilation-database -v oclint_args "-report-type html -o report.html"

当且仅当您的构建成功并且您可以将生成的报告路径和脚本报告检查到 Xcode 的 Log Navigator 时,才会生成 HTML 报告。

于 2014-12-18T14:25:09.380 回答