StyleCop

Analyzes C# source code to enforce a set of style and consistency rules.

Version

5.0.0

Runtime

Mono 5.18

Supported Languages

C#

Official Documentation

https://github.com/StyleCop/StyleCop

YAML Configuration

stylecop:

  • input:

    Patterns to include in reports.

    Note: The input patterns are not applied when running StyleCop. Therefore, the files excluded by the patterns are always processed and you may even see logs related to the excluded files in the job console. However, Inspecode eventually ignores any issues detected on the excluded files when generating job reports.

  • ignore:

    Patterns to exclude from reports.

    Note: Just like input:, the ignore patterns are not applied when running StyleCop.

  • auto-fix:

    N/A

  • config-file:

    Alias of /property: StyleCopOverrideSettingsFile= 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:

    /property:<n>=<v>  Set or override these project-level properties. <n> is
                       the property name, and <v> is the property value. Use a
                       semicolon or a comma to separate multiple properties, or
                       specify each property separately. (Short form: /p)
                       Example:
                         /property:WarningLevel=2;OutDir=bin\Debug\
    

YAML Examples

  • With default options:

    inspecode:
      stylecop: default
    
  • With custom machine:

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

    inspecode:
      stylecop:
        auto-fix: true
        options:
          - /property: WarningLevel=2
    
  • With a configuration file:

    inspecode:
      stylecop:
        config-file: my-settings.StyleCop
    

    The above configuration is equivalent to:

    inspecode:
      stylecop:
        options:
          - /property: StyleCopOverrideSettingsFile=my-settings.StyleCop
    

Configuration File Detection

If no configuration files are specified via config-file or options field, Inspecode walks the file tree in lexical order in your repository to find one of the following configuration files and specifies the file first found to StyleCop automatically via --config option.

  • Settings.StyleCop

Note: Inspecode ignores specific configuration files while searching. See Configuration > Tool Configuration > Field: config-file for detail.

If the configuration file detected by Inspecode is not the one you want to use or you do not want to use any configuration files, you can disable Inspecode from detecting configuration files by explicitly setting an empty string to config-file field like below:

inspecode:
  stylecop:
    config-file: ""

results matching ""

    No results matching ""