问题标签 [oclint]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
788 浏览

objective-c - 由于无法找到#import-ed 头文件,OCLint 报告编译器错误

我正在尝试集成 OCLint 0.13 以检查基于 ObjC 的 iOS 项目中的 lint 违规情况。

根据本指南,我在 Xcode 中创建了一个聚合目标来运行 a,xcodebuild clean build然后oclint-xcodebuild生成一个compile_commands.json. 我能够clang从生成的compile_commands.json文件中运行命令。oclint-json-compilation-database但是,在由命令生成的 html 报告中,在处理类似 的文件时NEORepos/Public/ResourceObservables/NEOAggregatedObservable.h'NEOObservables/NEOObservable.h' file not found即使上述头文件存在于NEOObservables/Public/Observables/NEOObservable.h.

在此处输入图像描述

如何摆脱这些阻止我的某些源文件被检查的编译器错误?

compile_commands.json从生成文件运行 clang 命令.o,但 OCLint 似乎无法使用 json 文件进行编译。我还尝试添加更多-I包含路径,但没有帮助。欢迎所有建议和指点。

这是一段(编辑过的)日志......

xcode_clean_build_command = xcodebuild -workspace 'Neo.xcworkspace' -scheme 'NeoSampleApp' -configuration 'Debug' clean build -dry-run -derivedDataPath /Users/username/Documents/git/ios-neo_linter/build/Neo -sdk iphonesimulator CLANG_ENABLE_MODULE_DEBUGGING=NO CODE_SIGNING_ALLOWED=NO CODE_SIGN_IDENTITY='' CODE_SIGNING_REQUIRED=NO ENABLE_BITCODE=NO COMPILER_INDEX_STORE_ENABLE=NO | 三通 xcodebuild.log

...

/oclint-xcodebuild

...

生成 compile_commands.json ...

选择 NEORepos/Public/ResourceObservables/NEOAggregatedObservable.m 选择 NeoSampleApp/main.m

...

用于 linting 的入围文件(283 个中的 2 个)并创建新的 compile_commands.json

...

编译/Users/username/Documents/git/ios-neo_linter/NEORepos/Public/ResourceObservables/NEOAggregatedObservable.m - 编译失败/Users/username/Documents/git/ios-neo_linter/NeoSampleApp/main.m - 成功分析/Users/用户名/Documents/git/ios-neo_linter/NeoSampleApp/main.m - 完成

...

正在生成 lint 报告(如果有)...

...

执行命令:oclint-json-compilation-database -e Pods -v -- -list-enabled-rules -no-analytics -enable-global-analysis -verbose --report-type html -o oclint.html -extra-arg =-Wno-一切

...

/usr/local/bin/oclint -p /Users/username/Documents/git/ios-neo_linter -list-enabled-rules -no-analytics -enable-global-analysis -verbose --report-type html -o oclint. html -extra-arg=-Wno-everything /Users/username/Documents/git/ios-neo_linter/NEORepos/Public/ResourceObservables/NEOAggregatedObservable.m /Users/username/Documents/git/ios-neo_linter/NeoSampleApp/main.m

0 投票
0 回答
225 浏览

objective-c - OCLint 的编译器规则列表

是否有使用启用选项生成的所有编译器规则(不是OCLint 规则)的列表?oclint-enable-clang-static-analyzer

我正在寻找的是例如rule="clang static analyzer"rule="compiler warning"来自下面的 xml 片段。

0 投票
1 回答
324 浏览

objective-c - OCLint 在 html 报告文件中出现编译错误,但我的项目构建成功。为什么

oclint生成的html报告结果

xcodebuild -workspace ${myworkspace} -scheme ${myscheme} \ -sdk iphonesimulator \ -derivedDataPath ./build/derivedData \ -configuration Debug \ COMPILER_INDEX_STORE_ENABLE=NO \ | xcpretty -r json-compilation-database -o compile_commands.json

我运行上面的命令行来构建我的项目,它构建成功,但是当我运行下面的命令行来生成 oclint html 报告文件时,得到 15 个编译器错误。

oclint-json-compilation-database -e Pods -- \ -extra-arg=-Wno-error=everything \ -report-type html \ -rc LONG_LINE=200 \ -rule MultipleUnaryOperator \ -max-priority-1=0 \ -max-priority-2=10 \ -max-priority-3=20 \ -o ./oclint_report.html

0 投票
0 回答
471 浏览

xcode9.3 - OCLint Xcode 9.3.1 失败

我有以下运行脚本,可在http://oclint-docs.readthedocs.io/en/stable/guide/xcode.html获得

但是,当我执行它时,我收到以下错误。(1 次失败) oclint:指定的位置命令行参数不足!

oclint 版本是 OCLint 版本 0.13 和 Xcode 9.3.1

0 投票
0 回答
2418 浏览

oclint - 为什么会出现“访问构建数据库磁盘 I/O 错误”的错误?

当我使用Xcode10.2.1运行Oclint目标时,出现如下错误:

构建系统信息:-1:错误:访问构建数据库“ /Users//Library/Developer/Xcode/DerivedData/-axffsqylozkazhaxuzxqhztnaywu/Build/Intermediates.noindex/XCBuildData/build.db ”:磁盘I/O错误

0 投票
0 回答
51 浏览

c - C 的 OClint 警告混淆

我有一个程序,其中包含以下代码行

并且 OClint 给了我警告“破碎的奇数检查”,从文档中指出它不适用于负数,我理解,但它给我的解决方案是使用

然后给我一个“反转逻辑警告”并告诉我再次使用第一个代码......我不确定我应该在这里做什么。谢谢!

0 投票
1 回答
73 浏览

c - 在 C 中反转链表

我一直在研究反转链接列表的代码,但我似乎只在列表中打印出第一个元素。这是我的功能:

我为混乱的代码道歉,我尝试运行多个测试并在这里注释掉它们;我之前的代码运行良好,但在 OClint 中给出了垃圾值警告,所以我尝试修复它们,现在我的代码似乎不再工作了。如果没有其他方法,我可以回到我的原始代码。非常感谢任何输入!

0 投票
1 回答
74 浏览

c++ - 在 clang 中确定 VarDecl 的宏扩展

我是 C++ 的初学者,试图用 clang 对 Objective-C 代码进行 lint。我知道在使用 AST 访问节点和属性之前首先扩展宏。

我有一个名为 的宏NIL_CHECK,用于许多文件。在执行 lint 时,我想跳过扩展/使用此宏的行的变量声明。

例如,这个例子中的第一行应该被 linted,而第二行需要被跳过,这样当有一个宏扩展时就不会抛出误报:

这是VisitVarDecl访问者方法,它遍历每个变量声明以执行适当的 lint 检查:

如何确定宏并跳过此类变量声明?

0 投票
0 回答
26 浏览

c++ - 如何删除由于宏扩展引起的所有 OClint 警告

我面临 OCLint 和(例如)catch2宏扩展的问题:

未使用的局部变量 [unused|P3] 未使用局部变量“scopedMessage0”。
未使用的局部变量 [unused|P3] 未使用局部变量“scopedMessage1”。
...

每次我打电话时INFO("my message")(与 相同CHECK(my_condition))。

这不是我的代码,但在宏扩展后似乎在我的文件中,我想摆脱这些警告。
我看到的替代方案是:

OCLint 显然有一个关于禁用宏扩展的开放错误,但也许有一种解决方法或一种聪明的方法来处理一般情况下的这种情况(比如 grepping 结果以排除 scopeMessage?)。

谢谢您的帮助。

0 投票
0 回答
15 浏览

ios - 在 iOS 中使用配置文件自定义/禁用 OCLint 警告时没有发生任何事情

我知道有不同的方法可以自定义/禁用 OCLint 规则。我已按照以下步骤实现它,但没有任何反应。

  • 我在应用程序的根文件夹中创建了一个“.oclinnt.yml”文件,如下所示

在此处输入图像描述

  • 然后使用项目位置的终端执行以下注释。

    xcodebuild clean -workspace MyProject.xcworkspace -scheme MyProject_Target -destination "generic/platform=iOS"

    xcodebuild build -workspace MyProject.xcworkspace -scheme MyProject_Target -destination "generic/platform=iOS" COMPILER_INDEX_STORE_ENABLE=NO | xcpretty -r json 编译数据库 -o ./oclint/compile_commands.json

    oclint-json-compilation-database -p ./oclint -e Pods -e Vendors -- -max-priority-1 '10' -max-priority-2 '2000' -max-priority-3 '6000' -report-输入 html -o ./oclint/oclint_report.html

    我可以看到报告,但根据我的配置文件没有任何更改。我已经检查了以下链接。

参考链接:

有人可以帮我解决这个问题吗?