Static Code Analysis Tools for LibreOffice

Maintaining software stability across a multi-million-line codebase requires continuous, automated inspection. LibreOffice relies on a suite of static code analysis tools to catch bugs, memory leaks, security vulnerabilities, and code smell before code reaches production. The primary tools used to audit the LibreOffice codebase include Coverity Scan, custom Clang compiler plugins, Cppcheck, PVS-Studio, and CodeQL.

Coverity Scan

Coverity Scan is one of the most prominent static analysis tools used by the LibreOffice project. Since joining the Coverity Scan initiative for open-source software, the LibreOffice development team has resolved tens of thousands of defects, dramatically lowering the project’s defect density per thousand lines of code. Coverity analyzes LibreOffice’s complex C++ structures to identify:

Automated builds run Coverity scans periodically, alerting developers to regressions and defects introduced in recent commits.

Custom Clang Compiler Plugins

LibreOffice maintains an extensive internal suite of custom Clang plugins located within the compilerplugins/clang directory of its source tree. Because LibreOffice uses custom idioms—such as the Universal Network Objects (UNO) framework, custom string classes (OUString), and specialized reference-counting pointers—generic static analyzers do not always catch domain-specific misuse.

These AST-based Clang plugins run during compilation to enforce:

Cppcheck

Cppcheck is regularly utilized for auditing the LibreOffice C and C++ codebase. Unlike compiler warnings, Cppcheck focuses on deep, non-standard static analysis with very low false-positive rates. It is used to detect:

PVS-Studio

PVS-Studio is periodically used to audit the LibreOffice source tree. The tool excels at catching complex C++ issues that standard compilers miss, such as:

Insights from PVS-Studio audits are regularly reviewed by core contributors to patch deep-seated legacy bugs.

CodeQL and GitHub Automated Analysis

With parts of the LibreOffice ecosystem and associated subprojects hosted or mirrored on GitHub, semantic analysis engines like GitHub CodeQL (formerly LGTM) are used for automated security reviews. CodeQL treats code as data, running queries to detect security vulnerabilities such as buffer overflows, injection points, and unsafe type casts directly within the continuous integration (CI) pipeline.