-
Notifications
You must be signed in to change notification settings - Fork 660
Add Microsoft static code analyzers #2761
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
01372c5
Add Microsoft.CodeAnalysis.CSharp.CodeStyle
Evangelink b78f5aa
Add default .editorconfig options for C# code style
Evangelink 2a8204b
Enforce `this.` qualifier for fields
Evangelink 95448c5
Prefer expression body
Evangelink c9b43b7
Expression body for ctor
Evangelink 4f3b8a1
Expression body for lambdas
Evangelink e9bc23b
Expression body for operators
Evangelink cdebf87
Add missing accessibilities
Evangelink 19a387d
Make fields readonly
Evangelink c48599e
Disable warning for braces for ifs (IDE0011)
Evangelink 737f624
IDE0090 use new(...) syntax
Evangelink 0ff7037
IDE0041: Use 'is null' check
Evangelink 669320f
Add Microsoft.CodeAnalysis.NetAnalyzers
Evangelink d3517b0
CA1825: Avoid zero-length array allocations
Evangelink 3452926
CA1822: Mark members as static
Evangelink dfd39e8
CA2208: Instantiate argument exceptions correctly
Evangelink 3e90f20
Fix formatting
Evangelink 3fee4c1
Extract the analyzers into Directory.Build.props
Evangelink 495a699
Remove underscore prefix for fields
Evangelink 5aa0803
Run dotnet format command
Evangelink e20a0ef
Fix formatting issues
Evangelink 27e394a
Fix some formatting issues
Evangelink a7584a4
Fix more alignment
Evangelink abed44c
Expression body for property, accessor and indexer
Evangelink 3685fbf
Fix field name in reflection
Evangelink 8093bf1
Add missing `this.` prefix
Evangelink 63dac65
Post rebase cleanup
Evangelink f6bc602
Fix using order
Evangelink 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -9,7 +9,7 @@ namespace GitTools.Testing | |
/// </summary> | ||
public abstract class RepositoryFixtureBase : IDisposable | ||
{ | ||
readonly SequenceDiagram _sequenceDiagram; | ||
private readonly SequenceDiagram sequenceDiagram; | ||
|
||
protected RepositoryFixtureBase(Func<string, IRepository> repoBuilder) | ||
: this(repoBuilder(PathHelper.GetTempPath())) | ||
|
@@ -18,23 +18,17 @@ protected RepositoryFixtureBase(Func<string, IRepository> repoBuilder) | |
|
||
protected RepositoryFixtureBase(IRepository repository) | ||
{ | ||
_sequenceDiagram = new SequenceDiagram(); | ||
this.sequenceDiagram = new SequenceDiagram(); | ||
Repository = repository; | ||
Repository.Config.Set("user.name", "Test"); | ||
Repository.Config.Set("user.email", "[email protected]"); | ||
} | ||
|
||
public IRepository Repository { get; } | ||
|
||
public string RepositoryPath | ||
{ | ||
get { return Repository.Info.WorkingDirectory.TrimEnd('\\'); } | ||
} | ||
public string RepositoryPath => Repository.Info.WorkingDirectory.TrimEnd('\\'); | ||
|
||
public SequenceDiagram SequenceDiagram | ||
{ | ||
get { return _sequenceDiagram; } | ||
} | ||
public SequenceDiagram SequenceDiagram => this.sequenceDiagram; | ||
|
||
/// <summary> | ||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. | ||
|
@@ -53,21 +47,15 @@ public virtual void Dispose() | |
e.Message); | ||
} | ||
|
||
_sequenceDiagram.End(); | ||
this.sequenceDiagram.End(); | ||
Console.WriteLine("**Visualisation of test:**"); | ||
Console.WriteLine(string.Empty); | ||
Console.WriteLine(_sequenceDiagram.GetDiagram()); | ||
Console.WriteLine(this.sequenceDiagram.GetDiagram()); | ||
} | ||
|
||
public void Checkout(string branch) | ||
{ | ||
Commands.Checkout(Repository, branch); | ||
} | ||
public void Checkout(string branch) => Commands.Checkout(Repository, branch); | ||
|
||
public static void Init(string path) | ||
{ | ||
GitTestExtensions.ExecuteGitCmd($"init {path} -b main"); | ||
} | ||
public static void Init(string path) => GitTestExtensions.ExecuteGitCmd($"init {path} -b main"); | ||
|
||
public void MakeATaggedCommit(string tag) | ||
{ | ||
|
@@ -77,28 +65,28 @@ public void MakeATaggedCommit(string tag) | |
|
||
public void ApplyTag(string tag) | ||
{ | ||
_sequenceDiagram.ApplyTag(tag, Repository.Head.FriendlyName); | ||
this.sequenceDiagram.ApplyTag(tag, Repository.Head.FriendlyName); | ||
Repository.ApplyTag(tag); | ||
} | ||
|
||
public void BranchTo(string branchName, string @as = null) | ||
{ | ||
_sequenceDiagram.BranchTo(branchName, Repository.Head.FriendlyName, @as); | ||
this.sequenceDiagram.BranchTo(branchName, Repository.Head.FriendlyName, @as); | ||
var branch = Repository.CreateBranch(branchName); | ||
Commands.Checkout(Repository, branch); | ||
} | ||
|
||
public void BranchToFromTag(string branchName, string fromTag, string onBranch, string @as = null) | ||
{ | ||
_sequenceDiagram.BranchToFromTag(branchName, fromTag, onBranch, @as); | ||
this.sequenceDiagram.BranchToFromTag(branchName, fromTag, onBranch, @as); | ||
var branch = Repository.CreateBranch(branchName); | ||
Commands.Checkout(Repository, branch); | ||
} | ||
|
||
public void MakeACommit() | ||
{ | ||
var to = Repository.Head.FriendlyName; | ||
_sequenceDiagram.MakeACommit(to); | ||
this.sequenceDiagram.MakeACommit(to); | ||
Repository.MakeACommit(); | ||
} | ||
|
||
|
@@ -107,7 +95,7 @@ public void MakeACommit() | |
/// </summary> | ||
public void MergeNoFF(string mergeSource) | ||
{ | ||
_sequenceDiagram.Merge(mergeSource, Repository.Head.FriendlyName); | ||
this.sequenceDiagram.Merge(mergeSource, Repository.Head.FriendlyName); | ||
Repository.MergeNoFF(mergeSource, Generate.SignatureNow()); | ||
} | ||
|
||
|
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.
There is no analyzer to help with this kind of formatting. I will make the changes manually, just let me know your preference between:
=>
=>
(that's the one I usually go for but that's purely personal)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.
3