-
Notifications
You must be signed in to change notification settings - Fork 119
API
Pavel Bansky edited this page Jan 8, 2018
·
14 revisions
DevSkim functionality can be used or extended via .NET library. The very same library is used in Command Line Interface as well as in Visual Studio Extension.
DevSkim library is available on NuGet Microsoft.DevSkim
PM> Install-Package Microsoft.DevSkim
dotnet add package Microsoft.DevSkim
<ItemGroup>
<PackageReference Include="Microsoft.DevSkim" Version="0.3.6" />
</ItemGroup>
DevSkim library consists of two main classes, Ruleset
collection which loads and contains rules and RuleProcessor
which applies given rule set to a text content and returns results.
The Ruleset
can be created from a directory, file or free form text.
// verbose way
RuleSet rules = new RuleSet();
rules.AddDirectory("/home/user/rules);
// faster way
RuleSet fastRules = RuleSet.FromDirectory("/home/other/rules);
// Load the rules
RuleSet rules = RuleSet.FromDirectory("/home/user/rules);
// Create RuleProcessor and pass the ruleset
RuleProcessor processor = new RuleProcessor(rules);
Issue[] issues = processor.Analyze("strcpy(dest,src);", "cpp");