diff --git a/Directory.Build.props b/Directory.Build.props
index 4c3a0ac..7a7de7e 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -6,6 +6,6 @@
-
+
diff --git a/SqlServer.Dac/Visitors/ColumnReferenceVisitor.cs b/SqlServer.Dac/Visitors/ColumnReferenceExpressionVisitor.cs
similarity index 100%
rename from SqlServer.Dac/Visitors/ColumnReferenceVisitor.cs
rename to SqlServer.Dac/Visitors/ColumnReferenceExpressionVisitor.cs
diff --git a/SqlServer.Dac/Visitors/CreateLoginVisitor.cs b/SqlServer.Dac/Visitors/CreateLoginVisitor.cs
index 65cfcb8..24a590f 100644
--- a/SqlServer.Dac/Visitors/CreateLoginVisitor.cs
+++ b/SqlServer.Dac/Visitors/CreateLoginVisitor.cs
@@ -1,12 +1,8 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace SqlServer.Dac.Visitors
{
- ///
- ///
- ///
- ///
public class CreateLoginVisitor : BaseVisitor, IVisitor
{
public IList Statements { get; } = new List();
diff --git a/SqlServer.Dac/Visitors/CreateRoleVisitor.cs b/SqlServer.Dac/Visitors/CreateRoleVisitor.cs
index 9f20fb5..6351423 100644
--- a/SqlServer.Dac/Visitors/CreateRoleVisitor.cs
+++ b/SqlServer.Dac/Visitors/CreateRoleVisitor.cs
@@ -1,12 +1,8 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace SqlServer.Dac.Visitors
{
- ///
- ///
- ///
- ///
public class CreateRoleVisitor : BaseVisitor, IVisitor
{
public IList Statements { get; } = new List();
diff --git a/SqlServer.Dac/Visitors/CreateUserVisitor.cs b/SqlServer.Dac/Visitors/CreateUserVisitor.cs
index 215bbb1..3477aef 100644
--- a/SqlServer.Dac/Visitors/CreateUserVisitor.cs
+++ b/SqlServer.Dac/Visitors/CreateUserVisitor.cs
@@ -1,12 +1,8 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace SqlServer.Dac.Visitors
{
- ///
- ///
- ///
- ///
public class CreateUserVisitor : BaseVisitor, IVisitor
{
public IList Statements { get; } = new List();
diff --git a/SqlServer.Dac/Visitors/FunctionCallVisitor.cs b/SqlServer.Dac/Visitors/FunctionCallVisitor.cs
index 79ae0ee..08f2bcb 100644
--- a/SqlServer.Dac/Visitors/FunctionCallVisitor.cs
+++ b/SqlServer.Dac/Visitors/FunctionCallVisitor.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.TransactSql.ScriptDom;
@@ -6,15 +6,15 @@ namespace SqlServer.Dac.Visitors
{
public class FunctionCallVisitor : BaseVisitor, IVisitor
{
- private readonly IList _functionNames;
+ private readonly IList functionNames;
public FunctionCallVisitor()
{
- _functionNames = new List();
+ functionNames = new List();
}
public FunctionCallVisitor(params string[] functionNames)
{
- _functionNames = functionNames.ToList();
+ this.functionNames = functionNames.ToList();
}
public IList Statements { get; } = new List();
@@ -25,11 +25,11 @@ public int Count
public override void ExplicitVisit(FunctionCall node)
{
- if (!_functionNames.Any())
+ if (!functionNames.Any())
{
Statements.Add(node);
}
- else if (_functionNames.Any(f => Comparer.Equals(f, node.FunctionName.Value)))
+ else if (functionNames.Any(f => Comparer.Equals(f, node.FunctionName.Value)))
{
Statements.Add(node);
}
diff --git a/SqlServer.Dac/Visitors/TypesVisitor.cs b/SqlServer.Dac/Visitors/TypesVisitor.cs
index b891ce4..c6b7faa 100644
--- a/SqlServer.Dac/Visitors/TypesVisitor.cs
+++ b/SqlServer.Dac/Visitors/TypesVisitor.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using Microsoft.SqlServer.TransactSql.ScriptDom;
@@ -6,7 +6,7 @@ namespace SqlServer.Dac.Visitors
{
public class TypesVisitor : BaseVisitor, IVisitor
{
- private readonly List _types = new List();
+ private readonly List types = new List();
public IList Statements { get; } = new List();
public int Count
{
@@ -20,12 +20,12 @@ public TypesVisitor(params Type[] typesToLookFor)
throw new ArgumentNullException(nameof(typesToLookFor));
}
- _types = new List(typesToLookFor);
+ types = new List(typesToLookFor);
}
public override void Visit(TSqlFragment fragment)
{
- if (_types.Contains(fragment.GetType()))
+ if (types.Contains(fragment.GetType()))
{
Statements.Add(fragment);
}
diff --git a/SqlServer.Rules.Report/IssueTypeComparer.cs b/SqlServer.Rules.Report/IssueTypeComparer.cs
index a07a4b2..29819e9 100644
--- a/SqlServer.Rules.Report/IssueTypeComparer.cs
+++ b/SqlServer.Rules.Report/IssueTypeComparer.cs
@@ -1,10 +1,8 @@
-using System;
+using System;
using System.Collections.Generic;
-using System.Xml.Serialization;
namespace SqlServer.Rules.Report;
-
public class IssueTypeComparer : IEqualityComparer
{
public bool Equals(IssueType x, IssueType y)
diff --git a/SqlServer.Rules.Test/Docs/DocsExtensions.cs b/SqlServer.Rules.Test/Docs/DocsExtensions.cs
new file mode 100644
index 0000000..aea85e6
--- /dev/null
+++ b/SqlServer.Rules.Test/Docs/DocsExtensions.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Xml;
+using LoxSmoke.DocXml;
+using Microsoft.SqlServer.Dac.CodeAnalysis;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using SqlServer.Rules.Design;
+using TSQLSmellSCA;
+
+namespace SqlServer.Rules.Tests.Docs;
+
+public static class DocsExtensions
+{
+ public static string ToSentence(this string input)
+ {
+ var parts = Regex.Split(input, @"([A-Z]?[a-z]+)").Where(str => !string.IsNullOrEmpty(str));
+ return string.Join(' ', parts);
+ }
+
+ public static string ToId(this string input)
+ {
+ return new string(input.Split('.').Last());
+ }
+}
\ No newline at end of file
diff --git a/SqlServer.Rules.Test/Docs/DocsGenerator.cs b/SqlServer.Rules.Test/Docs/DocsGenerator.cs
index 041beef..2ccdb49 100644
--- a/SqlServer.Rules.Test/Docs/DocsGenerator.cs
+++ b/SqlServer.Rules.Test/Docs/DocsGenerator.cs
@@ -5,7 +5,6 @@
using System.Linq;
using System.Reflection;
using System.Text;
-using System.Text.RegularExpressions;
using System.Xml;
using LoxSmoke.DocXml;
using Microsoft.SqlServer.Dac.CodeAnalysis;
@@ -341,17 +340,3 @@ private static Dictionary> CollectRuleScripts(string rulesS
return ruleScripts;
}
}
-
-public static class DocsExtensions
-{
- public static string ToSentence(this string input)
- {
- var parts = Regex.Split(input, @"([A-Z]?[a-z]+)").Where(str => !string.IsNullOrEmpty(str));
- return string.Join(' ', parts);
- }
-
- public static string ToId(this string input)
- {
- return new string(input.Split('.').Last());
- }
-}
\ No newline at end of file
diff --git a/SqlServer.Rules.Test/Utils/ArgumentValidation.cs b/SqlServer.Rules.Test/Utils/ArgumentValidation.cs
index 242467b..5a07b64 100644
--- a/SqlServer.Rules.Test/Utils/ArgumentValidation.cs
+++ b/SqlServer.Rules.Test/Utils/ArgumentValidation.cs
@@ -1,38 +1,4 @@
-//------------------------------------------------------------------------------
-//
-//
-// The MIT License (MIT)
-//
-// Copyright (c) 2015 Microsoft
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-//
-//------------------------------------------------------------------------------
-
using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Text.RegularExpressions;
-using Microsoft.Data.SqlClient;
namespace SqlServer.Rules.Tests.Utils;
diff --git a/SqlServer.Rules.Test/Utils/CommonConstants.cs b/SqlServer.Rules.Test/Utils/CommonConstants.cs
index c6bd88a..f27013c 100644
--- a/SqlServer.Rules.Test/Utils/CommonConstants.cs
+++ b/SqlServer.Rules.Test/Utils/CommonConstants.cs
@@ -1,30 +1,3 @@
-//------------------------------------------------------------------------------
-//
-//
-// The MIT License (MIT)
-//
-// Copyright (c) 2015 Microsoft
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-//
-//------------------------------------------------------------------------------
-
namespace SqlServer.Rules.Tests.Utils;
internal sealed class CommonConstants
diff --git a/SqlServer.Rules.Test/Utils/DisposableList.cs b/SqlServer.Rules.Test/Utils/DisposableList.cs
index 478b9f0..3c056d7 100644
--- a/SqlServer.Rules.Test/Utils/DisposableList.cs
+++ b/SqlServer.Rules.Test/Utils/DisposableList.cs
@@ -29,10 +29,8 @@ private void Dispose(bool isDisposing)
}
}
- ///
- /// Add an item to the list.
- ///
- public T Add(T item) where T : IDisposable
+ public T Add(T item)
+ where T : IDisposable
{
base.Add(item);
diff --git a/SqlServer.Rules.Test/Utils/InstanceInfo.cs b/SqlServer.Rules.Test/Utils/InstanceInfo.cs
index ba39fd3..9c8121d 100644
--- a/SqlServer.Rules.Test/Utils/InstanceInfo.cs
+++ b/SqlServer.Rules.Test/Utils/InstanceInfo.cs
@@ -1,30 +1,3 @@
-//------------------------------------------------------------------------------
-//
-//
-// The MIT License (MIT)
-//
-// Copyright (c) 2015 Microsoft
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-//
-//------------------------------------------------------------------------------
-
using System;
using System.Globalization;
using Microsoft.Data.SqlClient;
diff --git a/SqlServer.Rules.Test/Utils/RuleTest.cs b/SqlServer.Rules.Test/Utils/RuleTest.cs
index 0fe13af..dd79c51 100644
--- a/SqlServer.Rules.Test/Utils/RuleTest.cs
+++ b/SqlServer.Rules.Test/Utils/RuleTest.cs
@@ -113,7 +113,6 @@ private TSqlModel CreateScriptedModel()
// LoadAsScriptBackedModel = true,
// ModelStorageType = Microsoft.SqlServer.Dac.DacSchemaModelStorageType.Memory
// });
-
return model;
}
@@ -251,7 +250,8 @@ private CodeAnalysisService CreateCodeAnalysisService(string ruleIdToRun)
Assert.IsTrue(
service.GetRules().Any(rule => rule.RuleId.Equals(ruleIdToRun, StringComparison.OrdinalIgnoreCase)),
- "Expected rule '{0}' not found by the service", ruleIdToRun);
+ "Expected rule '{0}' not found by the service",
+ ruleIdToRun);
return service;
}
diff --git a/SqlServer.Rules.Test/Utils/SqlTestDB.cs b/SqlServer.Rules.Test/Utils/SqlTestDB.cs
index d9fab2e..a3a1a88 100644
--- a/SqlServer.Rules.Test/Utils/SqlTestDB.cs
+++ b/SqlServer.Rules.Test/Utils/SqlTestDB.cs
@@ -1,30 +1,3 @@
-//------------------------------------------------------------------------------
-//
-//
-// The MIT License (MIT)
-//
-// Copyright (c) 2015 Microsoft
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-//
-//------------------------------------------------------------------------------
-
using System;
using System.Collections.Generic;
using System.Data.Common;
@@ -45,15 +18,16 @@ public sealed class SqlTestDB : IDisposable
{
public enum ReallyCleanUpDatabase
{
- NotIfItCameFromABackupFile, YesReally,
+ NotIfItCameFromABackupFile,
+ YesReally,
}
private readonly InstanceInfo instance;
private readonly string dbName;
// Variables for tracking restored DB information
- private bool cleanupDatabase;
private readonly List cleanupScripts;
+ private bool cleanupDatabase;
public event EventHandler Disposing;
public static SqlTestDB CreateFromDacpac(InstanceInfo instance, string dacpacPath, DacDeployOptions deployOptions = null, bool dropDatabaseOnCleanup = false)
@@ -178,13 +152,6 @@ private SqlTestDB()
cleanupScripts = [];
}
- ///
- /// Represents a test Database that was created for tests. The DB has already been attached/created,
- /// and will not be removed unless dropDatabaseOnCleanup is true.
- ///
- ///
- /// If true the db instance will be dropped when the Cleanup method is called
- ///
public SqlTestDB(InstanceInfo instance, string dbName, bool dropDatabaseOnCleanup = false)
{
if (string.IsNullOrEmpty(dbName))
@@ -310,8 +277,13 @@ public void SafeExecute(string script, int? timeout = null)
}
catch (Exception ex)
{
- var message = string.Format(CultureInfo.CurrentCulture, "Executing script on server '{0}' database '{1}' failed. Error: {2}.\r\n\r\nScript: {3}.)",
- Instance.DataSource, DatabaseName, ex.Message, script);
+ var message = string.Format(
+ CultureInfo.CurrentCulture,
+ "Executing script on server '{0}' database '{1}' failed. Error: {2}.\r\n\r\nScript: {3}.)",
+ Instance.DataSource,
+ DatabaseName,
+ ex.Message,
+ script);
Debug.WriteLine(message);
}
}
@@ -409,7 +381,8 @@ private static void Log(string format, params object[] args)
{
Trace.TraceInformation(
"*** {0} TEST {1}",
- DateTime.Now.ToString("HH:mm:ss.fff", CultureInfo.InvariantCulture), string.Format(CultureInfo.InvariantCulture, format, args));
+ DateTime.Now.ToString("HH:mm:ss.fff", CultureInfo.InvariantCulture),
+ string.Format(CultureInfo.InvariantCulture, format, args));
}
internal void AddCleanupScript(string script)
diff --git a/SqlServer.Rules.Test/Utils/TestUtils.cs b/SqlServer.Rules.Test/Utils/TestUtils.cs
index 7c085f0..2bdab15 100644
--- a/SqlServer.Rules.Test/Utils/TestUtils.cs
+++ b/SqlServer.Rules.Test/Utils/TestUtils.cs
@@ -1,30 +1,3 @@
-//------------------------------------------------------------------------------
-//
-//
-// The MIT License (MIT)
-//
-// Copyright (c) 2015 Microsoft
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-//
-//------------------------------------------------------------------------------
-
using System;
using System.Collections.Generic;
using System.Data;
@@ -46,11 +19,11 @@ internal static class TestUtils
public const string MasterDatabaseName = "master";
- const string SetLockTimeoutDefault = "SET LOCK_TIMEOUT {0}"; // value configurable
+ private const string SetLockTimeoutDefault = "SET LOCK_TIMEOUT {0}"; // value configurable
- const string QueryDatabaseIfExist = @"SELECT COUNT(*) FROM [sys].[databases] WHERE [name] = '{0}'";
+ private const string QueryDatabaseIfExist = @"SELECT COUNT(*) FROM [sys].[databases] WHERE [name] = '{0}'";
- const string DropDatabaseIfExist = @"
+ private const string DropDatabaseIfExist = @"
IF EXISTS (SELECT 1 FROM [sys].[databases] WHERE [name] = '{0}')
BEGIN
ALTER DATABASE [{0}]
diff --git a/SqlServer.Rules/BaseSqlCodeAnalysisRule.cs b/SqlServer.Rules/BaseSqlCodeAnalysisRule.cs
index 1178504..843d8b9 100644
--- a/SqlServer.Rules/BaseSqlCodeAnalysisRule.cs
+++ b/SqlServer.Rules/BaseSqlCodeAnalysisRule.cs
@@ -58,7 +58,7 @@ public abstract class BaseSqlCodeAnalysisRule : SqlCodeAnalysisRule
#pragma warning restore CA1002 // Do not expose generic lists
// really not proud of this... could not figure out another way. has to be maintained with each new SQL Server version.
- private static readonly Dictionary _functions = new Dictionary(StringComparer.InvariantCultureIgnoreCase)
+ private static readonly Dictionary Functions = new Dictionary(StringComparer.InvariantCultureIgnoreCase)
{
/*Date and Time Data Types and Functions (Transact-SQL)*/
{ "CURRENT_DATE", "date" },
@@ -192,11 +192,6 @@ public abstract class BaseSqlCodeAnalysisRule : SqlCodeAnalysisRule
{ "USER_NAME", "nvarchar" },
};
- ///
- /// Gets the statement list.
- ///
- /// The fragment.
- ///
public static StatementList GetStatementList(TSqlFragment fragment)
{
var fragmentTypeName = fragment.GetType().Name;
@@ -254,31 +249,16 @@ protected BaseSqlCodeAnalysisRule(params ModelTypeClass[] supportedElementTypes)
SupportedElementTypes = supportedElementTypes;
}
- ///
- /// Gets the data type of the value.
- ///
- /// The value.
- ///
protected static string GetDataType(IntegerLiteral value)
{
return value.LiteralType.ToString();
}
- ///
- /// Gets the data type of the value.
- ///
- /// The value.
- ///
protected static string GetDataType(NumericLiteral value)
{
return value.LiteralType.ToString();
}
- ///
- /// Gets the data type of the value.
- ///
- /// The value.
- ///
protected static string GetDataType(StringLiteral value)
{
if (value.IsNational)
@@ -289,11 +269,6 @@ protected static string GetDataType(StringLiteral value)
return "varchar";
}
- ///
- /// Gets the data type of the value.
- ///
- /// The value.
- ///
protected static string GetDataType(ScalarExpression value)
{
if (value is IntegerLiteral exprInt)
@@ -308,7 +283,7 @@ protected static string GetDataType(ScalarExpression value)
if (value is FunctionCall exprFunc)
{
- if (_functions.TryGetValue(exprFunc.FunctionName.Value, out var type))
+ if (Functions.TryGetValue(exprFunc.FunctionName.Value, out var type))
{
return type;
}
@@ -325,12 +300,6 @@ protected static string GetDataType(ScalarExpression value)
return null;
}
- ///
- /// Gets the data type of the value.
- ///
- /// The value.
- /// The variables.
- ///
protected static string GetDataType(ScalarExpression value, IList variables)
{
if (!(value is VariableReference varRef))
@@ -347,20 +316,12 @@ protected static string GetDataType(ScalarExpression value, IList
return string.Empty;
}
- ///
- /// Gets the data type of the value.
- ///
- /// The SQL object.
- /// The query.
- /// The expression.
- /// The variables.
- /// The model.
- ///
protected static string GetDataType(
TSqlObject sqlObj,
QuerySpecification query,
ScalarExpression expression,
- IList variables, TSqlModel model = null)
+ IList variables,
+ TSqlModel model = null)
{
if (expression == null)
{
@@ -391,7 +352,8 @@ protected static string GetDataType(
{
var val = long.Parse(exprInt.Value, CultureInfo.InvariantCulture);
- if (val >= 0 && val <= 255) // to bit or not to bit? NFC.
+ // to bit or not to bit? NFC.
+ if (val >= 0 && val <= 255)
{
return "tinyint";
}
@@ -438,7 +400,7 @@ protected static string GetDataType(
{
// TIM C: sigh, this does not work for all functions. the api does not allow for me to look up built in functions. nor does it allow me to get the
// data types of parameters, so I am not able to type ALL functions like DATEADD, the parameter could be a column, string literal, variable, function etc...
- if (_functions.TryGetValue(exprFunc.FunctionName.Value, out var type))
+ if (Functions.TryGetValue(exprFunc.FunctionName.Value, out var type))
{
return type;
}
@@ -472,30 +434,6 @@ protected static string GetDataType(
return null;
}
- // protected string GetColumnDataType(ColumnReferenceExpression value, Dictionary> columnDataTypes)
- // {
- // var columnName = value.MultiPartIdentifier.Identifiers.GetName().ToLower();
- // var types = columnDataTypes.Where(t => t.Key.Name.ToLower().Contains(columnName));
- // //so.... technically this could resolve to multiple columns, but I have no clue which one to pick as the column does not have any reference to the parent query.
- // var typ = types.FirstOrDefault();
-
- // if (typ.Key != null)
- // {
- // //return typ.Value..DataType.;
- // }
-
- // return null;
- // }
-
- ///
- /// Gets the data type of the column.
- ///
- /// The SQL object.
- /// The query.
- /// The column.
- /// The model.
- /// The variables.
- ///
protected static string GetColumnDataType(TSqlObject sqlObj, QuerySpecification query, ColumnReferenceExpression column, TSqlModel model, IList variables)
{
TSqlObject referencedColumn = null;
@@ -609,13 +547,6 @@ protected static string GetColumnDataType(TSqlObject sqlObj, QuerySpecification
return null;
}
- ///
- /// Gets the referenced column.
- ///
- /// The table.
- /// The columns.
- /// Name of the column.
- ///
private static TSqlObject GetReferencedColumn(TableReference table, List columns, string columnName)
{
TSqlObject referencedColumn = null;
@@ -629,8 +560,8 @@ private static TSqlObject GetReferencedColumn(TableReference table, List compareNames = (string t1, string t2, string c) =>
(t1.Contains($"{t2}.[{c}]", StringComparison.OrdinalIgnoreCase)
- || t1.Contains($"[{c}]", StringComparison.OrdinalIgnoreCase)
- && !t1.Contains('#', StringComparison.OrdinalIgnoreCase));
+ || (t1.Contains($"[{c}]", StringComparison.OrdinalIgnoreCase)
+ && !t1.Contains('#', StringComparison.OrdinalIgnoreCase)));
var tableName = reference.GetName();
referencedColumn = columns.FirstOrDefault(c => compareNames(c.Name.GetName(), tableName, columnName));
}
@@ -648,13 +579,6 @@ private static TSqlObject GetReferencedColumn(TableReference table, List
- /// Gets the table from column.
- ///
- /// The SQL object.
- /// The query.
- /// The column.
- ///
protected static TSqlObject GetTableFromColumn(TSqlObject sqlObj, QuerySpecification query, ColumnReferenceExpression column)
{
var tables = new List();
diff --git a/SqlServer.Rules/Design/AvoidCHARINDEXRule.cs b/SqlServer.Rules/Design/AvoidCHARINDEXRule.cs
index b349bce..e4b3961 100644
--- a/SqlServer.Rules/Design/AvoidCHARINDEXRule.cs
+++ b/SqlServer.Rules/Design/AvoidCHARINDEXRule.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.Dac.CodeAnalysis;
using SqlServer.Dac;
@@ -8,7 +8,7 @@
namespace SqlServer.Rules.Design
{
///
- ///
+ /// Avoid using CHARINDEX function in WHERE clauses.
///
/// Avoid using CHARINDEX
/// true
diff --git a/SqlServer.Rules/Design/AvoidDeletesWithoutWhereRule.cs b/SqlServer.Rules/Design/AvoidDeletesWithoutWhereRule.cs
index 4528bf2..1a365c6 100644
--- a/SqlServer.Rules/Design/AvoidDeletesWithoutWhereRule.cs
+++ b/SqlServer.Rules/Design/AvoidDeletesWithoutWhereRule.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.Dac.CodeAnalysis;
using Microsoft.SqlServer.TransactSql.ScriptDom;
@@ -8,13 +8,6 @@
namespace SqlServer.Rules.Design
{
- ///
- ///
- ///
- ///
- /// true
- ///
- ///
[ExportCodeAnalysisRule(
RuleId,
RuleDisplayName,
diff --git a/SqlServer.Rules/Design/AvoidStaticPredicateCompareRule.cs b/SqlServer.Rules/Design/AvoidStaticPredicateCompareRule.cs
index 87ce53a..9c04b12 100644
--- a/SqlServer.Rules/Design/AvoidStaticPredicateCompareRule.cs
+++ b/SqlServer.Rules/Design/AvoidStaticPredicateCompareRule.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.Dac.CodeAnalysis;
using Microsoft.SqlServer.TransactSql.ScriptDom;
@@ -122,7 +122,7 @@ private static bool TestCompare(BooleanComparisonExpression compare)
var type1 = expr1.GetType();
var type2 = expr2.GetType();
- return
+ return
(
(type1 == typeof(IntegerLiteral) || type1 == typeof(StringLiteral))
&& (type2 == typeof(IntegerLiteral) || type2 == typeof(StringLiteral))
diff --git a/SqlServer.Rules/Design/AvoidViewJoinsRule.cs b/SqlServer.Rules/Design/AvoidViewJoinsRule.cs
index a93c97b..67a94b9 100644
--- a/SqlServer.Rules/Design/AvoidViewJoinsRule.cs
+++ b/SqlServer.Rules/Design/AvoidViewJoinsRule.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.Dac.CodeAnalysis;
using Microsoft.SqlServer.Dac.Model;
@@ -23,7 +23,6 @@ namespace SqlServer.Rules.Design
Category = Constants.Design,
RuleScope = SqlRuleScope.Element)]
public sealed class AvoidViewJoinsRule : BaseSqlCodeAnalysisRule
-
{
///
/// The rule identifier
diff --git a/SqlServer.Rules/Design/ConsiderCachingGetDateToVariable.cs b/SqlServer.Rules/Design/ConsiderCachingGetDateToVariable.cs
index 6233576..5fe2fa3 100644
--- a/SqlServer.Rules/Design/ConsiderCachingGetDateToVariable.cs
+++ b/SqlServer.Rules/Design/ConsiderCachingGetDateToVariable.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.Dac.CodeAnalysis;
using Microsoft.SqlServer.TransactSql.ScriptDom;
@@ -8,13 +8,6 @@
namespace SqlServer.Rules.Design
{
- ///
- ///
- ///
- ///
- /// true
- ///
- ///
[ExportCodeAnalysisRule(
RuleId,
RuleDisplayName,
@@ -38,7 +31,7 @@ public class ConsiderCachingGetDateToVariable : BaseSqlCodeAnalysisRule
///
public const string Message = RuleDisplayName;
- private readonly List FunctionNames = new List { "GETDATE", "GETUTCDATE", "SYSDATETIME", "SYSUTCDATETIME", "SYSDATETIMEOFFSET" };
+ private readonly List functionNames = new List { "GETDATE", "GETUTCDATE", "SYSDATETIME", "SYSUTCDATETIME", "SYSDATETIMEOFFSET" };
///
/// Initializes a new instance of the class.
@@ -102,7 +95,7 @@ private bool DoesStatementHaveDateFunction(StatementWithCtesAndXmlNamespaces sta
statement.Accept(allFunctions);
- if (allFunctions.Statements.Any(p => FunctionNames.Contains(p.FunctionName.Value.ToUpperInvariant())))
+ if (allFunctions.Statements.Any(p => functionNames.Contains(p.FunctionName.Value.ToUpperInvariant())))
{
hasDateFunction = true;
}
@@ -120,7 +113,7 @@ private bool CheckFunctionCallsForDateFunction(IList functionCalls
foreach (var functionCall in functionCalls)
{
- if (FunctionNames.Contains(functionCall.FunctionName.Value.ToUpperInvariant()))
+ if (functionNames.Contains(functionCall.FunctionName.Value.ToUpperInvariant()))
{
hasDateFunctions = true;
}
diff --git a/SqlServer.Rules/Design/ConsiderColumnPrefixRule.cs b/SqlServer.Rules/Design/ConsiderColumnPrefixRule.cs
index 9aaf0eb..91e1565 100644
--- a/SqlServer.Rules/Design/ConsiderColumnPrefixRule.cs
+++ b/SqlServer.Rules/Design/ConsiderColumnPrefixRule.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.Dac.CodeAnalysis;
@@ -9,13 +9,6 @@
namespace SqlServer.Rules.Design
{
- ///
- ///
- ///
- ///
- /// true
- ///
- ///
[ExportCodeAnalysisRule(
RuleId,
RuleDisplayName,
@@ -23,7 +16,6 @@ namespace SqlServer.Rules.Design
Category = Constants.Design,
RuleScope = SqlRuleScope.Element)]
public sealed class ConsiderColumnPrefixRule : BaseSqlCodeAnalysisRule
-
{
///
/// The rule identifier
diff --git a/SqlServer.Rules/Design/ConsiderEXISTSInsteadOfInRule.cs b/SqlServer.Rules/Design/ConsiderEXISTSInsteadOfInRule.cs
index 29de5f2..28e3e2a 100644
--- a/SqlServer.Rules/Design/ConsiderEXISTSInsteadOfInRule.cs
+++ b/SqlServer.Rules/Design/ConsiderEXISTSInsteadOfInRule.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.Dac.CodeAnalysis;
using SqlServer.Dac;
@@ -7,13 +7,6 @@
namespace SqlServer.Rules.Design
{
- ///
- ///
- ///
- ///
- /// true
- ///
- ///
[ExportCodeAnalysisRule(
RuleId,
RuleDisplayName,
diff --git a/SqlServer.Rules/Design/DoNotMixDMLWithDDLRule.cs b/SqlServer.Rules/Design/DoNotMixDMLWithDDLRule.cs
index afd19bc..b934c61 100644
--- a/SqlServer.Rules/Design/DoNotMixDMLWithDDLRule.cs
+++ b/SqlServer.Rules/Design/DoNotMixDMLWithDDLRule.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.Dac.CodeAnalysis;
using Microsoft.SqlServer.Dac.Model;
@@ -9,13 +9,6 @@
namespace SqlServer.Rules.Design
{
- ///
- ///
- ///
- ///
- /// false
- ///
- ///
[ExportCodeAnalysisRule(
RuleId,
RuleDisplayName,
diff --git a/SqlServer.Rules/Design/DoNotUseDeprecatedTypesRule.cs b/SqlServer.Rules/Design/DoNotUseDeprecatedTypesRule.cs
index f5491b4..1261269 100644
--- a/SqlServer.Rules/Design/DoNotUseDeprecatedTypesRule.cs
+++ b/SqlServer.Rules/Design/DoNotUseDeprecatedTypesRule.cs
@@ -9,13 +9,6 @@
namespace SqlServer.Rules.Design
{
- ///
- ///
- ///
- ///
- /// false
- ///
- ///
[ExportCodeAnalysisRule(
RuleId,
RuleDisplayName,
diff --git a/SqlServer.Rules/Design/DoNotUseRealOrFloatRule.cs b/SqlServer.Rules/Design/DoNotUseRealOrFloatRule.cs
index be9de00..9c32b6f 100644
--- a/SqlServer.Rules/Design/DoNotUseRealOrFloatRule.cs
+++ b/SqlServer.Rules/Design/DoNotUseRealOrFloatRule.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.Dac.CodeAnalysis;
using Microsoft.SqlServer.Dac.Model;
@@ -86,7 +86,7 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
}
}
}
- else // tables, views
+ else
{
var columns = sqlObj.GetReferenced().Where(x => x.ObjectType == ModelSchema.Column);
diff --git a/SqlServer.Rules/Design/EqualityCompareWithNULLRule.cs b/SqlServer.Rules/Design/EqualityCompareWithNULLRule.cs
index 87e7dfa..161539c 100644
--- a/SqlServer.Rules/Design/EqualityCompareWithNULLRule.cs
+++ b/SqlServer.Rules/Design/EqualityCompareWithNULLRule.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.SqlServer.Dac.CodeAnalysis;
using Microsoft.SqlServer.TransactSql.ScriptDom;
@@ -9,7 +9,7 @@
namespace SqlServer.Rules.Design
{
///
- ///
+ /// Equality and inequality comparisons involving a NULL constant found. Use IS NULL or IS NOT NULL.
///
///
/// false
diff --git a/SqlServer.Rules/Design/NoLengthVarcharRule.cs b/SqlServer.Rules/Design/NoLengthVarcharRule.cs
index 4c320f2..9a8758d 100644
--- a/SqlServer.Rules/Design/NoLengthVarcharRule.cs
+++ b/SqlServer.Rules/Design/NoLengthVarcharRule.cs
@@ -47,7 +47,10 @@ public NoLengthVarcharRule()
new[]
{
ModelSchema.Procedure, ModelSchema.ScalarFunction, ModelSchema.TableValuedFunction, ModelSchema.Table,
- }, new[] { SqlDataTypeOption.VarChar, SqlDataTypeOption.NVarChar, SqlDataTypeOption.Char, SqlDataTypeOption.NChar }, 1, Message)
+ },
+ new[] { SqlDataTypeOption.VarChar, SqlDataTypeOption.NVarChar, SqlDataTypeOption.Char, SqlDataTypeOption.NChar },
+ 1,
+ Message)
{
}
}
diff --git a/SqlServer.Rules/Design/NoPrecisionScaleRule.cs b/SqlServer.Rules/Design/NoPrecisionScaleRule.cs
index f52f745..5b6a5fa 100644
--- a/SqlServer.Rules/Design/NoPrecisionScaleRule.cs
+++ b/SqlServer.Rules/Design/NoPrecisionScaleRule.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.Dac.CodeAnalysis;
+using Microsoft.SqlServer.Dac.CodeAnalysis;
using Microsoft.SqlServer.Dac.Model;
using Microsoft.SqlServer.TransactSql.ScriptDom;
using SqlServer.Rules.Globals;
@@ -49,7 +49,10 @@ public NoPrecisionScaleRule()
new[]
{
ModelSchema.Procedure, ModelSchema.ScalarFunction, ModelSchema.TableValuedFunction, ModelSchema.Table,
- }, new[] { SqlDataTypeOption.Decimal, SqlDataTypeOption.Numeric }, 2, Message)
+ },
+ new[] { SqlDataTypeOption.Decimal, SqlDataTypeOption.Numeric },
+ 2,
+ Message)
{
}
}
diff --git a/SqlServer.Rules/Design/TypesMissingParametersRule.cs b/SqlServer.Rules/Design/TypesMissingParametersRule.cs
index 5022003..89560df 100644
--- a/SqlServer.Rules/Design/TypesMissingParametersRule.cs
+++ b/SqlServer.Rules/Design/TypesMissingParametersRule.cs
@@ -9,18 +9,11 @@
namespace SqlServer.Rules.Design
{
- ///
- ///
- ///
- ///
- /// false
- ///
- ///
public class TypesMissingParametersRule : BaseSqlCodeAnalysisRule
{
- private readonly int _expectParameterCount;
- private readonly string _message;
- private readonly IList _types;
+ private readonly int expectParameterCount;
+ private readonly string message;
+ private readonly IList types;
///
/// Initializes a new instance of the class.
@@ -32,9 +25,9 @@ public class TypesMissingParametersRule : BaseSqlCodeAnalysisRule
public TypesMissingParametersRule(IList supportedElementTypes, IList types, int expectParameterCount, string message)
: base(supportedElementTypes)
{
- _expectParameterCount = expectParameterCount;
- _message = message;
- _types = types;
+ this.expectParameterCount = expectParameterCount;
+ this.message = message;
+ this.types = types;
}
///
@@ -69,16 +62,16 @@ from d in variableVisitor.DeclareVariables
from v in d.Declarations
let type = v.DataType as SqlDataTypeReference
let typeOption = type?.SqlDataTypeOption
- where _types.Contains(typeOption.GetValueOrDefault(SqlDataTypeOption.None))
- where type?.Parameters.Count != _expectParameterCount
+ where types.Contains(typeOption.GetValueOrDefault(SqlDataTypeOption.None))
+ where type?.Parameters.Count != expectParameterCount
select v;
var parameters =
from p in variableVisitor.ProcedureParameters
let type = p.DataType as SqlDataTypeReference
let typeOption = type?.SqlDataTypeOption
- where _types.Contains(typeOption.GetValueOrDefault(SqlDataTypeOption.None))
- where type?.Parameters.Count != _expectParameterCount
+ where types.Contains(typeOption.GetValueOrDefault(SqlDataTypeOption.None))
+ where type?.Parameters.Count != expectParameterCount
select p;
var columns =
@@ -86,13 +79,13 @@ from s in tableDefinitionVisitor.Statements
from c in s.ColumnDefinitions
let type = c.DataType as SqlDataTypeReference
let typeOption = type?.SqlDataTypeOption
- where _types.Contains(typeOption.GetValueOrDefault(SqlDataTypeOption.None))
- where type?.Parameters.Count != _expectParameterCount
+ where types.Contains(typeOption.GetValueOrDefault(SqlDataTypeOption.None))
+ where type?.Parameters.Count != expectParameterCount
select c;
- problems.AddRange(variables.Select(p => new SqlRuleProblem(_message, sqlObj, p)));
- problems.AddRange(parameters.Select(p => new SqlRuleProblem(_message, sqlObj, p)));
- problems.AddRange(columns.Select(p => new SqlRuleProblem(_message, sqlObj, p)));
+ problems.AddRange(variables.Select(p => new SqlRuleProblem(message, sqlObj, p)));
+ problems.AddRange(parameters.Select(p => new SqlRuleProblem(message, sqlObj, p)));
+ problems.AddRange(columns.Select(p => new SqlRuleProblem(message, sqlObj, p)));
var castVisitor = new CastCallVisitor();
var convertVisitor = new ConvertCallVisitor();
@@ -101,19 +94,19 @@ where _types.Contains(typeOption.GetValueOrDefault(SqlDataTypeOption.None))
var castCalls = from c in castVisitor.Statements
let type = c.DataType as SqlDataTypeReference
let typeOption = type?.SqlDataTypeOption
- where _types.Contains(typeOption.GetValueOrDefault(SqlDataTypeOption.None))
- where type?.Parameters.Count != _expectParameterCount
+ where types.Contains(typeOption.GetValueOrDefault(SqlDataTypeOption.None))
+ where type?.Parameters.Count != expectParameterCount
select c;
var convertCalls = from c in convertVisitor.Statements
let type = c.DataType as SqlDataTypeReference
let typeOption = type?.SqlDataTypeOption
- where _types.Contains(typeOption.GetValueOrDefault(SqlDataTypeOption.None))
- where type?.Parameters.Count != _expectParameterCount
+ where types.Contains(typeOption.GetValueOrDefault(SqlDataTypeOption.None))
+ where type?.Parameters.Count != expectParameterCount
select c;
- problems.AddRange(castCalls.Select(p => new SqlRuleProblem(_message, sqlObj, p)));
- problems.AddRange(convertCalls.Select(p => new SqlRuleProblem(_message, sqlObj, p)));
+ problems.AddRange(castCalls.Select(p => new SqlRuleProblem(message, sqlObj, p)));
+ problems.AddRange(convertCalls.Select(p => new SqlRuleProblem(message, sqlObj, p)));
return problems;
}
diff --git a/SqlServer.Rules/Globals/Constants.cs b/SqlServer.Rules/Globals/Constants.cs
index a2d5ebe..e224e33 100644
--- a/SqlServer.Rules/Globals/Constants.cs
+++ b/SqlServer.Rules/Globals/Constants.cs
@@ -1,15 +1,16 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
namespace SqlServer.Rules.Globals
{
- internal static class Constants
+ public static class Constants
{
public const string RuleNameSpace = "SqlServer.Rules.";
public const string Performance = "Performance";
public const string Design = "Design";
public const string Naming = "Naming";
- public static List Aggregates = new List
+#pragma warning disable CA1002 // Do not expose generic lists
+ public static List Aggregates { get; private set; } = new List
{
"AVG",
"MIN",
@@ -26,7 +27,7 @@ internal static class Constants
"MAX",
};
- public static List DateParts = new List
+ public static List DateParts { get; private set; } = new List
{
"YEAR",
"YY",
@@ -66,3 +67,4 @@ internal static class Constants
};
}
}
+#pragma warning restore CA1002 // Do not expose generic lists
\ No newline at end of file
diff --git a/SqlServer.Rules/Globals/Ignorables.cs b/SqlServer.Rules/Globals/Ignorables.cs
index ce5dba0..7b64790 100644
--- a/SqlServer.Rules/Globals/Ignorables.cs
+++ b/SqlServer.Rules/Globals/Ignorables.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
@@ -7,21 +7,10 @@
namespace SqlServer.Rules.Globals
{
- ///
- ///
- ///
public static class Ignorables
{
- #region ignorables
-
- ///
- /// Nots the ignored statements.
- ///
- ///
- /// The visitor.
- /// The rule identifier.
- ///
- public static IEnumerable NotIgnoredStatements(this IVisitor visitor, string ruleId) where T : TSqlFragment
+ public static IEnumerable NotIgnoredStatements(this IVisitor visitor, string ruleId)
+ where T : TSqlFragment
{
var scriptTokenStream = visitor.Statements.FirstOrDefault()?.ScriptTokenStream;
if (scriptTokenStream == null)
@@ -34,30 +23,16 @@ where ShouldNotIgnoreRule(scriptTokenStream, ruleId, s.StartLine)
select s;
}
- ///
- /// Nots the ignored statements.
- ///
- ///
- /// The visitor.
- /// The script token stream.
- /// The rule identifier.
- ///
- public static IEnumerable NotIgnoredStatements(this IVisitor visitor, IList scriptTokenStream, string ruleId) where T : TSqlFragment
+ public static IEnumerable NotIgnoredStatements(this IVisitor visitor, IList scriptTokenStream, string ruleId)
+ where T : TSqlFragment
{
return from s in visitor.Statements
where ShouldNotIgnoreRule(scriptTokenStream, ruleId, s.StartLine)
select s;
}
- private static readonly char[] separator = new char[] { '.' };
+ private static readonly char[] Separator = new char[] { '.' };
- ///
- /// Shoulds the not ignore rule.
- ///
- /// The script token stream.
- /// The rule identifier.
- /// The line number.
- ///
public static bool ShouldNotIgnoreRule(IList scriptTokenStream, string ruleId, int lineNumber)
{
if (scriptTokenStream == null)
@@ -65,7 +40,7 @@ public static bool ShouldNotIgnoreRule(IList scriptTokenStream,
return false;
}
- var baseRuleId = ruleId.Split(separator, StringSplitOptions.RemoveEmptyEntries).Last();
+ var baseRuleId = ruleId.Split(Separator, StringSplitOptions.RemoveEmptyEntries).Last();
var ignoreRegex = $@"\bIGNORE\b.*\b{baseRuleId}\b";
var globalIgnoreRegex = $@"\bGLOBAL\b\s*\bIGNORE\b.*\b{baseRuleId}\b";
@@ -80,6 +55,5 @@ from t in scriptTokenStream
return !result.Any();
}
- #endregion ignorables
}
}
diff --git a/SqlServer.Rules/Globals/ModelInfo.cs b/SqlServer.Rules/Globals/ModelInfo.cs
index 59c5bdd..274269f 100644
--- a/SqlServer.Rules/Globals/ModelInfo.cs
+++ b/SqlServer.Rules/Globals/ModelInfo.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
@@ -41,12 +41,6 @@ public static bool IsWhiteListed(this TSqlObject sqlObj)
return "[dbo].[RfcVersionHistory]".StringEquals(sqlObj.Name.ToString());
}
- ///
- /// Gets the data type view.
- ///
- /// The list.
- /// The column.
- ///
public static DataTypeView GetDataTypeView(this IDictionary> list, ColumnReferenceExpression column)
{
if (column == null)
@@ -72,12 +66,6 @@ public static DataTypeView GetDataTypeView(this IDictionary
- /// Gets the set variable.
- ///
- /// The select.
- /// Name of the variable.
- ///
public static string GetSetVariable(this SelectStatement select, string variableName)
{
if (select.QueryExpression is QuerySpecification query)
@@ -91,11 +79,6 @@ public static string GetSetVariable(this SelectStatement select, string variable
return null;
}
- ///
- /// Gets the value.
- ///
- /// The literal.
- ///
public static int GetValue(this IntegerLiteral literal)
{
var result = 0;
@@ -150,12 +133,6 @@ public static void GetTableColumnDataTypes(this TSqlStatement query, IDictionary
}
}
- ///
- /// Gets the columns and data types.
- ///
- /// The table.
- /// The model.
- ///
public static IDictionary GetColumnsAndDataTypes(this NamedTableReference table, TSqlModel model)
{
var ret = new Dictionary(StringComparer.InvariantCultureIgnoreCase);
@@ -176,12 +153,6 @@ public static IDictionary GetColumnsAndDataTypes(this Name
return ret;
}
- ///
- /// Gets the selects setting parameter value.
- ///
- /// The selects.
- /// The parameter.
- ///
public static IEnumerable GetSelectsSettingParameterValue(this IEnumerable selects, string parameter)
{
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
@@ -202,12 +173,6 @@ public static IEnumerable GetSelectsSettingParameterValue(this
yield break;
}
- ///
- /// Gets the selects using parameter in where.
- ///
- /// The selects.
- /// The parameter.
- ///
public static IEnumerable GetSelectsUsingParameterInWhere(this IEnumerable selects, string parameter)
{
#pragma warning disable CA1851 // Possible multiple enumerations of 'IEnumerable' collection
@@ -239,11 +204,6 @@ public static IEnumerable GetSelectsUsingParameterInWhere(this
yield break;
}
- ///
- /// Gets the data type parameters.
- ///
- /// Type of the data.
- ///
public static IEnumerable GetDataTypeParameters(this DataTypeReference dataType)
{
if (dataType == null)
diff --git a/SqlServer.Rules/NamedTableView.cs b/SqlServer.Rules/NamedTableView.cs
index b75052f..1476c1d 100644
--- a/SqlServer.Rules/NamedTableView.cs
+++ b/SqlServer.Rules/NamedTableView.cs
@@ -7,9 +7,6 @@
namespace SqlServer.Rules
{
- ///
- ///
- ///
public class NamedTableView
{
///
@@ -33,25 +30,15 @@ public NamedTableView(NamedTableReference namedTable)
///
public string Name { get; set; }
- ///
- /// Gets or sets the aliases.
- ///
- ///
- /// The aliases.
- ///
#pragma warning disable CA1002 // Do not expose generic lists
public List Aliases { get; private set; } = new List();
#pragma warning restore CA1002 // Do not expose generic lists
- private static readonly char[] separator = new[] { '.' };
+ private static readonly char[] Separator = new[] { '.' };
- ///
- /// Names to identifier.
- ///
- ///
public ObjectIdentifier NameToId()
{
- return new ObjectIdentifier((Name ?? string.Empty).Split(separator, StringSplitOptions.RemoveEmptyEntries));
+ return new ObjectIdentifier((Name ?? string.Empty).Split(Separator, StringSplitOptions.RemoveEmptyEntries));
}
///
diff --git a/SqlServer.Rules/Naming/GeneralNamingRules.cs b/SqlServer.Rules/Naming/GeneralNamingRules.cs
index 7f6f34c..e70439d 100644
--- a/SqlServer.Rules/Naming/GeneralNamingRules.cs
+++ b/SqlServer.Rules/Naming/GeneralNamingRules.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Microsoft.SqlServer.Dac.CodeAnalysis;
@@ -57,7 +57,6 @@ public GeneralNamingRules()
ModelSchema.ScalarFunction,
ModelSchema.TableValuedFunction,
ModelSchema.Procedure,
-
ModelSchema.PrimaryKeyConstraint,
ModelSchema.Index,
ModelSchema.ForeignKeyConstraint,
diff --git a/SqlServer.Rules/Naming/UseTwoPartNamesRule.cs b/SqlServer.Rules/Naming/UseTwoPartNames.cs
similarity index 100%
rename from SqlServer.Rules/Naming/UseTwoPartNamesRule.cs
rename to SqlServer.Rules/Naming/UseTwoPartNames.cs
diff --git a/SqlServer.Rules/ReferentialIntegrity/ForeignKeyInfo.cs b/SqlServer.Rules/ReferentialIntegrity/ForeignKeyInfo.cs
index d5f891b..567d1b7 100644
--- a/SqlServer.Rules/ReferentialIntegrity/ForeignKeyInfo.cs
+++ b/SqlServer.Rules/ReferentialIntegrity/ForeignKeyInfo.cs
@@ -5,9 +5,6 @@
namespace SqlServer.Rules.ReferentialIntegrity
{
- ///
- ///
- ///
public class ForeignKeyInfo
{
///
diff --git a/SqlServer.Rules/ReferentialIntegrity/JoinInfo.cs b/SqlServer.Rules/ReferentialIntegrity/JoinInfo.cs
index 301f25a..9498dc6 100644
--- a/SqlServer.Rules/ReferentialIntegrity/JoinInfo.cs
+++ b/SqlServer.Rules/ReferentialIntegrity/JoinInfo.cs
@@ -6,9 +6,6 @@
namespace SqlServer.Rules.ReferentialIntegrity
{
- ///
- ///
- ///
public class JoinInfo
{
///
@@ -74,11 +71,7 @@ public ObjectIdentifier Table2Name
///
public IList Table2JoinColumns { get; set; } = new List();
#pragma warning restore CA2227 // Collection properties should be read only
- ///
- /// Checks the table names.
- ///
- /// The fk information.
- ///
+
public bool CheckTableNames(ForeignKeyInfo fkInfo)
{
var table1Name = Table1Name;
@@ -88,11 +81,6 @@ public bool CheckTableNames(ForeignKeyInfo fkInfo)
|| (fkInfo.TableName.CompareTo(table2Name) >= 5 && fkInfo.ToTableName.CompareTo(table1Name) >= 5);
}
- ///
- /// Checks the full join.
- ///
- /// The fk information.
- ///
public bool CheckFullJoin(ForeignKeyInfo fkInfo)
{
var table1Name = Table1Name;
@@ -119,7 +107,7 @@ public bool CheckFullJoin(ForeignKeyInfo fkInfo)
return false;
}
- private (IList table1Columns, IList table2Columns, IList fkInfoColumnNames, IList fkInfoToColumnNames) GetColumnNames(ForeignKeyInfo fkInfo)
+ private (IList Table1Columns, IList Table2Columns, IList FkInfoColumnNames, IList FkInfoToColumnNames) GetColumnNames(ForeignKeyInfo fkInfo)
{
#pragma warning disable CA1304 // Specify CultureInfo
#pragma warning disable CA1311 // Specify a culture or use an invariant version
diff --git a/SqlServer.Rules/ReferentialIntegrity/RIUtils.cs b/SqlServer.Rules/ReferentialIntegrity/RIUtils.cs
index 40886a5..d15ffec 100644
--- a/SqlServer.Rules/ReferentialIntegrity/RIUtils.cs
+++ b/SqlServer.Rules/ReferentialIntegrity/RIUtils.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.SqlServer.Dac.Model;
@@ -9,23 +9,8 @@
namespace SqlServer.Rules.ReferentialIntegrity
{
- ///
- ///
- ///
public static class RIUtils
{
- ///
- /// Checks the index of for fk.
- ///
- /// The table.
- /// The column names.
- ///
- ///
- /// table
- /// or
- /// columnNames
- ///
- /// The parameter is not of type Table - table
public static bool CheckForFkIndex(this TSqlObject table, IList columnNames)
{
if (table == null)
@@ -86,13 +71,6 @@ public static bool CheckForFkIndex(this TSqlObject table, IList
- /// Gets the table fk infos.
- ///
- /// The table.
- ///
- /// table
- /// The parameter is not of type Table - table
public static IDictionary GetTableFKInfos(this TSqlObject table)
{
if (table == null)
@@ -119,13 +97,6 @@ public static IDictionary GetTableFKInfos(this TSqlObjec
return fks;
}
- ///
- /// Gets the fk information.
- ///
- /// The fk.
- ///
- /// fk
- /// The parameter is not of type ForeignKeyConstraint - fk
public static ForeignKeyInfo GetFKInfo(this TSqlObject fk)
{
if (fk == null)
@@ -153,12 +124,6 @@ public static ForeignKeyInfo GetFKInfo(this TSqlObject fk)
};
}
- ///
- /// Gets from clause join tables.
- ///
- /// From.
- ///
- /// from
public static IList GetFromClauseJoinTables(this FromClause from)
{
if (from == null)
diff --git a/SqlServer.TSQLSmells/FragmentTypeParser.cs b/SqlServer.TSQLSmells/FragmentTypeParser.cs
index 3340db5..8defa3e 100644
--- a/SqlServer.TSQLSmells/FragmentTypeParser.cs
+++ b/SqlServer.TSQLSmells/FragmentTypeParser.cs
@@ -1,21 +1,15 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
public static class FragmentTypeParser
{
- public static string GetFragmentType(TSqlFragment Statement)
+ public static string GetFragmentType(TSqlFragment statement)
{
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var Type = Statement.ToString();
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var TypeSplit = Type.Split('.');
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var StmtType = TypeSplit[TypeSplit.Length - 1];
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- return StmtType;
+ var type = statement.ToString();
+ var typeSplit = type.Split('.');
+ var stmtType = typeSplit[typeSplit.Length - 1];
+ return stmtType;
}
}
}
\ No newline at end of file
diff --git a/SqlServer.TSQLSmells/Processors/BeginEndBlockProcessor.cs b/SqlServer.TSQLSmells/Processors/BeginEndBlockProcessor.cs
index 107b9fd..d52bc38 100644
--- a/SqlServer.TSQLSmells/Processors/BeginEndBlockProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/BeginEndBlockProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,10 +11,10 @@ public BeginEndBlockProcessor(Smells smells)
this.smells = smells;
}
- public void ProcessBeginEndBlockStatement(BeginEndBlockStatement BEStatement)
+ public void ProcessBeginEndBlockStatement(BeginEndBlockStatement bEStatement)
{
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- foreach (var Statement in BEStatement.StatementList.Statements)
+ foreach (var Statement in bEStatement.StatementList.Statements)
{
smells.ProcessTsqlFragment(Statement);
}
diff --git a/SqlServer.TSQLSmells/Processors/ColumnDefinitionProcessor.cs b/SqlServer.TSQLSmells/Processors/ColumnDefinitionProcessor.cs
index e8230a3..cdd5b8a 100644
--- a/SqlServer.TSQLSmells/Processors/ColumnDefinitionProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/ColumnDefinitionProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,15 +11,13 @@ public ColumnDefinitionProcessor(Smells smells)
this.smells = smells;
}
- public void ProcessColumnDefinition(ColumnDefinition ColumnDef)
+ public void ProcessColumnDefinition(ColumnDefinition columnDef)
{
- smells.ProcessTsqlFragment(ColumnDef.DataType);
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- foreach (var Constraint in ColumnDef.Constraints)
+ smells.ProcessTsqlFragment(columnDef.DataType);
+ foreach (var constraint in columnDef.Constraints)
{
- smells.ProcessTsqlFragment(Constraint);
+ smells.ProcessTsqlFragment(constraint);
}
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
}
}
}
\ No newline at end of file
diff --git a/SqlServer.TSQLSmells/Processors/CreateTableProcessor.cs b/SqlServer.TSQLSmells/Processors/CreateTableProcessor.cs
index 6b6d3b6..f15c6ba 100644
--- a/SqlServer.TSQLSmells/Processors/CreateTableProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/CreateTableProcessor.cs
@@ -11,19 +11,19 @@ public CreateTableProcessor(Smells smells)
this.smells = smells;
}
- public void ProcessCreateTable(CreateTableStatement TblStmt)
+ public void ProcessCreateTable(CreateTableStatement tblStmt)
{
- var isTemp = TblStmt.SchemaObjectName.BaseIdentifier.Value.StartsWith('#') ||
- TblStmt.SchemaObjectName.BaseIdentifier.Value.StartsWith('@');
+ var isTemp = tblStmt.SchemaObjectName.BaseIdentifier.Value.StartsWith('#') ||
+ tblStmt.SchemaObjectName.BaseIdentifier.Value.StartsWith('@');
- if (TblStmt.SchemaObjectName.SchemaIdentifier == null &&
+ if (tblStmt.SchemaObjectName.SchemaIdentifier == null &&
!isTemp)
{
- smells.SendFeedBack(27, TblStmt);
+ smells.SendFeedBack(27, tblStmt);
}
{
- foreach (var colDef in TblStmt.Definition.ColumnDefinitions)
+ foreach (var colDef in tblStmt.Definition.ColumnDefinitions)
{
smells.ProcessTsqlFragment(colDef);
}
@@ -31,7 +31,7 @@ public void ProcessCreateTable(CreateTableStatement TblStmt)
if (isTemp)
{
- foreach (var constDef in TblStmt.Definition.TableConstraints)
+ foreach (var constDef in tblStmt.Definition.TableConstraints)
{
if (constDef.ConstraintIdentifier != null)
{
@@ -50,7 +50,7 @@ public void ProcessCreateTable(CreateTableStatement TblStmt)
}
}
- foreach (var colDef in TblStmt.Definition.ColumnDefinitions)
+ foreach (var colDef in tblStmt.Definition.ColumnDefinitions)
{
if (colDef.DefaultConstraint?.ConstraintIdentifier != null)
{
diff --git a/SqlServer.TSQLSmells/Processors/FromProcessor.cs b/SqlServer.TSQLSmells/Processors/FromProcessor.cs
index 59e9fa7..069309e 100644
--- a/SqlServer.TSQLSmells/Processors/FromProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/FromProcessor.cs
@@ -11,7 +11,7 @@ public FromProcessor(Smells smells)
this.smells = smells;
}
- private static bool isCteName(SchemaObjectName ObjectName, WithCtesAndXmlNamespaces cte)
+ private static bool IsCteName(SchemaObjectName objectName, WithCtesAndXmlNamespaces cte)
{
if (cte == null)
{
@@ -21,7 +21,7 @@ private static bool isCteName(SchemaObjectName ObjectName, WithCtesAndXmlNamespa
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
foreach (var Expression in cte.CommonTableExpressions)
{
- if (Expression.ExpressionName.Value == ObjectName.BaseIdentifier.Value)
+ if (Expression.ExpressionName.Value == objectName.BaseIdentifier.Value)
{
return true;
}
@@ -31,16 +31,16 @@ private static bool isCteName(SchemaObjectName ObjectName, WithCtesAndXmlNamespa
return false;
}
- private void ProcessTableReference(TableReference TableRef, WithCtesAndXmlNamespaces cte)
+ private void ProcessTableReference(TableReference tableRef, WithCtesAndXmlNamespaces cte)
{
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var Type = FragmentTypeParser.GetFragmentType(TableRef);
+ var Type = FragmentTypeParser.GetFragmentType(tableRef);
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
switch (Type)
{
case "NamedTableReference":
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var NamedTableRef = (NamedTableReference)TableRef;
+ var NamedTableRef = (NamedTableReference)tableRef;
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
if (NamedTableRef.SchemaObject.BaseIdentifier.Value[0] != '#' &&
NamedTableRef.SchemaObject.BaseIdentifier.Value[0] != '@')
@@ -51,7 +51,7 @@ private void ProcessTableReference(TableReference TableRef, WithCtesAndXmlNamesp
}
if (NamedTableRef.SchemaObject.SchemaIdentifier == null &&
- !isCteName(NamedTableRef.SchemaObject, cte))
+ !IsCteName(NamedTableRef.SchemaObject, cte))
{
smells.SendFeedBack(2, NamedTableRef);
}
@@ -87,7 +87,7 @@ private void ProcessTableReference(TableReference TableRef, WithCtesAndXmlNamesp
case "QueryDerivedTable":
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var QueryDerivedRef = (QueryDerivedTable)TableRef;
+ var QueryDerivedRef = (QueryDerivedTable)tableRef;
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
var Alias = QueryDerivedRef.Alias.Value;
@@ -107,7 +107,7 @@ private void ProcessTableReference(TableReference TableRef, WithCtesAndXmlNamesp
break;
case "QualifiedJoin":
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var QualifiedJoin = (QualifiedJoin)TableRef;
+ var QualifiedJoin = (QualifiedJoin)tableRef;
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
ProcessTableReference(QualifiedJoin.FirstTableReference, cte);
ProcessTableReference(QualifiedJoin.SecondTableReference, cte);
@@ -115,10 +115,10 @@ private void ProcessTableReference(TableReference TableRef, WithCtesAndXmlNamesp
}
}
- public void Process(FromClause FromClause, WithCtesAndXmlNamespaces cte)
+ public void Process(FromClause fromClause, WithCtesAndXmlNamespaces cte)
{
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- foreach (var TableRef in FromClause.TableReferences)
+ foreach (var TableRef in fromClause.TableReferences)
{
ProcessTableReference(TableRef, cte);
}
diff --git a/SqlServer.TSQLSmells/Processors/FunctionStatementBodyProcessor.cs b/SqlServer.TSQLSmells/Processors/FunctionStatementBodyProcessor.cs
index 2758532..03d05f6 100644
--- a/SqlServer.TSQLSmells/Processors/FunctionStatementBodyProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/FunctionStatementBodyProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,23 +11,21 @@ public FunctionStatementBodyProcessor(Smells smells)
this.smells = smells;
}
- public void ProcessFunctionStatementBody(FunctionStatementBody Function)
+ public void ProcessFunctionStatementBody(FunctionStatementBody function)
{
- if (Function.Name.SchemaIdentifier == null)
+ if (function.Name.SchemaIdentifier == null)
{
- smells.SendFeedBack(24, Function.Name);
+ smells.SendFeedBack(24, function.Name);
}
- smells.ProcessTsqlFragment(Function.ReturnType);
+ smells.ProcessTsqlFragment(function.ReturnType);
- if (Function.StatementList != null)
+ if (function.StatementList != null)
{
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- foreach (TSqlFragment Statement in Function.StatementList.Statements)
+ foreach (TSqlFragment statement in function.StatementList.Statements)
{
- smells.ProcessTsqlFragment(Statement);
+ smells.ProcessTsqlFragment(statement);
}
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
}
}
}
diff --git a/SqlServer.TSQLSmells/Processors/InsertProcessor.cs b/SqlServer.TSQLSmells/Processors/InsertProcessor.cs
index 43004e8..cbe3edc 100644
--- a/SqlServer.TSQLSmells/Processors/InsertProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/InsertProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,49 +11,39 @@ public InsertProcessor(Smells smells)
this.smells = smells;
}
- public void ProcessWithCtesAndXmlNamespaces(WithCtesAndXmlNamespaces Cte)
+ public void ProcessWithCtesAndXmlNamespaces(WithCtesAndXmlNamespaces cte)
{
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- foreach (var Expression in Cte.CommonTableExpressions)
+ foreach (var expression in cte.CommonTableExpressions)
{
- smells.ProcessQueryExpression(Expression.QueryExpression, "RG", false, Cte);
+ smells.ProcessQueryExpression(expression.QueryExpression, "RG", false, cte);
}
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
}
- public void Process(InsertStatement Fragment)
+ public void Process(InsertStatement fragment)
{
- if (Fragment.InsertSpecification.Columns.Count == 0)
+ if (fragment.InsertSpecification.Columns.Count == 0)
{
- smells.SendFeedBack(12, Fragment);
+ smells.SendFeedBack(12, fragment);
}
- switch (FragmentTypeParser.GetFragmentType(Fragment.InsertSpecification.InsertSource))
+ switch (FragmentTypeParser.GetFragmentType(fragment.InsertSpecification.InsertSource))
{
case "SelectInsertSource":
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var InsSource = (SelectInsertSource)Fragment.InsertSpecification.InsertSource;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var Cte = Fragment.WithCtesAndXmlNamespaces;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- smells.ProcessQueryExpression(InsSource.Select, "RG", false, Cte);
- if (Cte != null)
+ var insSource = (SelectInsertSource)fragment.InsertSpecification.InsertSource;
+ var cte = fragment.WithCtesAndXmlNamespaces;
+ smells.ProcessQueryExpression(insSource.Select, "RG", false, cte);
+ if (cte != null)
{
- ProcessWithCtesAndXmlNamespaces(Cte);
+ ProcessWithCtesAndXmlNamespaces(cte);
}
break;
case "ExecuteInsertSource":
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var ExecSource = (ExecuteInsertSource)Fragment.InsertSpecification.InsertSource;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
+ var execSource = (ExecuteInsertSource)fragment.InsertSpecification.InsertSource;
// ProcessExecuteSpecification(ExecSource.Execute);
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var ExecutableEntity = ExecSource.Execute.ExecutableEntity;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- smells.ExecutableEntityProcessor.ProcessExecutableEntity(ExecutableEntity);
+ var executableEntity = execSource.Execute.ExecutableEntity;
+ smells.ExecutableEntityProcessor.ProcessExecutableEntity(executableEntity);
break;
}
}
diff --git a/SqlServer.TSQLSmells/Processors/OrderByProcessor.cs b/SqlServer.TSQLSmells/Processors/OrderByProcessor.cs
index 419bf18..703d3ee 100644
--- a/SqlServer.TSQLSmells/Processors/OrderByProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/OrderByProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,42 +11,36 @@ public OrderByProcessor(Smells smells)
this.smells = smells;
}
- private void ProcessOrderExpression(ExpressionWithSortOrder Expression)
+ private void ProcessOrderExpression(ExpressionWithSortOrder expression)
{
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var SubExpressionType = FragmentTypeParser.GetFragmentType(Expression.Expression);
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- switch (SubExpressionType)
+ var subExpressionType = FragmentTypeParser.GetFragmentType(expression.Expression);
+ switch (subExpressionType)
{
case "IntegerLiteral":
- smells.SendFeedBack(7, Expression);
+ smells.SendFeedBack(7, expression);
break;
case "CastCall":
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var CastCall = (CastCall)Expression.Expression;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- if (FragmentTypeParser.GetFragmentType(CastCall.Parameter) == "ColumnReferenceExpression")
+ var castCall = (CastCall)expression.Expression;
+ if (FragmentTypeParser.GetFragmentType(castCall.Parameter) == "ColumnReferenceExpression")
{
- smells.SendFeedBack(6, Expression);
+ smells.SendFeedBack(6, expression);
}
break;
}
}
- public void Process(OrderByClause OrderClause)
+ public void Process(OrderByClause orderClause)
{
- if (OrderClause == null)
+ if (orderClause == null)
{
return;
}
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- foreach (var Expression in OrderClause.OrderByElements)
+ foreach (var expression in orderClause.OrderByElements)
{
- ProcessOrderExpression(Expression);
+ ProcessOrderExpression(expression);
}
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
}
}
}
\ No newline at end of file
diff --git a/SqlServer.TSQLSmells/Processors/PredicateSetProcessor.cs b/SqlServer.TSQLSmells/Processors/PredicateSetProcessor.cs
index f8e5e97..7a73e93 100644
--- a/SqlServer.TSQLSmells/Processors/PredicateSetProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/PredicateSetProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,68 +11,68 @@ public PredicateSetProcessor(Smells smells)
this.smells = smells;
}
- public void ProcessPredicateSetStatement(PredicateSetStatement Fragment)
+ public void ProcessPredicateSetStatement(PredicateSetStatement fragment)
{
- switch (Fragment.Options)
+ switch (fragment.Options)
{
case SetOptions.AnsiNulls:
- if (!Fragment.IsOn)
+ if (!fragment.IsOn)
{
- smells.SendFeedBack(14, Fragment);
+ smells.SendFeedBack(14, fragment);
}
return;
case SetOptions.AnsiPadding:
- if (!Fragment.IsOn)
+ if (!fragment.IsOn)
{
- smells.SendFeedBack(15, Fragment);
+ smells.SendFeedBack(15, fragment);
}
return;
case SetOptions.AnsiWarnings:
- if (!Fragment.IsOn)
+ if (!fragment.IsOn)
{
- smells.SendFeedBack(16, Fragment);
+ smells.SendFeedBack(16, fragment);
}
return;
case SetOptions.ArithAbort:
- if (!Fragment.IsOn)
+ if (!fragment.IsOn)
{
- smells.SendFeedBack(17, Fragment);
+ smells.SendFeedBack(17, fragment);
}
return;
case SetOptions.NumericRoundAbort:
- if (Fragment.IsOn)
+ if (fragment.IsOn)
{
- smells.SendFeedBack(18, Fragment);
+ smells.SendFeedBack(18, fragment);
}
return;
case SetOptions.QuotedIdentifier:
- if (!Fragment.IsOn)
+ if (!fragment.IsOn)
{
- smells.SendFeedBack(19, Fragment);
+ smells.SendFeedBack(19, fragment);
}
return;
case SetOptions.ForcePlan:
- if (Fragment.IsOn)
+ if (fragment.IsOn)
{
- smells.SendFeedBack(20, Fragment);
+ smells.SendFeedBack(20, fragment);
}
return;
case SetOptions.ConcatNullYieldsNull:
- if (!Fragment.IsOn)
+ if (!fragment.IsOn)
{
- smells.SendFeedBack(13, Fragment);
+ smells.SendFeedBack(13, fragment);
}
return;
case SetOptions.NoCount:
- if (Fragment.IsOn)
+ if (fragment.IsOn)
{
smells.ProcedureStatementBodyProcessor.NoCountSet = true;
}
diff --git a/SqlServer.TSQLSmells/Processors/ProcedureStatementBodyProcessor.cs b/SqlServer.TSQLSmells/Processors/ProcedureStatementBodyProcessor.cs
index a7506d5..437c63f 100644
--- a/SqlServer.TSQLSmells/Processors/ProcedureStatementBodyProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/ProcedureStatementBodyProcessor.cs
@@ -1,4 +1,4 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
@@ -7,7 +7,7 @@ public class ProcedureStatementBodyProcessor
{
private readonly Smells smells;
public bool NoCountSet { get; set; }
- private IList _parameterList;
+ private IList parameterList;
public ProcedureStatementBodyProcessor(Smells smells)
{
@@ -18,38 +18,36 @@ public ProcedureStatementBodyProcessor(Smells smells)
public IList ParameterList
#pragma warning restore CA2227 // Collection properties should be read only
{
- get { return _parameterList; }
- set { _parameterList = value; }
+ get { return parameterList; }
+ set { parameterList = value; }
}
- private void TestProcedureReference(ProcedureReference PrcRef)
+ private void TestProcedureReference(ProcedureReference prcRef)
{
- if (PrcRef.Name.SchemaIdentifier == null)
+ if (prcRef.Name.SchemaIdentifier == null)
{
- smells.SendFeedBack(24, PrcRef);
+ smells.SendFeedBack(24, prcRef);
}
}
- public void ProcessProcedureStatementBody(ProcedureStatementBody StatementBody)
+ public void ProcessProcedureStatementBody(ProcedureStatementBody statementBody)
{
smells.AssignmentList.Clear();
- TestProcedureReference(StatementBody.ProcedureReference);
- ParameterList = StatementBody.Parameters;
+ TestProcedureReference(statementBody.ProcedureReference);
+ ParameterList = statementBody.Parameters;
NoCountSet = false;
- if (StatementBody.StatementList != null)
+ if (statementBody.StatementList != null)
{
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- foreach (TSqlFragment Fragment in StatementBody.StatementList.Statements)
+ foreach (TSqlFragment fragment in statementBody.StatementList.Statements)
{
- smells.ProcessTsqlFragment(Fragment);
+ smells.ProcessTsqlFragment(fragment);
}
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
if (!NoCountSet)
{
- smells.SendFeedBack(30, StatementBody.ProcedureReference);
+ smells.SendFeedBack(30, statementBody.ProcedureReference);
}
}
diff --git a/SqlServer.TSQLSmells/Processors/ReturnStatementProcessor.cs b/SqlServer.TSQLSmells/Processors/ReturnStatementProcessor.cs
index e3e19d4..6064589 100644
--- a/SqlServer.TSQLSmells/Processors/ReturnStatementProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/ReturnStatementProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,11 +11,11 @@ public ReturnStatementProcessor(Smells smells)
this.smells = smells;
}
- public void ProcessReturnStatement(ReturnStatement ReturnStatement)
+ public void ProcessReturnStatement(ReturnStatement returnStatement)
{
- if (ReturnStatement.Expression != null)
+ if (returnStatement.Expression != null)
{
- smells.ProcessTsqlFragment(ReturnStatement.Expression);
+ smells.ProcessTsqlFragment(returnStatement.Expression);
}
}
}
diff --git a/SqlServer.TSQLSmells/Processors/ScalarFunctionReturnTypeProcessor.cs b/SqlServer.TSQLSmells/Processors/ScalarFunctionReturnTypeProcessor.cs
index fd3e8c9..feefc1a 100644
--- a/SqlServer.TSQLSmells/Processors/ScalarFunctionReturnTypeProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/ScalarFunctionReturnTypeProcessor.cs
@@ -1,10 +1,10 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
public static class ScalarFunctionReturnTypeProcessor
{
- public static void ProcessScalarFunctionReturnType(ScalarFunctionReturnType ReturnType)
+ public static void ProcessScalarFunctionReturnType(ScalarFunctionReturnType returnType)
{
}
}
diff --git a/SqlServer.TSQLSmells/Processors/SelectFunctionReturnTypeProcessor.cs b/SqlServer.TSQLSmells/Processors/SelectFunctionReturnTypeProcessor.cs
index 6d19b38..526f181 100644
--- a/SqlServer.TSQLSmells/Processors/SelectFunctionReturnTypeProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/SelectFunctionReturnTypeProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,9 +11,9 @@ public SelectFunctionReturnTypeProcessor(Smells smells)
this.smells = smells;
}
- public void ProcessSelectFunctionReturnType(SelectFunctionReturnType ReturnType)
+ public void ProcessSelectFunctionReturnType(SelectFunctionReturnType returnType)
{
- smells.ProcessTsqlFragment(ReturnType.SelectStatement);
+ smells.ProcessTsqlFragment(returnType.SelectStatement);
}
}
}
\ No newline at end of file
diff --git a/SqlServer.TSQLSmells/Processors/SelectSetProcessor.cs b/SqlServer.TSQLSmells/Processors/SelectSetProcessor.cs
index f2c7ca5..22c010d 100644
--- a/SqlServer.TSQLSmells/Processors/SelectSetProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/SelectSetProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,54 +11,42 @@ public SelectSetProcessor(Smells smells)
this.smells = smells;
}
- private void ProcessVariableReference(VariableReference VarRef, string VarName)
+ private void ProcessVariableReference(VariableReference varRef, string varName)
{
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var VarAssignment = new VarAssignment
+ var varAssignment = new VarAssignment
{
- SrcName = VarRef.Name,
- VarName = VarName,
+ SrcName = varRef.Name,
+ VarName = varName,
};
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- smells.AssignmentList.Add(VarAssignment);
+ smells.AssignmentList.Add(varAssignment);
}
- private void ProcessSelectSetFragment(TSqlFragment Expression, string VarName)
+ private void ProcessSelectSetFragment(TSqlFragment expression, string varName)
{
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var ElemType = FragmentTypeParser.GetFragmentType(Expression);
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- switch (ElemType)
+ var elemType = FragmentTypeParser.GetFragmentType(expression);
+ switch (elemType)
{
case "BinaryExpression":
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var BinaryExpression = (BinaryExpression)Expression;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- ProcessSelectSetFragment(BinaryExpression.FirstExpression, VarName);
- ProcessSelectSetFragment(BinaryExpression.SecondExpression, VarName);
+ var binaryExpression = (BinaryExpression)expression;
+ ProcessSelectSetFragment(binaryExpression.FirstExpression, varName);
+ ProcessSelectSetFragment(binaryExpression.SecondExpression, varName);
break;
case "VariableReference":
- ProcessVariableReference((VariableReference)Expression, VarName);
+ ProcessVariableReference((VariableReference)expression, varName);
break;
case "FunctionCall":
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var Func = (FunctionCall)Expression;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- foreach (TSqlFragment Parameter in Func.Parameters)
+ var func = (FunctionCall)expression;
+ foreach (TSqlFragment parameter in func.Parameters)
{
- ProcessSelectSetFragment(Parameter, VarName);
+ ProcessSelectSetFragment(parameter, varName);
}
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
break;
case "CastCall":
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var Cast = (CastCall)Expression;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- if (FragmentTypeParser.GetFragmentType(Cast.Parameter) == "VariableReference")
+ var cast = (CastCall)expression;
+ if (FragmentTypeParser.GetFragmentType(cast.Parameter) == "VariableReference")
{
- ProcessVariableReference((VariableReference)Cast.Parameter, VarName);
+ ProcessVariableReference((VariableReference)cast.Parameter, varName);
}
break;
@@ -67,15 +55,11 @@ private void ProcessSelectSetFragment(TSqlFragment Expression, string VarName)
}
}
- public void ProcessSelectSetVariable(SelectSetVariable SelectElement)
+ public void ProcessSelectSetVariable(SelectSetVariable selectElement)
{
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var VarName = SelectElement.Variable.Name;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var Expression = SelectElement.Expression;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- ProcessSelectSetFragment(Expression, VarName);
+ var varName = selectElement.Variable.Name;
+ var expression = selectElement.Expression;
+ ProcessSelectSetFragment(expression, varName);
}
}
}
\ No newline at end of file
diff --git a/SqlServer.TSQLSmells/Processors/SelectStatementProcessor.cs b/SqlServer.TSQLSmells/Processors/SelectStatementProcessor.cs
index 961ce83..ee1b139 100644
--- a/SqlServer.TSQLSmells/Processors/SelectStatementProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/SelectStatementProcessor.cs
@@ -23,36 +23,39 @@ private void ProcessOptimizerHints(IList optimizerHints, SelectSt
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
}
- public void Process(SelectStatement SelStatement, string ParentType, bool TestTop = false,
- WithCtesAndXmlNamespaces Cte = null)
+ public void Process(
+ SelectStatement selStatement,
+ string parentType,
+ bool testTop = false,
+ WithCtesAndXmlNamespaces cte = null)
{
- if (Cte == null && SelStatement.WithCtesAndXmlNamespaces != null)
+ if (cte == null && selStatement.WithCtesAndXmlNamespaces != null)
{
- Cte = SelStatement.WithCtesAndXmlNamespaces;
- if (Cte != null)
+ cte = selStatement.WithCtesAndXmlNamespaces;
+ if (cte != null)
{
- smells.InsertProcessor.ProcessWithCtesAndXmlNamespaces(Cte);
+ smells.InsertProcessor.ProcessWithCtesAndXmlNamespaces(cte);
}
}
- smells.ProcessQueryExpression(SelStatement.QueryExpression, ParentType, false, Cte);
- ProcessOptimizerHints(SelStatement.OptimizerHints, SelStatement);
+ smells.ProcessQueryExpression(selStatement.QueryExpression, parentType, false, cte);
+ ProcessOptimizerHints(selStatement.OptimizerHints, selStatement);
}
- private void ProcessSelectElement(SelectElement SelectElement, string ParentType, WithCtesAndXmlNamespaces Cte)
+ private void ProcessSelectElement(SelectElement selectElement, string parentType, WithCtesAndXmlNamespaces cte)
{
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var ElemType = FragmentTypeParser.GetFragmentType(SelectElement);
+ var ElemType = FragmentTypeParser.GetFragmentType(selectElement);
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
switch (ElemType)
{
case "SelectStarExpression":
- smells.SendFeedBack(5, SelectElement);
+ smells.SendFeedBack(5, selectElement);
break;
case "SelectScalarExpression":
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var ScalarExpression = (SelectScalarExpression)SelectElement;
+ var ScalarExpression = (SelectScalarExpression)selectElement;
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
var ExpressionType = FragmentTypeParser.GetFragmentType(ScalarExpression.Expression);
@@ -63,7 +66,7 @@ private void ProcessSelectElement(SelectElement SelectElement, string ParentType
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
var SubQuery = (ScalarSubquery)ScalarExpression.Expression;
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- smells.ProcessQueryExpression(SubQuery.QueryExpression, ParentType, false, Cte);
+ smells.ProcessQueryExpression(SubQuery.QueryExpression, parentType, false, cte);
break;
case "ColumnReferenceExpression":
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
@@ -81,12 +84,14 @@ private void ProcessSelectElement(SelectElement SelectElement, string ParentType
break;
case "SelectSetVariable":
- smells.SelectSetProcessor.ProcessSelectSetVariable((SelectSetVariable)SelectElement);
+ smells.SelectSetProcessor.ProcessSelectSetVariable((SelectSetVariable)selectElement);
break;
}
}
- public void ProcessSelectElements(IList selectElements, string parentType,
+ public void ProcessSelectElements(
+ IList selectElements,
+ string parentType,
WithCtesAndXmlNamespaces cte)
{
#pragma warning disable SA1312 // Variable names should begin with lower-case letter
@@ -97,9 +102,9 @@ public void ProcessSelectElements(IList selectElements, string pa
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
}
- private void ProcessHint(OptimizerHint Hint, SelectStatement SelStatement)
+ private void ProcessHint(OptimizerHint hint, SelectStatement selStatement)
{
- switch (Hint.HintKind)
+ switch (hint.HintKind)
{
case OptimizerHintKind.OrderGroup:
case OptimizerHintKind.MergeJoin:
@@ -109,7 +114,7 @@ private void ProcessHint(OptimizerHint Hint, SelectStatement SelStatement)
case OptimizerHintKind.HashUnion:
case OptimizerHintKind.MergeUnion:
case OptimizerHintKind.KeepUnion:
- smells.SendFeedBack(4, SelStatement);
+ smells.SendFeedBack(4, selStatement);
break;
}
}
diff --git a/SqlServer.TSQLSmells/Processors/SetProcessor.cs b/SqlServer.TSQLSmells/Processors/SetProcessor.cs
index dbfe207..9075d9e 100644
--- a/SqlServer.TSQLSmells/Processors/SetProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/SetProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,27 +11,25 @@ public SetProcessor(Smells smells)
this.smells = smells;
}
- private void ProcessGeneralSetCommand(GeneralSetCommand SetCommand)
+ private void ProcessGeneralSetCommand(GeneralSetCommand setCommand)
{
- switch (SetCommand.CommandType)
+ switch (setCommand.CommandType)
{
case GeneralSetCommandType.DateFirst:
- smells.SendFeedBack(9, SetCommand);
+ smells.SendFeedBack(9, setCommand);
break;
case GeneralSetCommandType.DateFormat:
- smells.SendFeedBack(8, SetCommand);
+ smells.SendFeedBack(8, setCommand);
break;
}
}
- public void ProcessSetStatement(SetCommandStatement Fragment)
+ public void ProcessSetStatement(SetCommandStatement fragment)
{
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- foreach (GeneralSetCommand SetCommand in Fragment.Commands)
+ foreach (GeneralSetCommand setCommand in fragment.Commands)
{
- ProcessGeneralSetCommand(SetCommand);
+ ProcessGeneralSetCommand(setCommand);
}
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
}
}
}
\ No newline at end of file
diff --git a/SqlServer.TSQLSmells/Processors/SetTransactionIsolationLevelProcessor.cs b/SqlServer.TSQLSmells/Processors/SetTransactionIsolationLevelProcessor.cs
index e122688..afbfe85 100644
--- a/SqlServer.TSQLSmells/Processors/SetTransactionIsolationLevelProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/SetTransactionIsolationLevelProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,12 +11,12 @@ public SetTransactionIsolationLevelProcessor(Smells smells)
this.smells = smells;
}
- public void ProcessSetTransactionIolationLevelStatement(SetTransactionIsolationLevelStatement Statement)
+ public void ProcessSetTransactionIolationLevelStatement(SetTransactionIsolationLevelStatement statement)
{
- switch (Statement.Level)
+ switch (statement.Level)
{
case IsolationLevel.ReadUncommitted:
- smells.SendFeedBack(10, Statement);
+ smells.SendFeedBack(10, statement);
break;
}
}
diff --git a/SqlServer.TSQLSmells/Processors/SqlDataTypeProcessor.cs b/SqlServer.TSQLSmells/Processors/SqlDataTypeProcessor.cs
index 08546f0..b18ea5f 100644
--- a/SqlServer.TSQLSmells/Processors/SqlDataTypeProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/SqlDataTypeProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,20 +11,20 @@ public SqlDataTypeProcessor(Smells smells)
this.smells = smells;
}
- public void ProcessSqlDataTypeReference(SqlDataTypeReference DataType)
+ public void ProcessSqlDataTypeReference(SqlDataTypeReference dataType)
{
- if (DataType.SqlDataTypeOption == SqlDataTypeOption.Table)
+ if (dataType.SqlDataTypeOption == SqlDataTypeOption.Table)
{
}
- switch (DataType.SqlDataTypeOption)
+ switch (dataType.SqlDataTypeOption)
{
case SqlDataTypeOption.Table:
break;
case SqlDataTypeOption.Text:
case SqlDataTypeOption.NText:
case SqlDataTypeOption.Image:
- smells.SendFeedBack(47, DataType);
+ smells.SendFeedBack(47, dataType);
break;
}
}
diff --git a/SqlServer.TSQLSmells/Processors/TableVariableProcessor.cs b/SqlServer.TSQLSmells/Processors/TableVariableProcessor.cs
index 69c78be..9731f1c 100644
--- a/SqlServer.TSQLSmells/Processors/TableVariableProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/TableVariableProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,30 +11,30 @@ public TableVariableProcessor(Smells smells)
this.smells = smells;
}
- public void ProcessTableVariableStatement(DeclareTableVariableStatement Fragment)
+ public void ProcessTableVariableStatement(DeclareTableVariableStatement fragment)
{
- if (Fragment.Body.VariableName.Value.Length <= 2)
+ if (fragment.Body.VariableName.Value.Length <= 2)
{
- smells.SendFeedBack(33, Fragment);
+ smells.SendFeedBack(33, fragment);
}
}
- public void ProcessTableValuedFunctionReturnType(TableValuedFunctionReturnType Fragment)
+ public void ProcessTableValuedFunctionReturnType(TableValuedFunctionReturnType fragment)
{
- smells.ProcessTsqlFragment(Fragment.DeclareTableVariableBody);
+ smells.ProcessTsqlFragment(fragment.DeclareTableVariableBody);
}
- public void ProcessTableVariableBody(DeclareTableVariableBody Fragment)
+ public void ProcessTableVariableBody(DeclareTableVariableBody fragment)
{
- if (Fragment.VariableName.Value.Length <= 2)
+ if (fragment.VariableName.Value.Length <= 2)
{
- smells.SendFeedBack(33, Fragment);
+ smells.SendFeedBack(33, fragment);
}
}
- public void ProcessExistsPredicate(ExistsPredicate ExistsPredicate)
+ public void ProcessExistsPredicate(ExistsPredicate existsPredicate)
{
- smells.ProcessTsqlFragment(ExistsPredicate.Subquery);
+ smells.ProcessTsqlFragment(existsPredicate.Subquery);
}
}
}
\ No newline at end of file
diff --git a/SqlServer.TSQLSmells/Processors/TopProcessor.cs b/SqlServer.TSQLSmells/Processors/TopProcessor.cs
index 028c12e..5cca3c0 100644
--- a/SqlServer.TSQLSmells/Processors/TopProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/TopProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,33 +11,29 @@ public TopProcessor(Smells smells)
this.smells = smells;
}
- public void ProcessTopFilter(TopRowFilter TopFilter)
+ public void ProcessTopFilter(TopRowFilter topFilter)
{
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- IntegerLiteral TopLiteral = null;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- if (FragmentTypeParser.GetFragmentType(TopFilter.Expression) != "ParenthesisExpression")
+ IntegerLiteral topLiteral = null;
+ if (FragmentTypeParser.GetFragmentType(topFilter.Expression) != "ParenthesisExpression")
{
- smells.SendFeedBack(34, TopFilter);
- if (FragmentTypeParser.GetFragmentType(TopFilter.Expression) == "IntegerLiteral")
+ smells.SendFeedBack(34, topFilter);
+ if (FragmentTypeParser.GetFragmentType(topFilter.Expression) == "IntegerLiteral")
{
- TopLiteral = (IntegerLiteral)TopFilter.Expression;
+ topLiteral = (IntegerLiteral)topFilter.Expression;
}
}
else
{
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var ParenthesisExpression = (ParenthesisExpression)TopFilter.Expression;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- if (FragmentTypeParser.GetFragmentType(ParenthesisExpression.Expression) == "IntegerLiteral")
+ var parenthesisExpression = (ParenthesisExpression)topFilter.Expression;
+ if (FragmentTypeParser.GetFragmentType(parenthesisExpression.Expression) == "IntegerLiteral")
{
- TopLiteral = (IntegerLiteral)ParenthesisExpression.Expression;
+ topLiteral = (IntegerLiteral)parenthesisExpression.Expression;
}
}
- if (TopFilter.Percent && TopLiteral != null && TopLiteral.Value == "100")
+ if (topFilter.Percent && topLiteral != null && topLiteral.Value == "100")
{
- smells.SendFeedBack(35, TopLiteral);
+ smells.SendFeedBack(35, topLiteral);
}
}
}
diff --git a/SqlServer.TSQLSmells/Processors/ViewStatementProcessor.cs b/SqlServer.TSQLSmells/Processors/ViewStatementProcessor.cs
index 748b2e0..9e18a71 100644
--- a/SqlServer.TSQLSmells/Processors/ViewStatementProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/ViewStatementProcessor.cs
@@ -1,4 +1,4 @@
-using Microsoft.SqlServer.TransactSql.ScriptDom;
+using Microsoft.SqlServer.TransactSql.ScriptDom;
namespace TSQLSmellSCA
{
@@ -11,18 +11,18 @@ public ViewStatementProcessor(Smells smells)
this.smells = smells;
}
- private void TestViewReference(SchemaObjectName ObjectName)
+ private void TestViewReference(SchemaObjectName objectName)
{
- if (ObjectName.SchemaIdentifier == null)
+ if (objectName.SchemaIdentifier == null)
{
- smells.SendFeedBack(24, ObjectName);
+ smells.SendFeedBack(24, objectName);
}
}
- public void ProcessViewStatementBody(ViewStatementBody StatementBody)
+ public void ProcessViewStatementBody(ViewStatementBody statementBody)
{
- TestViewReference(StatementBody.SchemaObjectName);
- new SelectStatementProcessor(smells).Process(StatementBody.SelectStatement, "VW", true);
+ TestViewReference(statementBody.SchemaObjectName);
+ new SelectStatementProcessor(smells).Process(statementBody.SelectStatement, "VW", true);
}
}
}
\ No newline at end of file
diff --git a/SqlServer.TSQLSmells/Processors/WhereProcessor.cs b/SqlServer.TSQLSmells/Processors/WhereProcessor.cs
index b5bc11a..0d35163 100644
--- a/SqlServer.TSQLSmells/Processors/WhereProcessor.cs
+++ b/SqlServer.TSQLSmells/Processors/WhereProcessor.cs
@@ -11,86 +11,70 @@ public WhereProcessor(Smells smells)
this.smells = smells;
}
- private void ProcessWhereBooleanExpression(BooleanExpression BooleanExpression)
+ private void ProcessWhereBooleanExpression(BooleanExpression booleanExpression)
{
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var ExpressionType = FragmentTypeParser.GetFragmentType(BooleanExpression);
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- switch (ExpressionType)
+ var expressionType = FragmentTypeParser.GetFragmentType(booleanExpression);
+ switch (expressionType)
{
case "BooleanComparisonExpression":
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var BoolComp = (BooleanComparisonExpression)BooleanExpression;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- ProcessWhereScalarExpression(BoolComp.FirstExpression);
- ProcessWhereScalarExpression(BoolComp.SecondExpression);
- if ((BoolComp.ComparisonType == BooleanComparisonType.Equals) &&
- (FragmentTypeParser.GetFragmentType(BoolComp.FirstExpression) == "NullLiteral" ||
- FragmentTypeParser.GetFragmentType(BoolComp.SecondExpression) == "NullLiteral")
+ var boolComp = (BooleanComparisonExpression)booleanExpression;
+ ProcessWhereScalarExpression(boolComp.FirstExpression);
+ ProcessWhereScalarExpression(boolComp.SecondExpression);
+ if ((boolComp.ComparisonType == BooleanComparisonType.Equals) &&
+ (FragmentTypeParser.GetFragmentType(boolComp.FirstExpression) == "NullLiteral" ||
+ FragmentTypeParser.GetFragmentType(boolComp.SecondExpression) == "NullLiteral")
)
{
- smells.SendFeedBack(46, BoolComp);
+ smells.SendFeedBack(46, boolComp);
}
break;
case "BooleanBinaryExpression":
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var BoolExpression = (BooleanBinaryExpression)BooleanExpression;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- ProcessWhereBooleanExpression(BoolExpression.FirstExpression);
- ProcessWhereBooleanExpression(BoolExpression.SecondExpression);
+ var boolExpression = (BooleanBinaryExpression)booleanExpression;
+ ProcessWhereBooleanExpression(boolExpression.FirstExpression);
+ ProcessWhereBooleanExpression(boolExpression.SecondExpression);
break;
default:
break;
}
}
- private void ProcessWhereScalarExpression(ScalarExpression WhereExpression)
+ private void ProcessWhereScalarExpression(ScalarExpression whereExpression)
{
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var ExpressionType = FragmentTypeParser.GetFragmentType(WhereExpression);
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- string ParameterType;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- switch (ExpressionType)
+ var expressionType = FragmentTypeParser.GetFragmentType(whereExpression);
+ string parameterType;
+ switch (expressionType)
{
case "ConvertCall":
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var ConvertCall = (ConvertCall)WhereExpression;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- ParameterType = FragmentTypeParser.GetFragmentType(ConvertCall.Parameter);
- if (ParameterType == "ColumnReferenceExpression")
+ var convertCall = (ConvertCall)whereExpression;
+ parameterType = FragmentTypeParser.GetFragmentType(convertCall.Parameter);
+ if (parameterType == "ColumnReferenceExpression")
{
- smells.SendFeedBack(6, ConvertCall);
+ smells.SendFeedBack(6, convertCall);
}
break;
case "CastCall":
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var CastCall = (CastCall)WhereExpression;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- ParameterType = FragmentTypeParser.GetFragmentType(CastCall.Parameter);
- if (ParameterType == "ColumnReferenceExpression")
+ var castCall = (CastCall)whereExpression;
+ parameterType = FragmentTypeParser.GetFragmentType(castCall.Parameter);
+ if (parameterType == "ColumnReferenceExpression")
{
- smells.SendFeedBack(6, CastCall);
+ smells.SendFeedBack(6, castCall);
}
break;
case "ScalarSubquery":
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var SubQuery = (ScalarSubquery)WhereExpression;
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- smells.ProcessQueryExpression(SubQuery.QueryExpression, "RG");
+ var subQuery = (ScalarSubquery)whereExpression;
+ smells.ProcessQueryExpression(subQuery.QueryExpression, "RG");
break;
}
}
- public void Process(WhereClause WhereClause)
+ public void Process(WhereClause whereClause)
{
- if (WhereClause?.SearchCondition != null)
+ if (whereClause?.SearchCondition != null)
{
- ProcessWhereBooleanExpression(WhereClause.SearchCondition);
+ ProcessWhereBooleanExpression(whereClause.SearchCondition);
}
}
}
diff --git a/SqlServer.TSQLSmells/RuleConstants.cs b/SqlServer.TSQLSmells/RuleConstants.cs
index 4eba390..6a0bf7b 100644
--- a/SqlServer.TSQLSmells/RuleConstants.cs
+++ b/SqlServer.TSQLSmells/RuleConstants.cs
@@ -1,22 +1,3 @@
-//------------------------------------------------------------------------------
-
-//
-// Copyright 2013 Microsoft
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//------------------------------------------------------------------------------
-
namespace TSQLSmellSCA
{
internal static class RuleConstants
diff --git a/SqlServer.TSQLSmells/Smells.cs b/SqlServer.TSQLSmells/Smells.cs
index ffd7741..3b7d992 100644
--- a/SqlServer.TSQLSmells/Smells.cs
+++ b/SqlServer.TSQLSmells/Smells.cs
@@ -9,103 +9,103 @@ namespace TSQLSmellSCA
{
public class Smells
{
- private readonly List _assignmentList = new List();
-
- private int _iRule;
- private TSqlObject _modelElement;
- private List _problems;
- private readonly SelectStatementProcessor _selectStatementProcessor;
- private readonly InsertProcessor _insertProcessor;
- private readonly ExecutableEntityProcessor _executableEntityProcessor;
- private readonly FromProcessor _fromProcessor;
- private readonly WhereProcessor _whereProcessor;
- private readonly OrderByProcessor _orderByProcessor;
- private readonly WhileProcessor _whileProcessor;
- private readonly PredicateSetProcessor _predicateSetProcessor;
- private readonly SetProcessor _setProcessor;
- private readonly FunctionProcessor _functionProcessor;
- private readonly TopProcessor _topProcessor;
- private readonly CreateTableProcessor _createTableProcessor;
- private readonly SelectSetProcessor _selectSetProcessor;
- private readonly SqlDataTypeProcessor _sqlDataTypeProcessor;
- private readonly ViewStatementProcessor _viewStatementProcessor;
- private readonly SetTransactionIsolationLevelProcessor _setTransactionIsolationLevelProcessor;
- private readonly CursorProcessor _cursorProcessor;
- private readonly BeginEndBlockProcessor _beginEndBlockProcessor;
- private readonly SelectFunctionReturnTypeProcessor _selectFunctionReturnTypeProcessor;
- private readonly FunctionStatementBodyProcessor _functionStatementBodyProcessor;
- private readonly ProcedureStatementBodyProcessor _procedureStatementBodyProcessor;
- private readonly IfStatementProcessor _ifStatementProcessor;
- private readonly DeclareVariableProcessor _declareVariableProcessor;
- private readonly TableVariableProcessor _tableVariableProcessor;
- private readonly ReturnStatementProcessor _returnStatementProcessor;
- private readonly ColumnDefinitionProcessor _columnDefinitionProcessor;
+ private readonly List assignmentList = new List();
+
+ private readonly SelectStatementProcessor selectStatementProcessor;
+ private readonly InsertProcessor insertProcessor;
+ private readonly ExecutableEntityProcessor executableEntityProcessor;
+ private readonly FromProcessor fromProcessor;
+ private readonly WhereProcessor whereProcessor;
+ private readonly OrderByProcessor orderByProcessor;
+ private readonly WhileProcessor whileProcessor;
+ private readonly PredicateSetProcessor predicateSetProcessor;
+ private readonly SetProcessor setProcessor;
+ private readonly FunctionProcessor functionProcessor;
+ private readonly TopProcessor topProcessor;
+ private readonly CreateTableProcessor createTableProcessor;
+ private readonly SelectSetProcessor selectSetProcessor;
+ private readonly SqlDataTypeProcessor sqlDataTypeProcessor;
+ private readonly ViewStatementProcessor viewStatementProcessor;
+ private readonly SetTransactionIsolationLevelProcessor setTransactionIsolationLevelProcessor;
+ private readonly CursorProcessor cursorProcessor;
+ private readonly BeginEndBlockProcessor beginEndBlockProcessor;
+ private readonly SelectFunctionReturnTypeProcessor selectFunctionReturnTypeProcessor;
+ private readonly FunctionStatementBodyProcessor functionStatementBodyProcessor;
+ private readonly ProcedureStatementBodyProcessor procedureStatementBodyProcessor;
+ private readonly IfStatementProcessor ifStatementProcessor;
+ private readonly DeclareVariableProcessor declareVariableProcessor;
+ private readonly TableVariableProcessor tableVariableProcessor;
+ private readonly ReturnStatementProcessor returnStatementProcessor;
+ private readonly ColumnDefinitionProcessor columnDefinitionProcessor;
+ private int iRule;
+ private TSqlObject modelElement;
+ private List problems;
public Smells()
{
- _selectStatementProcessor = new SelectStatementProcessor(this);
- _insertProcessor = new InsertProcessor(this);
- _executableEntityProcessor = new ExecutableEntityProcessor(this);
- _fromProcessor = new FromProcessor(this);
- _whereProcessor = new WhereProcessor(this);
- _orderByProcessor = new OrderByProcessor(this);
- _whileProcessor = new WhileProcessor(this);
- _predicateSetProcessor = new PredicateSetProcessor(this);
- _setProcessor = new SetProcessor(this);
- _functionProcessor = new FunctionProcessor(this);
- _topProcessor = new TopProcessor(this);
- _createTableProcessor = new CreateTableProcessor(this);
- _selectSetProcessor = new SelectSetProcessor(this);
- _sqlDataTypeProcessor = new SqlDataTypeProcessor(this);
- _viewStatementProcessor = new ViewStatementProcessor(this);
- _setTransactionIsolationLevelProcessor = new SetTransactionIsolationLevelProcessor(this);
- _cursorProcessor = new CursorProcessor(this);
- _beginEndBlockProcessor = new BeginEndBlockProcessor(this);
- _selectFunctionReturnTypeProcessor = new SelectFunctionReturnTypeProcessor(this);
- _functionStatementBodyProcessor = new FunctionStatementBodyProcessor(this);
- _procedureStatementBodyProcessor = new ProcedureStatementBodyProcessor(this);
- _ifStatementProcessor = new IfStatementProcessor(this);
- _declareVariableProcessor = new DeclareVariableProcessor(this);
- _tableVariableProcessor = new TableVariableProcessor(this);
- _returnStatementProcessor = new ReturnStatementProcessor(this);
- _columnDefinitionProcessor = new ColumnDefinitionProcessor(this);
+ selectStatementProcessor = new SelectStatementProcessor(this);
+ insertProcessor = new InsertProcessor(this);
+ executableEntityProcessor = new ExecutableEntityProcessor(this);
+ fromProcessor = new FromProcessor(this);
+ whereProcessor = new WhereProcessor(this);
+ orderByProcessor = new OrderByProcessor(this);
+ whileProcessor = new WhileProcessor(this);
+ predicateSetProcessor = new PredicateSetProcessor(this);
+ setProcessor = new SetProcessor(this);
+ functionProcessor = new FunctionProcessor(this);
+ topProcessor = new TopProcessor(this);
+ createTableProcessor = new CreateTableProcessor(this);
+ selectSetProcessor = new SelectSetProcessor(this);
+ sqlDataTypeProcessor = new SqlDataTypeProcessor(this);
+ viewStatementProcessor = new ViewStatementProcessor(this);
+ setTransactionIsolationLevelProcessor = new SetTransactionIsolationLevelProcessor(this);
+ cursorProcessor = new CursorProcessor(this);
+ beginEndBlockProcessor = new BeginEndBlockProcessor(this);
+ selectFunctionReturnTypeProcessor = new SelectFunctionReturnTypeProcessor(this);
+ functionStatementBodyProcessor = new FunctionStatementBodyProcessor(this);
+ procedureStatementBodyProcessor = new ProcedureStatementBodyProcessor(this);
+ ifStatementProcessor = new IfStatementProcessor(this);
+ declareVariableProcessor = new DeclareVariableProcessor(this);
+ tableVariableProcessor = new TableVariableProcessor(this);
+ returnStatementProcessor = new ReturnStatementProcessor(this);
+ columnDefinitionProcessor = new ColumnDefinitionProcessor(this);
}
public InsertProcessor InsertProcessor
{
- get { return _insertProcessor; }
+ get { return insertProcessor; }
}
public ExecutableEntityProcessor ExecutableEntityProcessor
{
- get { return _executableEntityProcessor; }
+ get { return executableEntityProcessor; }
}
public FunctionProcessor FunctionProcessor
{
- get { return _functionProcessor; }
+ get { return functionProcessor; }
}
public SelectSetProcessor SelectSetProcessor
{
- get { return _selectSetProcessor; }
+ get { return selectSetProcessor; }
}
#pragma warning disable CA1002 // Do not expose generic lists
public List AssignmentList
#pragma warning restore CA1002 // Do not expose generic lists
{
- get { return _assignmentList; }
+ get { return assignmentList; }
}
public ProcedureStatementBodyProcessor ProcedureStatementBodyProcessor
{
- get { return _procedureStatementBodyProcessor; }
+ get { return procedureStatementBodyProcessor; }
}
public void SendFeedBack(int errorNum, TSqlFragment errorFrg)
{
- if (errorNum != _iRule)
+ if (errorNum != iRule)
{
return;
}
@@ -117,10 +117,13 @@ public void SendFeedBack(int errorNum, TSqlFragment errorFrg)
var Out = rm.GetString(lookup, CultureInfo.InvariantCulture);
#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- _problems.Add(new SqlRuleProblem(Out, _modelElement, errorFrg));
+ problems.Add(new SqlRuleProblem(Out, modelElement, errorFrg));
}
- public void ProcessQueryExpression(QueryExpression queryExpression, string parentType, bool testTop = false,
+ public void ProcessQueryExpression(
+ QueryExpression queryExpression,
+ string parentType,
+ bool testTop = false,
WithCtesAndXmlNamespaces cte = null)
{
var expressionType = FragmentTypeParser.GetFragmentType(queryExpression);
@@ -129,20 +132,20 @@ public void ProcessQueryExpression(QueryExpression queryExpression, string paren
case "QuerySpecification":
// {$Query = $Stmt.QueryExpression;
var querySpec = (QuerySpecification)queryExpression;
- _selectStatementProcessor.ProcessSelectElements(querySpec.SelectElements, parentType, cte);
+ selectStatementProcessor.ProcessSelectElements(querySpec.SelectElements, parentType, cte);
if (querySpec.FromClause != null)
{
- _fromProcessor.Process(querySpec.FromClause, cte);
+ fromProcessor.Process(querySpec.FromClause, cte);
}
if (querySpec.WhereClause != null)
{
- _whereProcessor.Process(querySpec.WhereClause);
+ whereProcessor.Process(querySpec.WhereClause);
}
if (querySpec.OrderByClause != null)
{
- _orderByProcessor.Process(querySpec.OrderByClause);
+ orderByProcessor.Process(querySpec.OrderByClause);
if (parentType == "VW")
{
SendFeedBack(28, querySpec.OrderByClause);
@@ -151,7 +154,7 @@ public void ProcessQueryExpression(QueryExpression queryExpression, string paren
if (querySpec.TopRowFilter != null)
{
- _topProcessor.ProcessTopFilter(querySpec.TopRowFilter);
+ topProcessor.ProcessTopFilter(querySpec.TopRowFilter);
}
break;
@@ -182,38 +185,38 @@ public void ProcessTsqlFragment(TSqlFragment fragment)
switch (stmtType)
{
case "DeclareCursorStatement":
- _cursorProcessor.ProcessCursorStatement((DeclareCursorStatement)fragment);
+ cursorProcessor.ProcessCursorStatement((DeclareCursorStatement)fragment);
break;
case "BeginEndBlockStatement":
- _beginEndBlockProcessor.ProcessBeginEndBlockStatement((BeginEndBlockStatement)fragment);
+ beginEndBlockProcessor.ProcessBeginEndBlockStatement((BeginEndBlockStatement)fragment);
break;
case "CreateFunctionStatement":
case "AlterFunctionStatement":
- _functionStatementBodyProcessor.ProcessFunctionStatementBody((FunctionStatementBody)fragment);
+ functionStatementBodyProcessor.ProcessFunctionStatementBody((FunctionStatementBody)fragment);
break;
case "SelectFunctionReturnType":
- _selectFunctionReturnTypeProcessor.ProcessSelectFunctionReturnType((SelectFunctionReturnType)fragment);
+ selectFunctionReturnTypeProcessor.ProcessSelectFunctionReturnType((SelectFunctionReturnType)fragment);
return;
case "SetTransactionIsolationLevelStatement":
- _setTransactionIsolationLevelProcessor.ProcessSetTransactionIolationLevelStatement((SetTransactionIsolationLevelStatement)fragment);
+ setTransactionIsolationLevelProcessor.ProcessSetTransactionIolationLevelStatement((SetTransactionIsolationLevelStatement)fragment);
break;
case "WhileStatement":
- _whileProcessor.ProcessWhileStatement((WhileStatement)fragment);
+ whileProcessor.ProcessWhileStatement((WhileStatement)fragment);
break;
case "InsertStatement":
InsertProcessor.Process((InsertStatement)fragment);
break;
case "SelectStatement":
- _selectStatementProcessor.Process((SelectStatement)fragment, "RG", true);
+ selectStatementProcessor.Process((SelectStatement)fragment, "RG", true);
break;
case "SetRowCountStatement":
SendFeedBack(42, fragment);
break;
case "IfStatement":
- _ifStatementProcessor.ProcessIfStatement((IfStatement)fragment);
+ ifStatementProcessor.ProcessIfStatement((IfStatement)fragment);
break;
case "PredicateSetStatement":
- _predicateSetProcessor.ProcessPredicateSetStatement((PredicateSetStatement)fragment);
+ predicateSetProcessor.ProcessPredicateSetStatement((PredicateSetStatement)fragment);
break;
case "ExecuteStatement":
ExecutableEntityProcessor.ProcessExecuteStatement((ExecuteStatement)fragment);
@@ -222,21 +225,21 @@ public void ProcessTsqlFragment(TSqlFragment fragment)
SendFeedBack(22, fragment);
break;
case "SetCommandStatement":
- _setProcessor.ProcessSetStatement((SetCommandStatement)fragment);
+ setProcessor.ProcessSetStatement((SetCommandStatement)fragment);
break;
case "CreateTableStatement":
- _createTableProcessor.ProcessCreateTable((CreateTableStatement)fragment);
+ createTableProcessor.ProcessCreateTable((CreateTableStatement)fragment);
break;
case "CreateProcedureStatement":
case "AlterProcedureStatement":
ProcedureStatementBodyProcessor.ProcessProcedureStatementBody((ProcedureStatementBody)fragment);
- _assignmentList.Clear();
+ assignmentList.Clear();
break;
case "CreateViewStatement":
case "AlterViewStatement":
- _viewStatementProcessor.ProcessViewStatementBody((ViewStatementBody)fragment);
+ viewStatementProcessor.ProcessViewStatementBody((ViewStatementBody)fragment);
break;
case "TSqlBatch":
var batch = (TSqlBatch)fragment;
@@ -282,39 +285,39 @@ public void ProcessTsqlFragment(TSqlFragment fragment)
ProcessQueryExpression(scalarSubquery.QueryExpression, "RG");
break;
case "ReturnStatement":
- _returnStatementProcessor.ProcessReturnStatement((ReturnStatement)fragment);
+ returnStatementProcessor.ProcessReturnStatement((ReturnStatement)fragment);
break;
case "IntegerLiteral":
break;
case "DeclareVariableStatement":
- _declareVariableProcessor.ProcessDeclareVariableStatement((DeclareVariableStatement)fragment);
+ declareVariableProcessor.ProcessDeclareVariableStatement((DeclareVariableStatement)fragment);
break;
case "DeclareVariableElement":
- _declareVariableProcessor.ProcessDeclareVariableElement((DeclareVariableElement)fragment);
+ declareVariableProcessor.ProcessDeclareVariableElement((DeclareVariableElement)fragment);
break;
case "PrintStatement":
break;
case "SqlDataTypeReference":
- _sqlDataTypeProcessor.ProcessSqlDataTypeReference((SqlDataTypeReference)fragment);
+ sqlDataTypeProcessor.ProcessSqlDataTypeReference((SqlDataTypeReference)fragment);
break;
case "DeclareTableVariableStatement":
- _tableVariableProcessor.ProcessTableVariableStatement((DeclareTableVariableStatement)fragment);
+ tableVariableProcessor.ProcessTableVariableStatement((DeclareTableVariableStatement)fragment);
break;
case "TableValuedFunctionReturnType":
- _tableVariableProcessor.ProcessTableValuedFunctionReturnType((TableValuedFunctionReturnType)fragment);
+ tableVariableProcessor.ProcessTableValuedFunctionReturnType((TableValuedFunctionReturnType)fragment);
break;
case "DeclareTableVariableBody":
- _tableVariableProcessor.ProcessTableVariableBody((DeclareTableVariableBody)fragment);
+ tableVariableProcessor.ProcessTableVariableBody((DeclareTableVariableBody)fragment);
break;
case "VariableReference":
// ProcessVariableReference((VariableReference)Fragment);
break;
case "ExistsPredicate":
- _tableVariableProcessor.ProcessExistsPredicate((ExistsPredicate)fragment);
+ tableVariableProcessor.ProcessExistsPredicate((ExistsPredicate)fragment);
break;
case "ColumnDefinition":
- _columnDefinitionProcessor.ProcessColumnDefinition((ColumnDefinition)fragment);
+ columnDefinitionProcessor.ProcessColumnDefinition((ColumnDefinition)fragment);
break;
}
}
@@ -324,9 +327,9 @@ public List ProcessObject(TSqlObject sqlObject, int iRule)
#pragma warning restore CA1002 // Do not expose generic lists
{
var problems = new List();
- _problems = problems;
- _modelElement = sqlObject;
- _iRule = iRule;
+ this.problems = problems;
+ modelElement = sqlObject;
+ this.iRule = iRule;
TSqlFragment frg;
if (TSqlModelUtils.TryGetFragmentForAnalysis(sqlObject, out frg))
diff --git a/SqlServer.TSQLSmells/TSQLSmellSCA14.cs b/SqlServer.TSQLSmells/TSQLSmellSCA14.cs
new file mode 100644
index 0000000..45f48fb
--- /dev/null
+++ b/SqlServer.TSQLSmells/TSQLSmellSCA14.cs
@@ -0,0 +1,25 @@
+using System.Collections.Generic;
+using Microsoft.SqlServer.Dac.CodeAnalysis;
+
+namespace TSQLSmellSCA
+{
+ [LocalizedExportCodeAnalysisRule(
+ RuleId,
+ RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
+ RuleConstants.TSQLSmell_RuleName14, // ID used to look up the display name inside the resources file
+ null,
+ Category = RuleConstants.CategorySmells,
+ RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
+ public sealed class TSQLSmellSCA14 : SqlCodeAnalysisRule
+ {
+ public const string RuleId = "Smells.SML014";
+
+ public override IList Analyze(SqlRuleExecutionContext ruleExecutionContext)
+ {
+#pragma warning disable SA1312 // Variable names should begin with lower-case letter
+ var Worker = new TSQLSmellWorker(ruleExecutionContext, RuleId);
+#pragma warning restore SA1312 // Variable names should begin with lower-case letter
+ return Worker.Analyze();
+ }
+ }
+}
diff --git a/SqlServer.TSQLSmells/TSQLSmellSCA15.cs b/SqlServer.TSQLSmells/TSQLSmellSCA15.cs
new file mode 100644
index 0000000..d94adca
--- /dev/null
+++ b/SqlServer.TSQLSmells/TSQLSmellSCA15.cs
@@ -0,0 +1,25 @@
+using System.Collections.Generic;
+using Microsoft.SqlServer.Dac.CodeAnalysis;
+
+namespace TSQLSmellSCA
+{
+ [LocalizedExportCodeAnalysisRule(
+ RuleId,
+ RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
+ RuleConstants.TSQLSmell_RuleName15, // ID used to look up the display name inside the resources file
+ null,
+ Category = RuleConstants.CategorySmells,
+ RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
+ public sealed class TSQLSmellSCA15 : SqlCodeAnalysisRule
+ {
+ public const string RuleId = "Smells.SML015";
+
+ public override IList Analyze(SqlRuleExecutionContext ruleExecutionContext)
+ {
+#pragma warning disable SA1312 // Variable names should begin with lower-case letter
+ var Worker = new TSQLSmellWorker(ruleExecutionContext, RuleId);
+#pragma warning restore SA1312 // Variable names should begin with lower-case letter
+ return Worker.Analyze();
+ }
+ }
+}
diff --git a/SqlServer.TSQLSmells/TSQLSmellSCA16.cs b/SqlServer.TSQLSmells/TSQLSmellSCA16.cs
new file mode 100644
index 0000000..d32f1dd
--- /dev/null
+++ b/SqlServer.TSQLSmells/TSQLSmellSCA16.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using Microsoft.SqlServer.Dac.CodeAnalysis;
+using Microsoft.SqlServer.Dac.Model;
+
+namespace TSQLSmellSCA
+{
+ [LocalizedExportCodeAnalysisRule(
+ RuleId,
+ RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
+ RuleConstants.TSQLSmell_RuleName16, // ID used to look up the display name inside the resources file
+ null,
+ Category = RuleConstants.CategorySmells,
+ RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
+ public sealed class TSQLSmellSCA16 : SqlCodeAnalysisRule
+ {
+ public const string RuleId = "Smells.SML016";
+
+ public override IList Analyze(SqlRuleExecutionContext ruleExecutionContext)
+ {
+#pragma warning disable SA1312 // Variable names should begin with lower-case letter
+ var Worker = new TSQLSmellWorker(ruleExecutionContext, RuleId);
+#pragma warning restore SA1312 // Variable names should begin with lower-case letter
+ return Worker.Analyze();
+ }
+ }
+}
diff --git a/SqlServer.TSQLSmells/TSQLSmellSCA17.cs b/SqlServer.TSQLSmells/TSQLSmellSCA17.cs
new file mode 100644
index 0000000..eb9ca3d
--- /dev/null
+++ b/SqlServer.TSQLSmells/TSQLSmellSCA17.cs
@@ -0,0 +1,25 @@
+using System.Collections.Generic;
+using Microsoft.SqlServer.Dac.CodeAnalysis;
+
+namespace TSQLSmellSCA
+{
+ [LocalizedExportCodeAnalysisRule(
+ RuleId,
+ RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
+ RuleConstants.TSQLSmell_RuleName17, // ID used to look up the display name inside the resources file
+ null,
+ Category = RuleConstants.CategorySmells,
+ RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
+ public sealed class TSQLSmellSCA17 : SqlCodeAnalysisRule
+ {
+ public const string RuleId = "Smells.SML017";
+
+ public override IList Analyze(SqlRuleExecutionContext ruleExecutionContext)
+ {
+#pragma warning disable SA1312 // Variable names should begin with lower-case letter
+ var Worker = new TSQLSmellWorker(ruleExecutionContext, RuleId);
+#pragma warning restore SA1312 // Variable names should begin with lower-case letter
+ return Worker.Analyze();
+ }
+ }
+}
diff --git a/SqlServer.TSQLSmells/TSQLSmellSCA18.cs b/SqlServer.TSQLSmells/TSQLSmellSCA18.cs
new file mode 100644
index 0000000..7a07050
--- /dev/null
+++ b/SqlServer.TSQLSmells/TSQLSmellSCA18.cs
@@ -0,0 +1,25 @@
+using System.Collections.Generic;
+using Microsoft.SqlServer.Dac.CodeAnalysis;
+
+namespace TSQLSmellSCA
+{
+ [LocalizedExportCodeAnalysisRule(
+ RuleId,
+ RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
+ RuleConstants.TSQLSmell_RuleName18, // ID used to look up the display name inside the resources file
+ null,
+ Category = RuleConstants.CategorySmells,
+ RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
+ public sealed class TSQLSmellSCA18 : SqlCodeAnalysisRule
+ {
+ public const string RuleId = "Smells.SML018";
+
+ public override IList Analyze(SqlRuleExecutionContext ruleExecutionContext)
+ {
+#pragma warning disable SA1312 // Variable names should begin with lower-case letter
+ var Worker = new TSQLSmellWorker(ruleExecutionContext, RuleId);
+#pragma warning restore SA1312 // Variable names should begin with lower-case letter
+ return Worker.Analyze();
+ }
+ }
+}
diff --git a/SqlServer.TSQLSmells/TSQLSmellSCA19.cs b/SqlServer.TSQLSmells/TSQLSmellSCA19.cs
new file mode 100644
index 0000000..adbc8ef
--- /dev/null
+++ b/SqlServer.TSQLSmells/TSQLSmellSCA19.cs
@@ -0,0 +1,25 @@
+using System.Collections.Generic;
+using Microsoft.SqlServer.Dac.CodeAnalysis;
+
+namespace TSQLSmellSCA
+{
+ [LocalizedExportCodeAnalysisRule(
+ RuleId,
+ RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
+ RuleConstants.TSQLSmell_RuleName19, // ID used to look up the display name inside the resources file
+ null,
+ Category = RuleConstants.CategorySmells,
+ RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
+ public sealed class TSQLSmellSCA19 : SqlCodeAnalysisRule
+ {
+ public const string RuleId = "Smells.SML019";
+
+ public override IList Analyze(SqlRuleExecutionContext ruleExecutionContext)
+ {
+#pragma warning disable SA1312 // Variable names should begin with lower-case letter
+ var Worker = new TSQLSmellWorker(ruleExecutionContext, RuleId);
+#pragma warning restore SA1312 // Variable names should begin with lower-case letter
+ return Worker.Analyze();
+ }
+ }
+}
diff --git a/SqlServer.TSQLSmells/TSQLSmellWorker.cs b/SqlServer.TSQLSmells/TSQLSmellWorker.cs
index b3189ae..64f93e3 100644
--- a/SqlServer.TSQLSmells/TSQLSmellWorker.cs
+++ b/SqlServer.TSQLSmells/TSQLSmellWorker.cs
@@ -79,8 +79,6 @@ private List DoSmells(TSqlObject sqlObject)
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName01, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA1 : SqlCodeAnalysisRule
@@ -101,8 +99,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName02, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA2 : SqlCodeAnalysisRule
@@ -123,8 +119,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName03, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA3 : SqlCodeAnalysisRule
@@ -145,8 +139,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName04, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA4 : SqlCodeAnalysisRule
@@ -167,8 +159,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName05, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA5 : SqlCodeAnalysisRule
@@ -189,8 +179,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName06, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA6 : SqlCodeAnalysisRule
@@ -211,8 +199,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName07, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA07 : SqlCodeAnalysisRule
@@ -233,8 +219,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName08, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA08 : SqlCodeAnalysisRule
@@ -255,8 +239,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName09, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA09 : SqlCodeAnalysisRule
@@ -277,8 +259,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName10, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA10 : SqlCodeAnalysisRule
@@ -299,8 +279,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName11, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA11 : SqlCodeAnalysisRule
@@ -321,8 +299,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName12, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA12 : SqlCodeAnalysisRule
@@ -343,8 +319,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName13, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA13 : SqlCodeAnalysisRule
@@ -360,145 +334,11 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
}
}
- [LocalizedExportCodeAnalysisRule(
- RuleId,
- RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
- RuleConstants.TSQLSmell_RuleName14, // ID used to look up the display name inside the resources file
- null,
-
- // ID used to look up the description inside the resources file
- Category = RuleConstants.CategorySmells,
- RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
- public sealed class TSQLSmellSCA14 : SqlCodeAnalysisRule
- {
- public const string RuleId = "Smells.SML014";
-
- public override IList Analyze(SqlRuleExecutionContext ruleExecutionContext)
- {
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var Worker = new TSQLSmellWorker(ruleExecutionContext, RuleId);
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- return Worker.Analyze();
- }
- }
-
- [LocalizedExportCodeAnalysisRule(
- RuleId,
- RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
- RuleConstants.TSQLSmell_RuleName15, // ID used to look up the display name inside the resources file
- null,
-
- // ID used to look up the description inside the resources file
- Category = RuleConstants.CategorySmells,
- RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
- public sealed class TSQLSmellSCA15 : SqlCodeAnalysisRule
- {
- public const string RuleId = "Smells.SML015";
-
- public override IList Analyze(SqlRuleExecutionContext ruleExecutionContext)
- {
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var Worker = new TSQLSmellWorker(ruleExecutionContext, RuleId);
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- return Worker.Analyze();
- }
- }
-
- [LocalizedExportCodeAnalysisRule(
- RuleId,
- RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
- RuleConstants.TSQLSmell_RuleName16, // ID used to look up the display name inside the resources file
- null,
-
- // ID used to look up the description inside the resources file
- Category = RuleConstants.CategorySmells,
- RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
- public sealed class TSQLSmellSCA16 : SqlCodeAnalysisRule
- {
- public const string RuleId = "Smells.SML016";
-
- public override IList Analyze(SqlRuleExecutionContext ruleExecutionContext)
- {
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var Worker = new TSQLSmellWorker(ruleExecutionContext, RuleId);
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- return Worker.Analyze();
- }
- }
-
- [LocalizedExportCodeAnalysisRule(
- RuleId,
- RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
- RuleConstants.TSQLSmell_RuleName17, // ID used to look up the display name inside the resources file
- null,
-
- // ID used to look up the description inside the resources file
- Category = RuleConstants.CategorySmells,
- RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
- public sealed class TSQLSmellSCA17 : SqlCodeAnalysisRule
- {
- public const string RuleId = "Smells.SML017";
-
- public override IList Analyze(SqlRuleExecutionContext ruleExecutionContext)
- {
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var Worker = new TSQLSmellWorker(ruleExecutionContext, RuleId);
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- return Worker.Analyze();
- }
- }
-
- [LocalizedExportCodeAnalysisRule(
- RuleId,
- RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
- RuleConstants.TSQLSmell_RuleName18, // ID used to look up the display name inside the resources file
- null,
-
- // ID used to look up the description inside the resources file
- Category = RuleConstants.CategorySmells,
- RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
- public sealed class TSQLSmellSCA18 : SqlCodeAnalysisRule
- {
- public const string RuleId = "Smells.SML018";
-
- public override IList Analyze(SqlRuleExecutionContext ruleExecutionContext)
- {
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var Worker = new TSQLSmellWorker(ruleExecutionContext, RuleId);
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- return Worker.Analyze();
- }
- }
-
- [LocalizedExportCodeAnalysisRule(
- RuleId,
- RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
- RuleConstants.TSQLSmell_RuleName19, // ID used to look up the display name inside the resources file
- null,
-
- // ID used to look up the description inside the resources file
- Category = RuleConstants.CategorySmells,
- RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
- public sealed class TSQLSmellSCA19 : SqlCodeAnalysisRule
- {
- public const string RuleId = "Smells.SML019";
-
- public override IList Analyze(SqlRuleExecutionContext ruleExecutionContext)
- {
-#pragma warning disable SA1312 // Variable names should begin with lower-case letter
- var Worker = new TSQLSmellWorker(ruleExecutionContext, RuleId);
-#pragma warning restore SA1312 // Variable names should begin with lower-case letter
- return Worker.Analyze();
- }
- }
-
[LocalizedExportCodeAnalysisRule(
RuleId,
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName20, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA20 : SqlCodeAnalysisRule
@@ -519,8 +359,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName21, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA21 : SqlCodeAnalysisRule
@@ -541,8 +379,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName22, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA22 : SqlCodeAnalysisRule
@@ -563,8 +399,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName23, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA23 : SqlCodeAnalysisRule
@@ -585,8 +419,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName24, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA24 : SqlCodeAnalysisRule
@@ -607,8 +439,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName25, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA25 : SqlCodeAnalysisRule
@@ -629,8 +459,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName26, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA26 : SqlCodeAnalysisRule
@@ -651,8 +479,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName27, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA27 : SqlCodeAnalysisRule
@@ -673,8 +499,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName28, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA28 : SqlCodeAnalysisRule
@@ -695,8 +519,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName29, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA29 : SqlCodeAnalysisRule
@@ -717,8 +539,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName30, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA30 : SqlCodeAnalysisRule
@@ -739,8 +559,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName31, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA31 : SqlCodeAnalysisRule
@@ -761,8 +579,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName32, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA32 : SqlCodeAnalysisRule
@@ -783,8 +599,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName33, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA33 : SqlCodeAnalysisRule
@@ -805,8 +619,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName34, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA34 : SqlCodeAnalysisRule
@@ -827,8 +639,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName35, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA35 : SqlCodeAnalysisRule
@@ -849,8 +659,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName36, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA36 : SqlCodeAnalysisRule
@@ -871,8 +679,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName37, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA37 : SqlCodeAnalysisRule
@@ -893,8 +699,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName38, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA38 : SqlCodeAnalysisRule
@@ -915,8 +719,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName39, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA39 : SqlCodeAnalysisRule
@@ -937,8 +739,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName40, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA40 : SqlCodeAnalysisRule
@@ -959,8 +759,6 @@ public override IList Analyze(SqlRuleExecutionContext ruleExecut
RuleConstants.ResourceBaseName, // Name of the resource file to look up displayname and description in
RuleConstants.TSQLSmell_RuleName41, // ID used to look up the display name inside the resources file
null,
-
- // ID used to look up the description inside the resources file
Category = RuleConstants.CategorySmells,
RuleScope = SqlRuleScope.Model)] // This rule targets the whole model
public sealed class TSQLSmellSCA41 : SqlCodeAnalysisRule
diff --git a/TSQLSmellsSSDTTest/TestDisabledForeignKeyConstraint.cs b/TSQLSmellsSSDTTest/TestDisabledForeignKeyConstraint.cs
index 46e2119..e9d92af 100644
--- a/TSQLSmellsSSDTTest/TestDisabledForeignKeyConstraint.cs
+++ b/TSQLSmellsSSDTTest/TestDisabledForeignKeyConstraint.cs
@@ -1,4 +1,4 @@
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace TSQLSmellsSSDTTest;
@@ -19,6 +19,4 @@ public void DisabledForeignKeyConstraint()
{
RunTest();
}
-
}
-#pragma warning restore IDE1006 // Naming Styles