In some cases it is necessary to exclude files from the analysis, e.g. to avoid analysis of 3rd party assemblies or jquery files. This can be achieved by using SPCAF rulesets.
SPCAF rulesets are XML files with extension .spruleset. They are mainly used to enable or disable analyzers (like rules or metrics) for the analysis. Please refer to Rulesets in this documentation for more details.
Besides the activation/deactivation of rules, the rulesets can be used to define a list of ignored files or folders. This list contains the names of the files/folders which should be ignored during the analysis. The list of ignored files/folders is a string of semicolon-separated filenames or folder paths. See sample below:
Sometimes files should not be excluded completely from the analysis. Instead, the file should be excluded only for a certain rule category or rule. SPCAF rulesets allow the exclusion of files on the following levels;
The list of ignored files is stored in a property "IgnoredFiles" in a ruleset. You can use the following methods to edit this property in a ruleset.
SPCAF comes with a separate tool "SPCAF.SettingsEditor.exe" which can be found in the installation directory of SPCAF or in your start menu (depending on your installation). This tool is used to load and edit SPCAF rulesets via a user interface. The following screenshot shows the SettingsEditor after the start.
To define a complete exclusion of files refer to the "Global Properties" section (see screenshot below). Here you can define the property "IgnoredFiles" and the list of files for exclusion. If the property is not present add the property by clicking the "Add" button.
To define the list of ignored files on an analyzer, category or rule select in the treeview in the center of the SettingsEditor, on which level you want to exclude files from the analysis, e.g. select category "Deployment" (see sample below). If you want to exclude file completely select nothing in the treeview.
After defining the level for exclusion refer to the section "Configuration Values" on the right side of the application (see screenshot below). Here you can define the property "IgnoredFiles" and the list of files for exclusion. If the property is not present add the property by clicking the "Add" button.
If you are firm with editing XML code you can open an SPCAF ruleset (.spruleset) in your preferred XML editor.
Important: Be carefully when editing SPCAF rulesets. If the XML format is not correct SPCAF cannot load the ruleset during the analysis.
Open the SPCAF ruleset in an XML editor. You will see a XML code similiar to the following sample:
<SPCAFSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
Name="Extended Recommended Settings"
Description="These settings focus on a detailed check of your code." >
<Analyzer Name="SPCAF.Dependencies" Disabled="false" />
<Analyzer Name="SPCAF.Inventory" Disabled="false">
<Property Key="IgnoredFiles" Value="DocumentFormat.OpenXml.dll;Camlex.NET.dll" />
<Analyzer Name="SPCAF.Rules" Disabled="false">
<Property Key="IgnoredFiles" Value="AjaxControlToolkit.dll" />
In the sample above you see:
Finally, save the ruleset and use the ruleset for your analysis. Refer to section "Rulesets" for more information how to use rulesets in your analysis.
SPCAF | Rules | Ruleset | Ignore | Files | Analysis | BQ_U