ClangFormat

A tool to format C/C++/Objective-C code.

Version

clang 5.0.0

Runtime

Alpine Linux 3.7

Supported Languages

C C++ Objective-C

Official Documentation

http://releases.llvm.org/5.0.0/tools/clang/docs/ClangFormat.html

YAML Configuration

clang-format:

  • input:

    Patterns to include in execution and reports.

  • ignore:

    Patterns to exclude from execution and reports.

  • auto-fix:

    true/false

  • config-file:

    Path to a style configuration file.

    Inspecode copies the specified file to <repo>/../.clang-format before running ClangFormat, so that your custom style configuration can be applied even if ClangFormat can not find the original one. In other words, you do not have to specify the configuration file to Inspecode if the file is already at the right place where ClangFormat can find directly. See the official document about how ClangFormat finds configuration files.

  • machine:

    • cpu:

      Amount of CPU. The default machine has 0.25 CPU with 960 MiB RAM.

  • options:

    Below is the list of options that are supported:

    OPTIONS:
      -fallback-style=<string>  - The name of the predefined style used as a
                                  fallback in case clang-format is invoked with
                                  -style=file, but can not find the .clang-format
                                  file to use.
                                  Use -fallback-style=none to skip formatting.
      -sort-includes            - If set, overrides the include sorting behavior determined by the SortIncludes style flag
      -style=<string>           - Coding style, currently supports:
                                    LLVM, Google, Chromium, Mozilla, WebKit.
                                  Use -style=file to load style configuration from
                                  .clang-format file located in one of the parent
                                  directories of the source file (or current
                                  directory for stdin).
                                  Use -style="{key: value, ...}" to set specific
                                  parameters, e.g.:
                                    -style="{BasedOnStyle: llvm, IndentWidth: 8}"
  • experimental:

    • incremental:

      true/false

      Note: The incremental analysis is disabled if any kinds of configuration files are changed. The files recognized as configuration files are as follows:

      • Style files:
        • Files specified in config-file field
        • If -style option is not specified or has file as a value:
          • **/.clang-format, **/_clang-format

YAML Examples

  • With default options:

    inspecode:
      clang-format: default
  • With enabling auto-fixing and default options:

    inspecode:
      clang-format: auto-fix
  • With enabling auto-fixing and a custom configuration file:

    inspecode:
      clang-format:
        auto-fix: true
        config-file: ./my-clang-format.yml
  • With custom machine:

    inspecode:
      clang-format:
        machine:
          cpu: 1.5 # 1.5 CPU, 5760 MiB RAM
  • With custom options:

    inspecode:
      clang-format:
        options:
          - -sort-includes
          - -style: Google

results matching ""

    No results matching ""