Click or drag to resize
Performing Static Analysis
Analyze a selection of T-SQL code

Set default active rules

To configure which rules will be active by default, do the following:

1. Open SQL Enlight > Options dialog and go to the Analysis > Rules tab.

analysis-rules-1

2. Set the checked state of each rule which you want to be active by default.

3. Optionally set default values to rule parameters.

Analyze commands

There are two main analysis commands available:

  • The Analyze with All Rules command can be used to analyze with all default active rules.
  • The Analyze with Specific Rules... command can be used to select rules which to be applied.

    The command will show the following rule selector dialog:

    analysis-rules-selector

    Use the Show Details button to show rule details - see rule description and set rule parameters.

    analysis-rules-parameters-selector

The commands will analyze the selected SQL code or the entire active document if there is no current selection.

Both commands are available on the SQL Enlight menu and SQL Enlight toolbar.

Note Note

By default only Batch scoped analysis rules will be applied when analyzing T-SQL document using the Analyze with All Rules command.

Explicit rules

Explicit analysis rules are directly available in the Static Analysis sub menu.

These rules are managed in the Explicit Rules analysis group and due to their kind are available only to be used separately from the general rules.

analysis-rules-explicit-1

Analyze database stored procedures,function and triggers in SQL Server Management Studio

1. Right click object in SQL Server Management Studio's Object Explorer to open the context menu.

analyze-4

2. Use the Static Analysis menu to select SQL Enlight command, specific group or rule. The menu will be available If the selected object or one of its children can be analyzed.

3. If the Analyze with Specific Rules... command is used, specific rules can be selected prior to running the analysis.

4. The command will script the stored procedures, functions and triggers under the selected object in a new query window and will analyze the resulting script.

Note Note

By default only Batch scoped analysis rules will be applied when analyzing T-SQL document using the Analyze with All Rules command.

Analyze SQL files in Solution Explorer

1. Open Solution Explorer in SQL Server Management Studio or Visual Studio.

2. Right-click the target Solution Explorer item to open its context menu. It can be a solution, project, folder which contain SQL file(s) or a single SQL file.

3. To start the analysis use the SQL Enlight context menu item and select one of Analyze with All Rules or Analyze with Specific Rules... commands.

This way all SQL files under the selected Solution Explorer items will be analyzed and the generated rule violations will be added to the SQL Enlight Error List.

Instant Code Analysis

Instant Code Analysis feature provides real-time analysis and code issues feedback in the editors of SQL Server Management Studio and Visual Studio.

The analysis is fired a few of seconds after a script document is opened for a first time or an opened document has its content changed.

The document is analyzed in background using the rules in the current analysis template.

The code elements that trigger violations are highlighted in the editor and a complete list of file code issues is added and displayed in the SQL Enlight Error List tool window.

The Details pane of the Error List shows more information about the source and explains the nature of the issue.

The feature can be configured and turned on/off using SQL Enlight Settings, SQL Enlight toolbar and SQL Enlight main menu.

Analysis Result

If there are T-SQL script analysis rules violations, the SQL Enlight Error List Window will be displayed and the violations will be marked in the text editor.

analyze-3

See SQL Enlight Error List for more details.

See Also