Rulesets

Rulesets in SPCAF are files with extension '.spruleset' which configure the analysis process and define, which rules are disabled during analysis.

Usage samples
Rulesets can be used in parameter 'SettingsFile' to disable rules during analysis.
By default SPCAF loads rulesets from the location '[INSTALLATIONFOLDER]/Ruleses', 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 Rulesets

To edit existing rulesets or to create custom rulesets the tool 'SPCAF.RulesetEditor.exe' can be used. The tool can be found in the installation directory of SPCAF.

With the ruleset editor you can:

  • Edit existing rulesets or create new rulesets
  • 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, categorie or analyzer which appears in the reports (e.g. to provide background information about changed severity)
  • Add configuration values

See below a screenshot of the rule set 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.

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 ruleset file and the configuration value which is assigned on a higher level will be overriden.

Configure Rules

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

Default Rule Sets
The following rulesets are available by default:

Ruleset Description
All Rules All available rules are used for the analysis.
Filename: RS00_AllRules.spruleset
Minimum Rules These rules focus on the most critical problems in your code for which Code Analysis is the most accurate. Only rules from the categories Correctness, Security and Supportability are applied.
Filename: RS01_MinimumRules.spruleset
Minimum Recommended Rules These rules focus on the most critical problems in your code and violations against best practices. The rule set extends the MinimumRules with rules from the categories Design, Best Practices and Deployment.
Filename: RS02_MinimumRecommendedRules.spruleset
Extended Recommended Rules These rules focus on a detailed check of your code. The rule set extends the MinimumRecommendedRules with rules from the categories Localization and Naming.
Filename: RS10_ExtendedRecommendedRules.spruleset
Compatibility Rules These rules focus on compatibility to different SharePoint versions and Sandboxed Compatibility of your code. The rule set extends the MinimumRecommendedRules.
Filename: RS20_CompatibilityRules.spruleset
Customization Policy Silver Rules These rules focus on conformance of your code to the Silver Service Hosting model (Utility Hosting/Shared Web Applications). The rule set extends the MinimumRecommendedRules.
Filename: RS50_CustomizationPolicySilverRules.spruleset
Customization Policy Gold Rules These rules focus on conformance of your code to the Gold Service Hosting model (Shared Hardware/Dedicated Web Applications). The rule set extends the MinimumRecommendedRules.
Filename: RS51_CustomizationPolicyGoldRules.spruleset
Customization Policy Platinum Rules These rules focus on conformance of your code to the Platinum Service Hosting model (Dedicated Hardware). The rule set extends the MinimumRecommendedRules.
Filename: RS52_CustomizationPolicyPlatinumRules.spruleset
comments powered by Disqus