OCLint is a static code analysis 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 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 and continuous inspection of the code while being developed, so that technical debts can be fixed early on to reduce the maintenance cost.

Get OCLint

OCLint is a standalone tool that runs on Linux and Mac OS X platforms. You can get the latest version by building from source code or downloading pre-compiled binaries. The OCLint source code and binaries are distributed under Modified BSD License.


Inspirations and Acknowledgment

We're inspired by the great static analysis tools like P.M.D. for Java and CodeNarc for Groovy, as well as the smart code inspections performed by Jetbrains IntelliJ IDEA and AppCode.

OCLint is based on Clang Tooling, it's a handy library with great support writing standalone tools. We would like to appreciate the entire LLVM community for their hard work.