Add linting for copyright and unused usings (#1416)

* Add linting for copyright and unused usings

* Add one more + comment

* Enforce in build and fix errors

* Fix build
This commit is contained in:
Charles Gagnon
2022-03-04 15:17:29 -08:00
committed by GitHub
parent 025f9af4fd
commit c248400a6c
233 changed files with 1323 additions and 364 deletions

View File

@@ -1,6 +1,7 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
@@ -13,7 +14,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
/// </summary>
public static class CommonUtil
{
private const int KeyValueNameLength = 1024; // 1024 should be enough for registry key value name.
private const int KeyValueNameLength = 1024; // 1024 should be enough for registry key value name.
//********************************************************************************************
/// <summary>
@@ -44,7 +45,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
//********************************************************************************************
/// <summary>
/// Throw an exception if a string is null or empty.
/// Throw an exception if a string is null or empty.
/// </summary>
/// <param name="stringVar">string to check</param>
/// <param name="stringVarName">the variable or parameter name to display</param>
@@ -97,6 +98,6 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
return message;
}
}
}

View File

@@ -1,6 +1,7 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
namespace Microsoft.SqlTools.ResourceProvider.Core
{

View File

@@ -1,6 +1,7 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Data.Common;
@@ -18,7 +19,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
/// Returns true if given exception if any of the inner exceptions is UserNeedsAuthenticationException
/// </summary>
internal static bool IsUserNeedsReauthenticateException(this Exception ex)
{
{
return ex.IsExceptionType(typeof(UserNeedsAuthenticationException));
}

View File

@@ -1,6 +1,7 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Runtime.Serialization;
@@ -8,7 +9,7 @@ using System.Runtime.Serialization;
namespace Microsoft.SqlTools.ResourceProvider.Core
{
/// <summary>
/// The exception is used if any operation fails as a request failed due to an expired token
/// The exception is used if any operation fails as a request failed due to an expired token
/// </summary>
public class ExpiredTokenException : ServiceExceptionBase
{
@@ -29,11 +30,11 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
}
/// <summary>
/// Initializes a new instance of the ServiceFailedException class with a specified error message
/// Initializes a new instance of the ServiceFailedException class with a specified error message
/// and a reference to the inner exception that is the cause of this exception.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception. </param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
/// (Nothing in Visual Basic) if no inner exception is specified</param>
public ExpiredTokenException(string message, Exception innerException)
: base(message, innerException)

View File

@@ -35,11 +35,11 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
/// </summary>
/// <param name="message">The error message that explains the reason for the exception. </param>
/// <param name="httpStatusCode">The Http error code. </param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
/// (Nothing in Visual Basic) if no inner exception is specified</param>
public ServiceExceptionBase(string message, HttpStatusCode httpStatusCode, Exception innerException = null)
: this(message, (int)httpStatusCode, innerException)
{
{
}
/// <summary>
@@ -47,7 +47,7 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
/// </summary>
/// <param name="message">The error message that explains the reason for the exception. </param>
/// <param name="httpStatusCode">The Http error code. </param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
/// (Nothing in Visual Basic) if no inner exception is specified</param>
public ServiceExceptionBase(string message, int httpStatusCode, Exception innerException)
: base(message, innerException)
@@ -57,11 +57,11 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
}
/// <summary>
/// Initializes a new instance of the AuthenticationFailedException class with a specified error message
/// Initializes a new instance of the AuthenticationFailedException class with a specified error message
/// and a reference to the inner exception that is the cause of this exception.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception. </param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
/// (Nothing in Visual Basic) if no inner exception is specified</param>
protected ServiceExceptionBase(string message, Exception innerException)
: base(message, innerException)

View File

@@ -32,11 +32,11 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
}
/// <summary>
/// Initializes a new instance of the ServiceFailedException class with a specified error message
/// Initializes a new instance of the ServiceFailedException class with a specified error message
/// and a reference to the inner exception that is the cause of this exception.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception. </param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
/// (Nothing in Visual Basic) if no inner exception is specified</param>
public ServiceFailedException(string message, Exception innerException)
: base(message, innerException)
@@ -54,13 +54,13 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
}
/// <summary>
/// Creates a new instance of ServiceFailedException by adding the server definition info to the given message
/// Creates a new instance of ServiceFailedException by adding the server definition info to the given message
/// </summary>
internal static ServiceFailedException CreateException(string message, ServerDefinition serverDefinition, Exception innerException)
{
return new ServiceFailedException(
string.Format(CultureInfo.CurrentCulture, message,
serverDefinition != null ? serverDefinition.ServerType : string.Empty,
string.Format(CultureInfo.CurrentCulture, message,
serverDefinition != null ? serverDefinition.ServerType : string.Empty,
serverDefinition != null ? serverDefinition.Category : string.Empty), innerException);
}
}

View File

@@ -1,6 +1,7 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
using System.Runtime.Serialization;
@@ -8,7 +9,7 @@ using System.Runtime.Serialization;
namespace Microsoft.SqlTools.ResourceProvider.Core
{
/// <summary>
/// The exception is used if any operation fails becauase user needs to reauthenticate
/// The exception is used if any operation fails becauase user needs to reauthenticate
/// </summary>
public class UserNeedsAuthenticationException : ServiceExceptionBase
{
@@ -29,11 +30,11 @@ namespace Microsoft.SqlTools.ResourceProvider.Core
}
/// <summary>
/// Initializes a new instance of the ServiceFailedException class with a specified error message
/// Initializes a new instance of the ServiceFailedException class with a specified error message
/// and a reference to the inner exception that is the cause of this exception.
/// </summary>
/// <param name="message">The error message that explains the reason for the exception. </param>
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference
/// (Nothing in Visual Basic) if no inner exception is specified</param>
public UserNeedsAuthenticationException(string message, Exception innerException)
: base(message, innerException)