Skip to content

120+ SQL Server static code analysis rules for SQL Database Projects

License

Notifications You must be signed in to change notification settings

ErikEJ/SqlServer.Rules

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Static Analysis Rule-sets for SQL Projects

build status latest version latest version

Overview

A library of SQL best practices implemented as more than 120 database code analysis rules checked at build.

The rules can be added as NuGet packages to modern SQL Database projects based on either MSBuild.Sdk.SqlProj or Microsoft.Build.Sql.

You can also download and manually use the rules with Visual Studio and "classic" SQL Database projects, as described in my blog post here.

For a complete list of the current rules we have implemented see here.

This fork also contains an additional set of rules TSQL Smells forked from TSQL-Smells

Usage

The latest version is available on NuGet

dotnet add package ErikEJ.DacFX.SqlServer.Rules
dotnet add package ErikEJ.DacFX.TSQLSmellSCA

You can read more about using and customizing the rules in the readme here

Solution Organization

.github - GitHub actions

docs - markdown files generated from rule inspection with the DocsGenerator unit test

Solution Items - files relating to build etc.

src

  • SqlServer.Rules - This holds the rules derived from SqlCodeAnalysisRule
  • TSQLSmellSCA - an additional set of rules TSQL Smells forked from TSQL-Smells

test

  • SqlServer.Rules.Tests - a few test to demonstrate unit testing of rules
  • TSQLSmellsSSDTTest - unit tests of some of the TSQL Smells rules
  • TestHelpers - shared test base classes

test/rulescli

  • SqlServer.Rules.Generator - a quick console app to report on all rules in a SQL Project.
  • SqlServer.Rules.Report - Library for evaluating a rule and serializing the result.

test/sqlprojects

  • AW - AdventureWorks schema SQL Project for rules validation
  • TestDatabase - a small SQL Database Project with some rule violations
  • TSQLSmellsTest - a SQL Database Project with some rule violations

About

120+ SQL Server static code analysis rules for SQL Database Projects

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Languages

  • C# 54.9%
  • TSQL 44.3%
  • XSLT 0.8%