<commit_before>==========
Clang-Tidy
==========

:program:`clang-tidy` is a clang-based C++ linter tool. Its purpose is to
provide an extensible framework for diagnosing and fixing typical programming
errors, like style violations, interface misuse, or bugs that can be deduced via
static analysis. :program:`clang-tidy` is modular and provides a convenient
interface for writing new checks.


Using clang-tidy
================

:program:`clang-tidy` is a `LibTooling`_-based tool, and it's easier to work
with if you set up a compile command database for your project (for an example
of how to do this see `How To Setup Tooling For LLVM`_ ). You can also specify
compilation options on the command line after ``--``:

.. code-block:: bash

  $ clang-tidy test.cpp -- -Imy_project/include -DMY_DEFINES ...

:program:`clang-tidy` has its own checks and can also run Clang static analyzer
checks. Each check has a name and the checks to run can be chosen using the
``-checks=`` option, which specifies a comma-separated list of positive and
negative (prefixed with ``-``) globs. Positive globs add subsets of checks,
negative globs remove them. For example,

.. code-block:: bash

  $ clang-tidy test.cpp -checks='-*,clang-analyzer-*,-clang-analyzer-alpha*'

will disable all default checks (``-*``) and enable all ``clang-analyzer-*``
checks except for ``clang-analyzer-alpha*`` ones.

The ``-list-checks`` option lists all the enabled checks. When used without
``-checks=``, it shows checks enabled by default. Use ``-checks='*'`` to see all
available checks or with any other value of ``-checks=`` to see which checks are
enabled by this value.

There are currently three groups of checks:

* Checks related to the LLVM coding conventions have names starting with
  ``llvm-``.

* Checks related to the Google coding conventions have names starting with
  ``google-``.

* Checks with names starting with ``misc-`` don't relate to any particular
  coding style.

* Clang static analyzer checks are named starting with ``clang-analyzer-``.


The ``-fix`` flag instructs :program:`clang-format` to fix found errors if
supported by corresponding checks.

An overview of all the command-line options:

.. code-block:: bash

  $ clang-tidy -help
  USAGE: clang-tidy [options] <source0> [... <sourceN>]

  OPTIONS:

  General options:

    -help                    - Display available options (-help-hidden
                               for more)
    -help-list               - Display list of available options
                               (-help-list-hidden for more)
    -version                 - Display the version of this program

  clang-tidy options:<commit_msg>[doc] Fix incorrect reference to clang-format -> clang-tidy<commit_after>==========
Clang-Tidy
==========

:program:`clang-tidy` is a clang-based C++ linter tool. Its purpose is to
provide an extensible framework for diagnosing and fixing typical programming
errors, like style violations, interface misuse, or bugs that can be deduced via
static analysis. :program:`clang-tidy` is modular and provides a convenient
interface for writing new checks.


Using clang-tidy
================

:program:`clang-tidy` is a `LibTooling`_-based tool, and it's easier to work
with if you set up a compile command database for your project (for an example
of how to do this see `How To Setup Tooling For LLVM`_ ). You can also specify
compilation options on the command line after ``--``:

.. code-block:: bash

  $ clang-tidy test.cpp -- -Imy_project/include -DMY_DEFINES ...

:program:`clang-tidy` has its own checks and can also run Clang static analyzer
checks. Each check has a name and the checks to run can be chosen using the
``-checks=`` option, which specifies a comma-separated list of positive and
negative (prefixed with ``-``) globs. Positive globs add subsets of checks,
negative globs remove them. For example,

.. code-block:: bash

  $ clang-tidy test.cpp -checks='-*,clang-analyzer-*,-clang-analyzer-alpha*'

will disable all default checks (``-*``) and enable all ``clang-analyzer-*``
checks except for ``clang-analyzer-alpha*`` ones.

The ``-list-checks`` option lists all the enabled checks. When used without
``-checks=``, it shows checks enabled by default. Use ``-checks='*'`` to see all
available checks or with any other value of ``-checks=`` to see which checks are
enabled by this value.

There are currently three groups of checks:

* Checks related to the LLVM coding conventions have names starting with
  ``llvm-``.

* Checks related to the Google coding conventions have names starting with
  ``google-``.

* Checks with names starting with ``misc-`` don't relate to any particular
  coding style.

* Clang static analyzer checks are named starting with ``clang-analyzer-``.


The ``-fix`` flag instructs :program:`clang-tidy` to fix found errors if
supported by corresponding checks.

An overview of all the command-line options:

.. code-block:: bash

  $ clang-tidy -help
  USAGE: clang-tidy [options] <source0> [... <sourceN>]

  OPTIONS:

  General options:

    -help                    - Display available options (-help-hidden
                               for more)
    -help-list               - Display list of available options
                               (-help-list-hidden for more)
    -version                 - Display the version of this program

  clang-tidy options:
{'fraction_non_alphanumeric': 0.10710301227222016, 'fraction_numerical': 0.0003718854592785422, 'mean_word_length': 3.3414043583535107, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5481015', 'n_tokens_mistral': 1548, 'n_tokens_neox': 1456, 'n_words': 667}