Artistic Style

Artistic Style is a source code indenter, formatter, and beautifier for the C, C++, C++/CLI, Objective‑C, C# and Java programming languages.

Version

3.1

Runtime

Debian Stretch

Supported Languages

C C++ Objective-C C# Java

Official Documentation

http://astyle.sourceforge.net/

YAML Configuration

astyle:

  • input:

    Patterns to include in execution and reports.

  • ignore:

    Patterns to exclude from execution and reports.

  • auto-fix:

    true/false

  • config-file:

    Alias of --options option.

  • 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:

    Brace Style Options:
    --------------------
        default brace style
        If no brace style is requested, the opening braces will not be
        changed and closing braces will be broken from the preceding line.
    
        --style=allman  OR  --style=bsd  OR  --style=break  OR  -A1
        Allman style formatting/indenting.
        Broken braces.
    
        --style=java  OR  --style=attach  OR  -A2
        Java style formatting/indenting.
        Attached braces.
    
        --style=kr  OR  --style=k&r  OR  --style=k/r  OR  -A3
        Kernighan & Ritchie style formatting/indenting.
        Linux braces.
    
        --style=stroustrup  OR  -A4
        Stroustrup style formatting/indenting.
        Linux braces.
    
        --style=whitesmith  OR  -A5
        Whitesmith style formatting/indenting.
        Broken, indented braces.
        Indented class blocks and switch blocks.
    
        --style=vtk  OR  -A15
        VTK style formatting/indenting.
        Broken, indented braces except for the opening braces.
    
        --style=ratliff  OR  --style=banner  OR  -A6
        Ratliff style formatting/indenting.
        Attached, indented braces.
    
        --style=gnu  OR  -A7
        GNU style formatting/indenting.
        Broken braces, indented blocks.
    
        --style=linux  OR  --style=knf  OR  -A8
        Linux style formatting/indenting.
        Linux braces, minimum conditional indent is one-half indent.
    
        --style=horstmann  OR  --style=run-in  OR  -A9
        Horstmann style formatting/indenting.
        Run-in braces, indented switches.
    
        --style=1tbs  OR  --style=otbs  OR  -A10
        One True Brace Style formatting/indenting.
        Linux braces, add braces to all conditionals.
    
        --style=google  OR  -A14
        Google style formatting/indenting.
        Attached braces, indented class modifiers.
    
        --style=mozilla  OR  -A16
        Mozilla style formatting/indenting.
        Linux braces, with broken braces for structs and enums,
        and attached braces for namespaces.
    
        --style=pico  OR  -A11
        Pico style formatting/indenting.
        Run-in opening braces and attached closing braces.
        Uses keep one line blocks and keep one line statements.
    
        --style=lisp  OR  -A12
        Lisp style formatting/indenting.
        Attached opening braces and attached closing braces.
        Uses keep one line statements.
    
    Tab Options:
    ------------
        default indent option
        If no indentation option is set, the default
        option of 4 spaces per indent will be used.
    
        --indent=spaces=#  OR  -s#
        Indent using # spaces per indent. Not specifying #
        will result in a default of 4 spaces per indent.
    
        --indent=tab  OR  --indent=tab=#  OR  -t  OR  -t#
        Indent using tab characters, assuming that each
        indent is # spaces long. Not specifying # will result
        in a default assumption of 4 spaces per indent.
    
        --indent=force-tab=#  OR  -T#
        Indent using tab characters, assuming that each
        indent is # spaces long. Force tabs to be used in areas
        AStyle would prefer to use spaces.
    
        --indent=force-tab-x=#  OR  -xT#
        Allows the tab length to be set to a length that is different
        from the indent length. This may cause the indentation to be
        a mix of both spaces and tabs. This option sets the tab length.
    
    Brace Modify Options:
    ---------------------
        --attach-namespaces  OR  -xn
        Attach braces to a namespace statement.
    
        --attach-classes  OR  -xc
        Attach braces to a class statement.
    
        --attach-inlines  OR  -xl
        Attach braces to class inline function definitions.
    
        --attach-extern-c  OR  -xk
        Attach braces to an extern "C" statement.
    
        --attach-closing-while  OR  -xV
        Attach closing while of do-while to the closing brace.
    
    Indentation Options:
    --------------------
        --indent-classes  OR  -C
        Indent 'class' blocks so that the entire block is indented.
    
        --indent-modifiers  OR  -xG
        Indent 'class' access modifiers, 'public:', 'protected:' or
        'private:', one half indent. The rest of the class is not
        indented.
    
        --indent-switches  OR  -S
        Indent 'switch' blocks, so that the inner 'case XXX:'
        headers are indented in relation to the switch block.
    
        --indent-cases  OR  -K
        Indent case blocks from the 'case XXX:' headers.
        Case statements not enclosed in blocks are NOT indented.
    
        --indent-namespaces  OR  -N
        Indent the contents of namespace blocks.
    
        --indent-after-parens  OR  -xU
        Indent, instead of align, continuation lines following lines
        that contain an opening paren '(' or an assignment '='.
    
        --indent-continuation=#  OR  -xt#
        Indent continuation lines an additional # indents.
        The valid values are 0 thru 4 indents.
        The default value is 1 indent.
    
        --indent-labels  OR  -L
        Indent labels so that they appear one indent less than
        the current indentation level, rather than being
        flushed completely to the left (which is the default).
    
        --indent-preproc-block  OR  -xW
        Indent preprocessor blocks at brace level 0.
        Without this option the preprocessor block is not indented.
    
        --indent-preproc-cond  OR  -xw
        Indent preprocessor conditional statements #if/#else/#endif
        to the same level as the source code.
    
        --indent-preproc-define  OR  -w
        Indent multi-line preprocessor #define statements.
    
        --indent-col1-comments  OR  -Y
        Indent line comments that start in column one.
    
        --min-conditional-indent=#  OR  -m#
        Indent a minimal # spaces in a continuous conditional
        benameEqualValueing to a conditional header.
        The valid values are:
        0 - no minimal indent.
        1 - indent at least one additional indent.
        2 - indent at least two additional indents.
        3 - indent at least one-half an additional indent.
        The default value is 2, two additional indents.
    
        --max-continuation-indent=#  OR  -M#
        Indent a maximal # spaces in a continuation line,
        relative to the previous line.
        The valid values are 40 thru 120.
        The default value is 40.
    
    Padding Options:
    ----------------
        --break-blocks  OR  -f
        Insert empty lines around unrelated blocks, labels, classes, ...
    
        --break-blocks=all  OR  -F
        Like --break-blocks, except also insert empty lines
        around closing headers (e.g. 'else', 'catch', ...).
    
        --pad-oper  OR  -p
        Insert space padding around operators.
    
        --pad-comma  OR  -xg
        Insert space padding after commas.
    
        --pad-paren  OR  -P
        Insert space padding around parenthesis on both the outside
        and the inside.
    
        --pad-paren-out  OR  -d
        Insert space padding around parenthesis on the outside only.
    
        --pad-first-paren-out  OR  -xd
        Insert space padding around first parenthesis in a series on
        the outside only.
    
        --pad-paren-in  OR  -D
        Insert space padding around parenthesis on the inside only.
    
        --pad-header  OR  -H
        Insert space padding after paren headers (e.g. 'if', 'for'...).
    
        --unpad-paren  OR  -U
        Remove unnecessary space padding around parenthesis. This
        can be used in combination with the 'pad' options above.
    
        --delete-empty-lines  OR  -xe
        Delete empty lines within a function or method.
        It will NOT delete lines added by the break-blocks options.
    
        --fill-empty-lines  OR  -E
        Fill empty lines with the white space of their
        previous lines.
    
        --align-pointer=type    OR  -k1
        --align-pointer=middle  OR  -k2
        --align-pointer=name    OR  -k3
        Attach a pointer or reference operator (*, &, or ^) to either
        the operator type (left), middle, or operator name (right).
        To align the reference separately use --align-reference.
    
        --align-reference=none    OR  -W0
        --align-reference=type    OR  -W1
        --align-reference=middle  OR  -W2
        --align-reference=name    OR  -W3
        Attach a reference operator (&) to either
        the operator type (left), middle, or operator name (right).
        If not set, follow pointer alignment.
    
    Formatting Options:
    -------------------
        --break-closing-braces  OR  -y
        Break braces before closing headers (e.g. 'else', 'catch', ...).
        Use with --style=java, --style=kr, --style=stroustrup,
        --style=linux, or --style=1tbs.
    
        --break-elseifs  OR  -e
        Break 'else if()' statements into two different lines.
    
        --break-one-line-headers  OR  -xb
        Break one line headers (e.g. 'if', 'while', 'else', ...) from a
        statement residing on the same line.
    
        --add-braces  OR  -j
        Add braces to unbraced one line conditional statements.
    
        --add-one-line-braces  OR  -J
        Add one line braces to unbraced one line conditional
        statements.
    
        --remove-braces  OR  -xj
        Remove braces from a braced one line conditional statements.
        --break-return-type       OR  -xB
        --break-return-type-decl  OR  -xD
        Break the return type from the function name. Options are
        for the function definitions and the function declarations.
        --attach-return-type       OR  -xf
        --attach-return-type-decl  OR  -xh
        Attach the return type to the function name. Options are
        for the function definitions and the function declarations.
    
        --keep-one-line-blocks  OR  -O
        Don't break blocks residing completely on one line.
    
        --keep-one-line-statements  OR  -o
        Don't break lines containing multiple statements into
        multiple single-statement lines.
    
        --convert-tabs  OR  -c
        Convert tabs to the appropriate number of spaces.
    
        --close-templates  OR  -xy
        Close ending angle brackets on template definitions.
    
        --remove-comment-prefix  OR  -xp
        Remove the leading '*' prefix on multi-line comments and
        indent the comment text one indent.
    
        --max-code-length=#    OR  -xC#
        --break-after-logical  OR  -xL
        max-code-length=# will break the line if it exceeds more than
        # characters. The valid values are 50 thru 200.
        If the line contains logical conditionals they will be placed
        first on the new line. The option break-after-logical will
        cause the logical conditional to be placed last on the
        previous line.
    
        --mode=c
        Indent a C or C++ source file (this is the default).
    
        --mode=java
        Indent a Java source file.
    
        --mode=cs
        Indent a C# source file.
    
    Objective-C Options:
    --------------------
        --pad-method-prefix  OR  -xQ
        Insert space padding after the '-' or '+' Objective-C
        method prefix.
    
        --unpad-method-prefix  OR  -xR
        Remove all space padding after the '-' or '+' Objective-C
        method prefix.
    
        --pad-return-type  OR  -xq
        Insert space padding after the Objective-C return type.
    
        --unpad-return-type  OR  -xr
        Remove all space padding after the Objective-C return type.
    
        --pad-param-type  OR  -xS
        Insert space padding after the Objective-C return type.
    
        --unpad-param-type  OR  -xs
        Remove all space padding after the Objective-C return type.
    
        --align-method-colon  OR  -xM
        Align the colons in an Objective-C method definition.
    
        --pad-method-colon=none    OR  -xP
        --pad-method-colon=all     OR  -xP1
        --pad-method-colon=after   OR  -xP2
        --pad-method-colon=before  OR  -xP3
        Add or remove space padding before or after the colons in an
        Objective-C method call.
    
    Other Options:
    --------------
        --exclude=####
        Specify a file or directory #### to be excluded from processing.
    
        --preserve-date  OR  -Z
        Preserve the original file's date and time modified. The time
         modified will be changed a few micro seconds to force a compile.
    
        --lineend=windows  OR  -z1
        --lineend=linux    OR  -z2
        --lineend=macold   OR  -z3
        Force use of the specified line end style. Valid options
        are windows (CRLF), linux (LF), and macold (CR).
    
    Command Line Only:
    ------------------
        --options=####
        Specify an options file #### to read and use.
    
        --options=none
        Disable the default options file.
        Only the command-line parameters will be used.
    
  • thresholds:

    • num-issues:

      No tool specific severity levels are available.

  • 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:

      • Option files:
        • Files specified in config-file field
        • Files specified to --options option

YAML Examples

  • With default options:

    inspecode:
      astyle: default
    
  • With enabling auto-fixing and default options:

    inspecode:
      astyle: auto-fix
    
  • With custom machine:

    inspecode:
      astyle:
        machine:
          cpu: 1.5 # 1.5 CPU, 5760 MiB RAM
    
  • With custom options:

    inspecode:
      astyle:
        options:
          --style: gnu
          --break-blocks: all
          -k: 1 # --align-pointer=type
    
  • With a configuration file:

    inspecode:
      astyle:
        config-file: ./my-astylerc
    

    The above configuration is equivalent to:

    inspecode:
      astyle:
        options:
          --options: ./my-astylerc
    

results matching ""

    No results matching ""