Skip to content

Commit

Permalink
Add Resharper InspectCode and CleanupCode Targets (#227)
Browse files Browse the repository at this point in the history
* chore: lint Akka.Persistence.Sql.Tests

* feat: add jetbrains tools

* chore: apply resharper cleanup

* chore: more resharper cleanup

* chore: missing newline

* feat: add linting results to build

* chore: missing resharper cleanup

---------

Co-authored-by: Gregorius Soedharmo <[email protected]>
  • Loading branch information
CumpsD and Arkatufus authored Apr 19, 2023
1 parent 4346859 commit 12c626b
Show file tree
Hide file tree
Showing 186 changed files with 1,148 additions and 1,115 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"jetbrains.resharper.globaltools": {
"version": "2023.1.0",
"commands": [
"jb"
]
}
}
}
7 changes: 7 additions & 0 deletions Akka.Persistence.Sql.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,27 @@
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Akka_002ENET/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="Akka.NET"&gt;&lt;AspOptimizeRegisterDirectives&gt;True&lt;/AspOptimizeRegisterDirectives&gt;&lt;CSReorderTypeMembers&gt;True&lt;/CSReorderTypeMembers&gt;&lt;CSCodeStyleAttributes ArrangeVarStyle="True" ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="True" AddMissingParentheses="True" ArrangeAttributes="True" ArrangeCodeBodyStyle="True" ArrangeTrailingCommas="True" ArrangeObjectCreation="True" ArrangeDefaultValue="True" ArrangeNamespaces="True" /&gt;&lt;CssAlphabetizeProperties&gt;True&lt;/CssAlphabetizeProperties&gt;&lt;JSStringLiteralQuotesDescriptor&gt;True&lt;/JSStringLiteralQuotesDescriptor&gt;&lt;CorrectVariableKindsDescriptor&gt;True&lt;/CorrectVariableKindsDescriptor&gt;&lt;VariablesToInnerScopesDescriptor&gt;True&lt;/VariablesToInnerScopesDescriptor&gt;&lt;StringToTemplatesDescriptor&gt;True&lt;/StringToTemplatesDescriptor&gt;&lt;JsInsertSemicolon&gt;True&lt;/JsInsertSemicolon&gt;&lt;RemoveRedundantQualifiersTs&gt;True&lt;/RemoveRedundantQualifiersTs&gt;&lt;OptimizeImportsTs&gt;True&lt;/OptimizeImportsTs&gt;&lt;OptimizeReferenceCommentsTs&gt;True&lt;/OptimizeReferenceCommentsTs&gt;&lt;PublicModifierStyleTs&gt;True&lt;/PublicModifierStyleTs&gt;&lt;ExplicitAnyTs&gt;True&lt;/ExplicitAnyTs&gt;&lt;TypeAnnotationStyleTs&gt;True&lt;/TypeAnnotationStyleTs&gt;&lt;RelativePathStyleTs&gt;True&lt;/RelativePathStyleTs&gt;&lt;AsInsteadOfCastTs&gt;True&lt;/AsInsteadOfCastTs&gt;&lt;RemoveCodeRedundanciesVB&gt;True&lt;/RemoveCodeRedundanciesVB&gt;&lt;Xaml.RedundantFreezeAttribute&gt;True&lt;/Xaml.RedundantFreezeAttribute&gt;&lt;Xaml.RemoveRedundantModifiersAttribute&gt;True&lt;/Xaml.RemoveRedundantModifiersAttribute&gt;&lt;Xaml.RemoveRedundantNameAttribute&gt;True&lt;/Xaml.RemoveRedundantNameAttribute&gt;&lt;Xaml.RemoveRedundantResource&gt;True&lt;/Xaml.RemoveRedundantResource&gt;&lt;Xaml.RemoveRedundantCollectionProperty&gt;True&lt;/Xaml.RemoveRedundantCollectionProperty&gt;&lt;Xaml.RemoveRedundantAttachedPropertySetter&gt;True&lt;/Xaml.RemoveRedundantAttachedPropertySetter&gt;&lt;Xaml.RemoveRedundantStyledValue&gt;True&lt;/Xaml.RemoveRedundantStyledValue&gt;&lt;Xaml.RemoveRedundantNamespaceAlias&gt;True&lt;/Xaml.RemoveRedundantNamespaceAlias&gt;&lt;Xaml.RemoveForbiddenResourceName&gt;True&lt;/Xaml.RemoveForbiddenResourceName&gt;&lt;Xaml.RemoveRedundantGridDefinitionsAttribute&gt;True&lt;/Xaml.RemoveRedundantGridDefinitionsAttribute&gt;&lt;Xaml.RemoveRedundantUpdateSourceTriggerAttribute&gt;True&lt;/Xaml.RemoveRedundantUpdateSourceTriggerAttribute&gt;&lt;Xaml.RemoveRedundantBindingModeAttribute&gt;True&lt;/Xaml.RemoveRedundantBindingModeAttribute&gt;&lt;Xaml.RemoveRedundantGridSpanAttribut&gt;True&lt;/Xaml.RemoveRedundantGridSpanAttribut&gt;&lt;RemoveCodeRedundancies&gt;True&lt;/RemoveCodeRedundancies&gt;&lt;CSUseAutoProperty&gt;True&lt;/CSUseAutoProperty&gt;&lt;CSMakeFieldReadonly&gt;True&lt;/CSMakeFieldReadonly&gt;&lt;CSMakeAutoPropertyGetOnly&gt;True&lt;/CSMakeAutoPropertyGetOnly&gt;&lt;CSArrangeQualifiers&gt;True&lt;/CSArrangeQualifiers&gt;&lt;CSFixBuiltinTypeReferences&gt;True&lt;/CSFixBuiltinTypeReferences&gt;&lt;CssReformatCode&gt;True&lt;/CssReformatCode&gt;&lt;HtmlReformatCode&gt;True&lt;/HtmlReformatCode&gt;&lt;JsReformatCode&gt;True&lt;/JsReformatCode&gt;&lt;JsFormatDocComments&gt;True&lt;/JsFormatDocComments&gt;&lt;VBOptimizeImports&gt;True&lt;/VBOptimizeImports&gt;&lt;VBShortenReferences&gt;True&lt;/VBShortenReferences&gt;&lt;XMLReformatCode&gt;True&lt;/XMLReformatCode&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;CSharpFormatDocComments&gt;True&lt;/CSharpFormatDocComments&gt;&lt;FormatAttributeQuoteDescriptor&gt;True&lt;/FormatAttributeQuoteDescriptor&gt;&lt;CSUpdateFileHeader&gt;True&lt;/CSUpdateFileHeader&gt;&lt;VBReformatCode&gt;True&lt;/VBReformatCode&gt;&lt;VBFormatDocComments&gt;True&lt;/VBFormatDocComments&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_IFELSE/@EntryValue">RequiredForMultilineStatement</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/CONSTRUCTOR_OR_DESTRUCTOR_BODY/@EntryValue">ExpressionBody</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/FORCE_ATTRIBUTE_STYLE/@EntryValue">Separate</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/LOCAL_FUNCTION_BODY/@EntryValue">ExpressionBody</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/METHOD_OR_OPERATOR_BODY/@EntryValue">ExpressionBody</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/NAMESPACE_BODY/@EntryValue">BlockScoped</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/TRAILING_COMMA_IN_MULTILINE_LISTS/@EntryValue">True</s:Boolean>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_INSIDE_REGION/@EntryValue">0</s:Int64>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/EMPTY_BLOCK_STYLE/@EntryValue">TOGETHER_SAME_LINE</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue">1</s:Int64>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_EMBEDDED_ARRANGEMENT/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/LINE_FEED_AT_FILE_END/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ACCESSOR_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ACCESSORHOLDER_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_EXPR_METHOD_ON_SINGLE_LINE/@EntryValue">NEVER</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_EMBEDDED_STATEMENT_ON_SAME_LINE/@EntryValue">NEVER</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_DECLARATION_LPAR/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_INVOCATION_LPAR/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_ARGUMENTS_STYLE/@EntryValue">CHOP_IF_LONG</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_BEFORE_ARROW_WITH_EXPRESSIONS/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_BEFORE_LINQ_EXPRESSION/@EntryValue">True</s:Boolean>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/@EntryValue">180</s:Int64>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LINQ_EXPRESSIONS/@EntryValue">CHOP_ALWAYS</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_PARAMETERS_STYLE/@EntryValue">CHOP_IF_LONG</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_TERNARY_EXPR_STYLE/@EntryValue">CHOP_ALWAYS</s:String>
Expand Down
37 changes: 36 additions & 1 deletion build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,37 @@ Target "PublishNuget" (fun _ ->
projects |> Seq.iter (runSingleProject)
)

//--------------------------------------------------------------------------------
// JetBrain targets
//--------------------------------------------------------------------------------
Target "InspectCode" (fun _ ->
DotNetCli.RunCommand
(fun p ->
{ p with
TimeOut = TimeSpan.FromMinutes 10. })
"tool restore"

DotNetCli.RunCommand
(fun p ->
{ p with
TimeOut = TimeSpan.FromMinutes 10. })
"dotnet jb inspectcode Akka.Persistence.Sql.sln --build --swea --properties=\"Configuration=Release\" --telemetry-optout --format=\"Html;Xml;Text\" --output=\"TestResults/Akka.Persistence.Sql.jb\""
)

Target "CleanupCode" (fun _ ->
DotNetCli.RunCommand
(fun p ->
{ p with
TimeOut = TimeSpan.FromMinutes 10. })
"tool restore"

DotNetCli.RunCommand
(fun p ->
{ p with
TimeOut = TimeSpan.FromMinutes 10. })
"dotnet jb cleanupcode Akka.Persistence.Sql.sln --profile=\"Akka.NET\" --properties=\"Configuration=Release\" --telemetry-optout"
)

//--------------------------------------------------------------------------------
// Cleanup
//--------------------------------------------------------------------------------
Expand Down Expand Up @@ -213,7 +244,7 @@ Target "All" DoNothing
Target "Nuget" DoNothing

// build dependencies
"Clean" ==> "AssemblyInfo" ==> "Build" ==> "BuildRelease"
"Clean" ==> "AssemblyInfo" ==> "Build" ==> "InspectCode" ==> "BuildRelease"

// tests dependencies
"Build" ==> "RunTests"
Expand All @@ -222,6 +253,10 @@ Target "Nuget" DoNothing
"Clean" ==> "Build" ==> "CreateNuget"
"CreateNuget" ==> "PublishNuget" ==> "Nuget"

// jetbrain dependencies
"InspectCode"
"Build" ==> "CleanupCode"

// all
"BuildRelease" ==> "All"
"RunTests" ==> "All"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ public PostgreSqlJournalPerfSpec(
nameof(PostgreSqlJournalPerfSpec),
output,
40,
TestConstants.DockerNumMessages)
{
}
TestConstants.DockerNumMessages) { }

public static Configuration.Config InitConfig(PostgreSqlContainer fixture)
{
if (!fixture.InitializeDbAsync().Wait(10.Seconds()))
throw new Exception("Failed to clean up database in 10 seconds");

return ConfigurationFactory.ParseString(@$"

return ConfigurationFactory.ParseString(
@$"
akka.persistence {{
publish-plugin-commands = on
journal {{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
// -----------------------------------------------------------------------

using System;
using System.Threading.Tasks;
using Akka.Configuration;
using Akka.Persistence.Sql.Journal;
using Akka.Persistence.Sql.Tests.Common;
using Akka.Persistence.Sql.Tests.Common.Containers;
using FluentAssertions.Extensions;
using LinqToDB;
using Xunit;
using Xunit.Abstractions;

Expand All @@ -28,16 +24,15 @@ public PostgreSqlSqlJournalPerfSpec(
nameof(PostgreSqlSqlJournalPerfSpec),
output,
40,
eventsCount: TestConstants.DockerNumMessages)
{
}
eventsCount: TestConstants.DockerNumMessages) { }

private static Configuration.Config Configuration(PostgreSqlContainer fixture)
{
if (!fixture.InitializeDbAsync().Wait(10.Seconds()))
throw new Exception("Failed to clean up database in 10 seconds");

return ConfigurationFactory.ParseString(@$"

return ConfigurationFactory.ParseString(
@$"
akka.persistence {{
publish-plugin-commands = on
journal {{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using Akka.TestKit;
using Akka.Util;
using Akka.Util.Internal;
using FluentAssertions.Extensions;
using JetBrains.dotMemoryUnit;
using JetBrains.dotMemoryUnit.Kernel;
using Xunit;
Expand Down Expand Up @@ -64,9 +63,10 @@ internal IActorRef BenchActor(string pid, int replyAfter)
internal (IActorRef aut, TestProbe probe) BenchActorNewProbeGroup(string pid, int numActors, int numMessages)
{
var tp = CreateTestProbe();
return (Sys.ActorOf(Props
.Create(() => new BenchActor(pid, tp, numMessages, false))
.WithRouter(new RoundRobinPool(numActors))), tp);
return (Sys.ActorOf(
Props
.Create(() => new BenchActor(pid, tp, numMessages, false))
.WithRouter(new RoundRobinPool(numActors))), tp);
}

internal void FeedAndExpectLastRouterSet(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ public BatchingSqlServerJournalPerfSpec(ITestOutputHelper output, SqlServerConta
nameof(BatchingSqlServerJournalPerfSpec),
output,
40,
TestConstants.DockerNumMessages)
{
}
TestConstants.DockerNumMessages) { }

public static Configuration.Config Configure(SqlServerContainer fixture)
{
if (!fixture.InitializeDbAsync().Wait(10.Seconds()))
throw new Exception("Failed to clean up database in 10 seconds");

return ConfigurationFactory.ParseString(@$"

return ConfigurationFactory.ParseString(
@$"
akka.persistence {{
publish-plugin-commands = on
journal {{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ public SqlServerJournalPerfSpec(ITestOutputHelper output, SqlServerContainer fix
nameof(SqlServerJournalPerfSpec),
output,
40,
eventsCount: TestConstants.DockerNumMessages)
{
}
eventsCount: TestConstants.DockerNumMessages) { }

private static Configuration.Config Configuration(SqlServerContainer fixture)
{
if (!fixture.InitializeDbAsync().Wait(10.Seconds()))
throw new Exception("Failed to clean up database in 10 seconds");

return ConfigurationFactory.ParseString(@$"

return ConfigurationFactory.ParseString(
@$"
akka.persistence {{
publish-plugin-commands = on
journal {{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ public SqlServerLinq2DbJournalPerfSpec(ITestOutputHelper output, SqlServerContai
nameof(SqlServerLinq2DbJournalPerfSpec),
output,
40,
eventsCount: TestConstants.DockerNumMessages)
{
}
eventsCount: TestConstants.DockerNumMessages) { }

private static Configuration.Config Configure(SqlServerContainer fixture)
{
if (!fixture.InitializeDbAsync().Wait(10.Seconds()))
throw new Exception("Failed to clean up database in 10 seconds");

return ConfigurationFactory.ParseString(@$"
return ConfigurationFactory.ParseString(
@$"
akka.persistence {{
publish-plugin-commands = on
journal {{
Expand All @@ -49,7 +48,8 @@ private static Configuration.Config Configure(SqlServerContainer fixture)
}}
}}
}}")
.WithFallback(SqlPersistence.DefaultConfiguration); }
.WithFallback(SqlPersistence.DefaultConfiguration);
}

[Fact]
public void PersistenceActor_Must_measure_PersistGroup1000()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ public MsSqliteJournalPerfSpec(ITestOutputHelper output, MsSqliteContainer fixtu
CreateSpecConfig(fixture),
nameof(MsSqliteJournalPerfSpec),
output,
eventsCount: TestConstants.NumMessages)
{
}
eventsCount: TestConstants.NumMessages) { }

private static Configuration.Config CreateSpecConfig(MsSqliteContainer fixture)
{
if (!fixture.InitializeDbAsync().Wait(10.Seconds()))
throw new Exception("Failed to clean up database in 10 seconds");

return ConfigurationFactory.ParseString(@$"
return ConfigurationFactory.ParseString(
@$"
akka.persistence {{
publish-plugin-commands = on
journal {{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

using Akka.Persistence.Sql.Tests.Common.Containers;
using Akka.Persistence.Sql.Tests.Sqlite;
using LinqToDB;
using Xunit;
using Xunit.Abstractions;

Expand All @@ -20,8 +19,6 @@ public MsSqliteLinq2DbJournalPerfSpec(ITestOutputHelper output, MsSqliteContaine
SqliteJournalSpecConfig.Create(fixture),
nameof(MsSqliteLinq2DbJournalPerfSpec),
output,
eventsCount: TestConstants.NumMessages)
{
}
eventsCount: TestConstants.NumMessages) { }
}
}
14 changes: 7 additions & 7 deletions src/Akka.Persistence.Sql.Benchmarks/Configurations/Configs.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//-----------------------------------------------------------------------
// <copyright file="Configs.cs" company="Akka.NET Project">
// Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// <copyright file="Configs.cs" company="Akka.NET Project">
// Copyright (C) 2013-2023 .NET Foundation <https://github.com/akkadotnet/akka.net>
// </copyright>
// -----------------------------------------------------------------------

using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
Expand All @@ -12,7 +12,7 @@
namespace Akka.Persistence.Sql.Benchmarks.Configurations
{
/// <summary>
/// Basic BenchmarkDotNet configuration used for micro benchmarks.
/// Basic BenchmarkDotNet configuration used for micro benchmarks.
/// </summary>
public class MicroBenchmarkConfig : ManualConfig
{
Expand All @@ -25,7 +25,7 @@ public MicroBenchmarkConfig()
}

/// <summary>
/// BenchmarkDotNet configuration used for monitored jobs (not for micro benchmarks).
/// BenchmarkDotNet configuration used for monitored jobs (not for micro benchmarks).
/// </summary>
public class MonitoringConfig : ManualConfig
{
Expand Down
1 change: 0 additions & 1 deletion src/Akka.Persistence.Sql.Benchmarks/DebuggingHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Diagnostics;
using Akka.Event;
using LinqToDB.Data;
using Xunit.Abstractions;

namespace Akka.Persistence.Sql.Benchmarks
{
Expand Down
3 changes: 1 addition & 2 deletions src/Akka.Persistence.Sql.Benchmarks/EventTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// </copyright>
// -----------------------------------------------------------------------

using System.Collections.Generic;
using Akka.Persistence.Journal;

namespace Akka.Persistence.Sql.Benchmarks
Expand All @@ -25,7 +24,7 @@ public object ToJournal(object evt)
<= Const.Tag100UpperBound => new Tagged(evt, new[] { Const.Tag100, Const.Tag1000, Const.Tag10000 }),
<= Const.Tag1000UpperBound => new Tagged(evt, new[] { Const.Tag1000, Const.Tag10000 }),
<= Const.Tag10000UpperBound => new Tagged(evt, new[] { Const.Tag10000 }),
_ => evt
_ => evt,
};
}
}
Expand Down
Loading

0 comments on commit 12c626b

Please sign in to comment.