PricingDownload
Product

Platform

All features44 capabilities, from IDE to CICompliance KitsISO 26262, DO-178C, IEC 62304...AI GovernanceControl AI-generated C/C++ codeWhat’s new in 2027Latest version highlightsScreenshotsSee the product in action

Analyze & improve

Coding standardsMISRA, CERT, CWE, AUTOSARArchitecture & dependenciesGraphs, matrix, cyclesTechnical debtMeasured in hours and dollarsQuality gatesStop regressions in CISmart Code CityYour codebase in 3D

Integrations

IDE pluginsVisual Studio, VS Code, CLion...CI/CD pipelinesJenkins, Azure DevOps, GitHub, GitLabSonarQube pluginC/C++ results in SonarQubeExternal analyzersClang-Tidy, Cppcheck, coverageFeature on Demand
Solutions

By need

Functional safetyCompliance kits per standardCoding standardsMISRA, CERT, AUTOSAR, ISO...Legacy modernizationRefactor large C/C++ safelyCode auditExpert review of your codebaseM&A due diligenceAssess technical health fast

By role

DevelopersSoftware architectsTech leadsDevOps engineersEngineering managersProject managers

CTOsCIOs / IT leadersQA engineersSecurity leadersComplianceConsultantsRequest a guided PoC
Industries

Safety-critical

AutomotiveISO 26262, MISRA, AUTOSARAerospace & DefenseDO-178C programsMedical DevicesIEC 62304 softwareEnergy & UtilitiesIEC 61508 systemsEmbedded SystemsFirmware and devices

Enterprise

Financial ServicesTrading and paymentsGame DevelopmentEngines and large C++Software VendorsCommercial C/C++ productsGovernmentAgencies and contractorsAll industries & case studies
Resources

Learn

DocumentationGuides, rules and CI setupKnowledge baseFrequently asked questionsBlogC and C++ code quality articlesRelease notesEvery version since 2009

Customers

Case studiesSuccess storiesTestimonialsWhat users sayOur customersCompanies using CppDependGold Code QualityOpen source projects we rate

Programs & company

Feature on DemandMissing features built for freeFree for open sourceLicenses for OSS and studentsContact usSales and supportEULALicense agreement
Docs
Documentation

Guides

CQLinq

2 min readGuidesCppDepend 2027

CQLinq is the code query language of CppDepend. It is based on LINQ (Language Integrated Query) and allows you to write queries to explore your codebase, find code smells, and enforce coding standards.

With CQLinq, you can write queries to find types, methods, fields, and other code elements that match specific criteria. You can also write rules that warn you when certain conditions are met.

CQLinq is a powerful tool for code exploration, refactoring, and quality assurance. It is used extensively in CppDepend for all kinds of analysis tasks.

Looking for ready-to-use queries? See the PRQL Quick Reference — 37 queries you can copy and run immediately.

Getting Started with CQLinq

To get started with CQLinq, you can use the Queries and Rules Explorer panel in CppDepend. This panel contains a list of predefined queries and rules that you can run against your codebase.

You can also write your own queries using the CQLinq Editor. The editor provides syntax highlighting, code completion, and error checking to help you write queries quickly and accurately.

CQLinq queries are written in a syntax similar to SQL, but with C#-style syntax. Here is an example of a simple CQLinq query:

from m in Application.Methods
where m.NbLinesOfCode > 30
select m

This query finds all methods in the application that have more than 30 lines of code.

Query Examples

Here are some examples of CQLinq queries that you can use to explore your codebase:

Find all public methods with more than 5 parameters

from m in Application.Methods
where m.IsPublic && m.NbParameters > 5
select m

Find all types that implement a specific interface

from t in Application.Types
where t.Implement("MyNamespace.IMyInterface")
select t

Find all methods that are never called

from m in Application.Methods
where m.NbMethodsCallingMe == 0 && m.IsPublic
select m

Code Rules

CQLinq can also be used to write code rules. Code rules are queries that generate warnings when certain conditions are met.

To create a code rule, you write a CQLinq query and add a warnif or failif clause at the beginning. Here is an example:

warnif count > 0
from m in Application.Methods
where m.CyclomaticComplexity > 20
select m

This rule will generate a warning for every method that has a cyclomatic complexity greater than 20.

Metrics and Aggregation

CQLinq supports a wide range of metrics that you can use in your queries. These include code metrics like lines of code, cyclomatic complexity, and depth of inheritance, as well as dependency metrics like afferent and efferent coupling.

You can also use aggregation functions in your queries to compute statistics across your codebase. Here is an example:

from m in Application.Methods
select new { m, m.NbLinesOfCode, m.CyclomaticComplexity }
Was this page helpful?
Evaluating CppDepend on a production codebase?Get a guided proof of concept with our static analysis architects.
Request a PoC