SqlServer
SqlServer Code Rules
Category | Severity | Name | Description |
---|---|---|---|
|
|
|
@@IDENTITY should not be used |
|
|
|
A primary key should be specified during table creation |
|
|
|
All branches in a conditional structure should not have exactly the same implementation |
|
|
|
ANSI_NULLS, ANSI_PADDING and CONCAT_NULL_YIELDS_NULL should not be configured |
|
|
|
Boolean checks should not be inverted |
|
|
|
CASE expressions should end with ELSE clauses |
|
|
|
CASE expressions should not have too many WHEN clauses |
|
|
|
CASE input expressions should be invariant |
|
|
|
CATCH clauses should do more than rethrow |
|
|
|
COALESCE, IIF, and CASE input expressions should not contain subqueries |
|
|
|
Collapsible if statements should be merged |
|
|
|
Column names should be used in an ORDER BY clause |
|
|
|
Column references should not have more than two-parts |
|
|
|
Columns to be read with a SELECT statement should be clearly defined |
|
|
|
Conditionally executed code should be denoted by either indentation or BEGIN...END block |
|
|
|
Conditionals should start on new lines |
|
|
|
Control flow statements IF, WHILE and TRY should not be nested too deeply |
|
|
|
Control structures should use BEGIN...END blocks |
|
|
|
DELETE and UPDATE statements should contain WHERE clauses |
|
|
|
Deprecated features should not be used |
|
|
|
Deprecated system tables and views should not be used |
|
|
|
Duplicate values should not be passed as arguments |
|
|
|
Dynamically executing code is security-sensitive |
|
|
|
Empty Method |
|
|
|
Empty statements should be removed |
|
|
|
Expressions should not be too complex |
|
|
|
Files should not have too many lines of code |
|
|
|
Function and procedure names should comply with a naming convention |
|
|
|
Functions and procedures should not have too many parameters |
|
|
|
Functions and stored procedure should not have too many lines of code |
|
|
|
GOTO statements should not be used |
|
|
|
Identical expressions should not be used on both sides of a binary operator |
|
|
|
IF ... ELSEIF constructs should end with ELSE clauses |
|
|
|
INSERT statements should explicitly list the columns to be set |
|
|
|
Jump statements should not be followed by dead code |
|
|
|
Jump statements should not be redundant |
|
|
|
Large Scripts |
|
|
|
LIKE clauses should not be used without wildcards |
|
|
|
LIKE clauses should not start with wildcard characters |
|
|
|
Lines should not be too long |
|
|
|
Local variable and parameter names should comply with a naming convention |
|
|
|
Loops with at most one iteration should be refactored |
|
|
|
Multiline blocks should be enclosed in BEGIN...END blocks |
|
|
|
Multiple variables should not be declared on the same line |
|
|
|
NOCOUNT should be activated on PROCEDURE and TRIGGER definitions |
|
|
|
Non-standard comparison operators should not be used |
|
|
|
NULL should not be compared directly |
|
|
|
Nullable subqueries should not be used in NOT IN conditions |
|
|
|
Output parameters should be assigned |
|
|
|
Queries should not join too many tables |
|
|
|
Queries that use TOP should have an ORDER BY |
|
|
|
Redundant pairs of parentheses should be removed |
|
|
|
Related IF/ELSE IF statements and WHEN clauses in a CASE should not have the same condition |
|
|
|
Reserved keywords should not be used as identifiers or object names |
|
|
|
SELECT statements used as argument of EXISTS statements should be selective |
|
|
|
SHA-1 and Message-Digest hash algorithms should not be used in secure contexts |
|
|
|
Size should be specified for varchar variables and parameters |
|
|
|
Statements should be on separate lines |
|
|
|
String literals should not be duplicated |
|
|
|
Syntax Errors |
|
|
|
Tabulation characters should not be used |
|
|
|
The number of variables in a FETCH statement should match the number of columns in the cursor |
|
|
|
Track lack of SQL Server session configuration |
|
|
|
Track uses of FIXME tags |
|
|
|
Track uses of TODO tags |
|
|
|
Triggers should not PRINT, SELECT, or FETCH |
|
|
|
Two branches in a conditional structure should not have exactly the same implementation |
|
|
|
Unary prefix operators should not be repeated |
|
|
|
Uncommented scripts |
|
|
|
Unused local variables should be removed |
|
|
|
Unused procedure and function parameters should be removed |
|
|
|
Using hardcoded IP addresses is security-sensitive |
|
|
|
Variables should not be self-assigned |
|
|
|
WHEN clauses should not have too many lines of code |
|
|
|
WHERE clause conditions should not be contradictory |
|
|
|
WHERE clauses should not contain redundant conditions |