Expand Minimize

Rulesets

Settings in SPCAF are files with extension '.spruleset', which configure the analysis process, the reports to be created and define, which rules are disabled during analysis.

Usage samples
Settings can be used with the commandline parameter 'SettingsFile' to disable rules during analysis.
By default SPCAF loads settings from the location '[INSTALLATIONFOLDER]/Rulesets', e.g. 'C:\Program Files (x86)\SPCAF\RuleSets'.

Samples
spcop.exe -i "D:\SolutionFiles" -r "HTML" -s "RS02_MinimumRecommendedRules"
spcop.exe -i "D:\SolutionFiles" -r "HTML" -s "RS02_MinimumRecommendedRules.spruleset"
spcop.exe -i "D:\SolutionFiles" -r "HTML" -s "C:\Program Files (x86)\SPCAF\RuleSets\RS02_MinimumRecommendedRules.spruleset"
Editing Settings

To edit existing settings or to create custom settings the tool 'SPCAF.SettingsEditor.exe' can be used. The tool can be found in the installation directory of SPCAF and is also available in the programs menu.

With the settings editor you can:

  • Edit existing or create new settings files
  • Enable or disable whole analyzers (e.g. disable FxCop analyzer)
  • Enable or disable a whole category (e.g. disable all 'Best Practices' rules)
  • Enable or disable a single rule, metric, dependency or inventory entries
  • Change the severity e.g. from Error to Warning
  • Add comments to a rule, category or analyzer which appears in the reports (e.g. to provide background information about changed severity)
  • Add configuration values
  • Enable/Disable reports types e.g. Code Quality Analysis Report
  • Configure which sections should show up in the specifice

See below a screenshot of the settings editor.

Exclude Files from Analysis

Sometimes WSP solutions contains third party files (like assemblies or JavaScript files) which should be excluded from the analysis. To allow this SPCAF uses the configuration parameter "IgnoredFiles" which contains a semikolon separated list of excluded file names.
SPCAF uses for instance the value "jquery*.js;knockout*.js;angular*.js" for "IgnoredFiles" in JSHint analyzer to exclude typical third party JavaScript files.
See below a screenshot for the configuration of ignored files in the settings editor.

NOTE: If you want to include these third party files for a certain rule you can set the configuration value "IgnoredFiles" for this rule in a settings file and the configuration value which is assigned on a higher level will be overriden.

Define how new rules are loaded

By default SPCAF loads all new analyzers and rules (e.g. if a new SPCAF release contains new rules). This is done to make new rules available to each analysis.
But sometimes in a project it is not wanted that new rules are loaded automatically. Only the defined set of rules of the settings file should be loaded. To achieve this there are two options:

  • Only load enabled analyzers: This option only loads the selected analyzers (e.g. SPCop, Inventory etc.), but if new rules appear in this analyzers they are loaded automatically
  • Only load enabled rules: This option defines that only the selected rules in the ruleset should be loaded. New rules are not loaded.

See below a screenshot how to configure the default loading of analyzers and rules.

NOTE: If you want to include these third party files for a certain rule you can set the configuration value "IgnoredFiles" for this rule in a settings file and the configuration value which is assigned on a higher level will be overriden.

Configure Rules

Some rules can be configured via configruation values. For instance the rules for integration of FxCop allows you to configure the FxCop settings or configure the path to FxCop installation directory. The configuration is stored as a key value pair within the settings file.

Default Settings
The following settings are available by default:

Setting Description
All Analyzers All available analyzers are applied during the analysis.
Filename: RS00_AllRules.spruleset
Minimum Settings These settings focus on the most critical problems in your code for which Code Analysis is the most accurate. Only analyzers from the categories Correctness, Security and Supportability are applied.
Filename: RS01_MinimumRules.spruleset
Minimum Recommended Settings These settings focus on the most critical problems in your code and violations against best practices. The settings extend the MinimumRules with rules from the categories Design, Best Practices and Deployment.
Filename: RS02_MinimumRecommendedRules.spruleset
Extended Recommended Settings These settings focus on a detailed check of your code. The settings extends the MinimumRecommendedSettings with checks from the categories Localization and Naming.
Filename: RS10_ExtendedRecommendedRules.spruleset
Migration Assessment Settings These settings only runs analyzers for the Migration Assessment and only creates the assessment report.
Filename: RS30_MigrationAssessment.spruleset
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.