Table of Contents

Class DevSkimRuleProcessor

Namespace
Microsoft.DevSkim
Assembly
Microsoft.DevSkim.dll
public class DevSkimRuleProcessor
Inheritance
DevSkimRuleProcessor
Inherited Members

Constructors

DevSkimRuleProcessor(DevSkimRuleSet, DevSkimRuleProcessorOptions)

public DevSkimRuleProcessor(DevSkimRuleSet ruleSet, DevSkimRuleProcessorOptions processorOptions)

Parameters

ruleSet DevSkimRuleSet
processorOptions DevSkimRuleProcessorOptions

Methods

Analyze(string, string)

public IEnumerable<Issue> Analyze(string text, string fileName)

Parameters

text string
fileName string

Returns

IEnumerable<Issue>

Fix(string, CodeFix)

Applies given fix on the provided source code line. Recommended to call IsFixable(string, CodeFix) first to ensure the fix is intended for the target.

public static string? Fix(string text, CodeFix fixRecord)

Parameters

text string

Source code line

fixRecord CodeFix

Fix record to be applied

Returns

string

Fixed source code line

GenerateSuppressionByFileName(string, string, bool, int, string?, Languages?)

Generate appropriate suppression with comment style based on the filename

public static string GenerateSuppressionByFileName(string fileName, string rulesId, bool preferMultiLine = false, int duration = 0, string? reviewerName = null, Languages? languages = null)

Parameters

fileName string
rulesId string
preferMultiLine bool
duration int
reviewerName string
languages Languages

Returns

string

GenerateSuppressionByLanguage(string, string, bool, int, string?, Languages?)

Generate suppression text for a given rule ID and language. If the comment style for the language is not specified, returns null.

public static string GenerateSuppressionByLanguage(string sourceLanguage, string rulesId, bool preferMultiLine = false, int duration = 0, string? reviewerName = null, Languages? languages = null)

Parameters

sourceLanguage string

The target language (to choose the right comment style)

rulesId string

The ID for the rule to suppress

preferMultiLine bool

If multiline comment style should be preferred

duration int

Duration in days for suppression. Default 0 (unlimited)

reviewerName string

Optional name for the manual reviewer applying suppressions

languages Languages

Optional language specifications to use

Returns

string

A comment suppression or null if one could not be generated

IsFixable(string, CodeFix)

Checks if the target source can be fixed with the provided fix

public static bool IsFixable(string text, CodeFix fixRecord)

Parameters

text string

Source code line

fixRecord CodeFix

Fix record to be applied

Returns

bool

Fixed source code line