-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Effective C# analyzers and update SquiggleCop baselines #182
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4b88de0
Add Effective C# analyzers and update SquiggleCop baselines
rjmurillo 173b2f8
Update Effective C# Analyzers
rjmurillo 7f203bf
Update SquiggleCop baseline
rjmurillo dc8369f
Update .globalconfig to set effective C# analyzer to warning
rjmurillo cf7d89a
Fix code analysis warnings
rjmurillo 2937b48
Update SquiggleCop baseline
rjmurillo 968084a
Disable ECS analyzers for tools project
rjmurillo edac8dd
Merge branch 'main' into feature/add-effective-csharp-analyzers
rjmurillo e18ee47
Update to latest Effective C# analyzers package
rjmurillo af7ebf3
Update code for analyzers and squigglecop baseline
rjmurillo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using ArgumentOutOfRangeException = System.ArgumentOutOfRangeException; | ||
|
||
namespace Moq.Analyzers.Common; | ||
|
||
internal static class ArrayExtensions | ||
{ | ||
/// <summary> | ||
/// Returns an array with the element at the specified position removed. | ||
/// </summary> | ||
/// <typeparam name="T">The array type.</typeparam> | ||
/// <param name="array">The array.</param> | ||
/// <param name="index">The 0-based index into the array for the element to omit from the returned array.</param> | ||
/// <returns>The new array.</returns> | ||
internal static T[] RemoveAt<T>(this T[] array, int index) | ||
{ | ||
return RemoveRange(array, index, 1); | ||
} | ||
|
||
/// <summary> | ||
/// Returns an array with the elements at the specified position removed. | ||
/// </summary> | ||
/// <typeparam name="T">The array type.</typeparam> | ||
/// <param name="array">The array.</param> | ||
/// <param name="index">The 0-based index into the array for the element to omit from the returned array.</param> | ||
/// <param name="length">The number of elements to remove.</param> | ||
/// <returns>The new array.</returns> | ||
private static T[] RemoveRange<T>(this T[] array, int index, int length) | ||
{ | ||
// Range check | ||
if (index < 0 || index >= array.Length) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(index)); | ||
} | ||
|
||
if (length < 0 || index + length > array.Length) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(length)); | ||
} | ||
|
||
#pragma warning disable S2583 // Change condition so it doesn't always evaluate to false | ||
if (array.Length == 0) | ||
#pragma warning restore S2583 | ||
{ | ||
return array; | ||
} | ||
|
||
T[] tmp = new T[array.Length - length]; | ||
Array.Copy(array, tmp, index); | ||
Array.Copy(array, index + length, tmp, index, array.Length - index - length); | ||
|
||
return tmp; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
namespace Moq.Analyzers.Common; | ||
|
||
#pragma warning disable ECS0200 // Consider using readonly instead of const for flexibility | ||
|
||
internal static class WellKnownTypeNames | ||
{ | ||
internal const string Moq = "Moq"; | ||
internal const string Moq = nameof(Moq); | ||
internal const string MockName = "Mock"; | ||
internal const string MockBehavior = "MockBehavior"; | ||
internal const string MockFactory = "MockFactory"; | ||
internal const string MockBehavior = nameof(MockBehavior); | ||
internal const string MockFactory = nameof(MockFactory); | ||
internal const string MoqMock = $"{Moq}.{MockName}"; | ||
internal const string MoqMock1 = $"{MoqMock}`1"; | ||
internal const string MoqBehavior = $"{Moq}.{MockBehavior}"; | ||
internal const string MoqRepository = $"{Moq}.MockRepository"; | ||
internal const string As = "As"; | ||
internal const string Create = "Create"; | ||
internal const string Of = "Of"; | ||
internal const string As = nameof(As); | ||
internal const string Create = nameof(Create); | ||
internal const string Of = nameof(Of); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected tabs found.