Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
halgari committed Feb 21, 2024
1 parent 2ae09a0 commit 0d01177
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 24 deletions.
2 changes: 2 additions & 0 deletions qodana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ dotnet:
solution: NexusMods.EventSourcing.sln
profile:
name: qodana.recommended
exclude:
- name: ClassNeverInstantiated.Global
2 changes: 1 addition & 1 deletion src/NexusMods.EventSourcing.Abstractions/Symbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private Symbol(string nsAndName)
Namespace = nsAndName[..splitOn];
}

private static ConcurrentDictionary<string, Symbol> _internedSymbols = new();
private static readonly ConcurrentDictionary<string, Symbol> _internedSymbols = new();

Check warning on line 24 in src/NexusMods.EventSourcing.Abstractions/Symbol.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Inconsistent Naming

Name '_internedSymbols' does not match rule 'Static readonly fields (private)'. Suggested name is 'InternedSymbols'.

/// <summary>
/// Construct a new symbol, or return an existing one that matches the given name
Expand Down
12 changes: 6 additions & 6 deletions src/NexusMods.EventSourcing.DatomStore/BuiltInAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public class UniqueId() : ScalarAttribute<UniqueId, Symbol>(UniqueIdStaticId);
/// <summary>
/// Static unique id of the UniqueId attribute
/// </summary>
public static Symbol UniqueIdStaticId = Symbol.Intern("NexusMods.EventSourcing.DatomStore/UniqueId");
public static readonly Symbol UniqueIdStaticId = Symbol.Intern("NexusMods.EventSourcing.DatomStore/UniqueId");

Check notice on line 18 in src/NexusMods.EventSourcing.DatomStore/BuiltInAttributes.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Member can be made private: Non-private accessibility

Field 'UniqueIdStaticId' can be made private

/// <summary>
/// The database entity id of the UniqueId attribute
/// </summary>
public static ulong UniqueIdEntityId = 1;
public static readonly ulong UniqueIdEntityId = 1;

Check notice on line 23 in src/NexusMods.EventSourcing.DatomStore/BuiltInAttributes.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Member can be made private: Non-private accessibility

Field 'UniqueIdEntityId' can be made private

/// <summary>
/// The unique id if the IValueSerializer used to serialize the value of the attribute.
Expand All @@ -30,23 +30,23 @@ public class ValueSerializerId() : ScalarAttribute<ValueSerializerId, UInt128>("
/// <summary>
/// Static unique id of the UniqueId attribute
/// </summary>
public static Symbol ValueSerializerIdStaticId = Symbol.Intern("NexusMods.EventSourcing.DatomStore/ValueSerializerId");
public static readonly Symbol ValueSerializerIdStaticId = Symbol.Intern("NexusMods.EventSourcing.DatomStore/ValueSerializerId");

Check notice on line 33 in src/NexusMods.EventSourcing.DatomStore/BuiltInAttributes.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Member can be made private: Non-private accessibility

Field 'ValueSerializerIdStaticId' can be made private

/// <summary>
/// The database entity id of the UniqueId attribute
/// </summary>
public static ulong ValueSerializerIdEntityId = 2;
public static readonly ulong ValueSerializerIdEntityId = 2;

Check notice on line 38 in src/NexusMods.EventSourcing.DatomStore/BuiltInAttributes.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Member can be made private: Non-private accessibility

Field 'ValueSerializerIdEntityId' can be made private


/// <summary>
/// The initial set of built-in attributes that always exist in the database.
/// </summary>
public static DbAttribute[] Initial = [
public static readonly DbAttribute[] Initial = [
new DbAttribute(UniqueIdStaticId, UniqueIdEntityId, UInt128Serializer.Id),
new DbAttribute(ValueSerializerIdStaticId, ValueSerializerIdEntityId, UInt128Serializer.Id),
];

public static IDatom[] InitialDatoms = [
public static readonly IDatom[] InitialDatoms = [
UniqueId.Assert(UniqueIdEntityId, UniqueIdStaticId),
ValueSerializerId.Assert(UniqueIdEntityId, UInt128Serializer.Id),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace NexusMods.EventSourcing.DatomStore;

public class RocksDBDatomStore : IDatomStore

Check warning on line 13 in src/NexusMods.EventSourcing.DatomStore/RocksDBDatomStore.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Inconsistent Naming

Name 'RocksDBDatomStore' does not match rule 'Types and namespaces'. Suggested name is 'RocksDbDatomStore'.
{
private object _lock = new();
private readonly object _lock = new();
private readonly ILogger<RocksDBDatomStore> _logger;

Check warning on line 16 in src/NexusMods.EventSourcing.DatomStore/RocksDBDatomStore.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Non-accessed field: Private accessibility

Field '_logger' is assigned but its value is never used
private readonly DatomStoreSettings _settings;

Check warning on line 17 in src/NexusMods.EventSourcing.DatomStore/RocksDBDatomStore.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Private field can be converted into local variable

The field is always assigned before being used and can be converted into a local variable
private readonly DbOptions _options;

Check warning on line 18 in src/NexusMods.EventSourcing.DatomStore/RocksDBDatomStore.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Private field can be converted into local variable

The field is always assigned before being used and can be converted into a local variable
Expand Down
4 changes: 2 additions & 2 deletions src/NexusMods.EventSourcing/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace NexusMods.EventSourcing;
public class Transaction(Connection connection) : ITransaction

Check warning on line 8 in src/NexusMods.EventSourcing/Transaction.cs

View workflow job for this annotation

GitHub Actions / Qodana Community for .NET

Missing XML comment for publicly visible type or member

Missing XML comment for publicly visible type or member 'NexusMods.EventSourcing.Transaction'
{
private ulong _tempId = Ids.MinId(Ids.Partition.Tmp) + 1;
private ConcurrentBag<IDatom> _datoms = new();
private ConcurrentBag<IReadModel> _models = new();
private readonly ConcurrentBag<IDatom> _datoms = new();
private readonly ConcurrentBag<IReadModel> _models = new();

/// <inhertdoc />
public EntityId TempId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

namespace NexusMods.EventSourcing.DatomStore.Tests;

public class DatomStoreSetupTests : ADatomStoreTest
public class DatomStoreSetupTests(IEnumerable<IValueSerializer> valueSerializers, IEnumerable<IAttribute> attributes)
: ADatomStoreTest(valueSerializers, attributes)
{
public DatomStoreSetupTests(IEnumerable<IValueSerializer> valueSerializers, IEnumerable<IAttribute> attributes)
: base(valueSerializers, attributes)
{
}

[Fact]
public void CanGetAttributesFromDatomStore()
{
Expand Down
10 changes: 2 additions & 8 deletions tests/NexusMods.EventSourcing.Tests/DbTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@

namespace NexusMods.EventSourcing.Tests;

public class DbTests : AEventSourcingTest
public class DbTests(IEnumerable<IValueSerializer> valueSerializers, IEnumerable<IAttribute> attributes)
: AEventSourcingTest(valueSerializers, attributes)
{

public DbTests(IEnumerable<IValueSerializer> valueSerializers, IEnumerable<IAttribute> attributes)
: base(valueSerializers, attributes)
{

}

[Fact]
public void ReadDatomsForEntity()
{
Expand Down

0 comments on commit 0d01177

Please sign in to comment.