美文网首页
iOS OCLint代码分析介绍(一)2019-12-03

iOS OCLint代码分析介绍(一)2019-12-03

作者: AT19 | 来源:发表于2019-12-03 09:34 被阅读0次

1.oclint介绍中文

OCLint是一种静态代码分析工具,用于通过检查C,C ++和Objective-C代码并查找潜在问题来提高质量并减少缺陷。如下:

可能的错误-if / else / try / catch / finally语句为空
未使用的代码-未使用的局部变量和参数
复杂的代码-高圈复杂度,NPath复杂度和高NCSS
冗余代码-冗余if语句和无用的括号
代码气味-长方法和长参数列表
错误做法-逻辑和参数的重新分配
...
静态代码分析是检测编译器不可见的缺陷的一项关键技术。 OCLint通过高级功能自动执行此检查过程:

依靠源代码的抽象语法树来提高准确性和效率;误报大多会减少,以避免有用的结果沉入其中。
将规则动态加载到系统中,即使在运行时也是如此。
灵活且可扩展的配置可确保用户自定义工具的行为。
命令行调用有助于在开发过程中对代码进行持续集成和连续检查,从而可以尽早解决技术债务,从而降低维护成本。

1.oclint介绍英文

OCLint is a tool for improving quality and reducing defects by inspecting C, C++ and Objective-C code and looking for potential problems like:

*   Possible bugs - empty if/else/try/catch/finally statements
*   Unused code - unused local variables and parameters
*   Complicated code - high cyclomatic complexity, NPath complexity and high NCSS
*   Redundant code - redundant if statement and useless parentheses
*   Code smells - long method and long parameter list
*   Bad practices - inverted logic and parameter reassignment
*   ...

Static code analysis is a critical technique to detect defects that aren't visible to compilers. OCLint automates this inspection process with advanced features:

*   Relying on the [abstract syntax tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree) of the source code for better accuracy and efficiency; False positives are mostly reduced to avoid useful results sinking in them.
*   Dynamically loading rules into system, even in the runtime.
*   Flexible and extensible configurations ensure users in customizing the behaviors of the tool.
*   Command line invocation facilitates [continuous integration](http://martinfowler.com/articles/continuousIntegration.html) and continuous inspection of the code while being developed, so that technical debts can be fixed early on to reduce the maintenance cost.


相关文章

网友评论

      本文标题:iOS OCLint代码分析介绍(一)2019-12-03

      本文链接:https://www.haomeiwen.com/subject/otaqgctx.html