Skip to content

Commit

Permalink
fix: resolved all warnings in the project, adjusted versioning feat
Browse files Browse the repository at this point in the history
… in github workflow
  • Loading branch information
Khertys committed Nov 4, 2023
1 parent acb8763 commit 6cc3299
Show file tree
Hide file tree
Showing 131 changed files with 475 additions and 497 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
uses: codacy/[email protected]
with:
prefix: 'v'
minor-identifier: 'feat:'
minor-identifier: 'feat'
major-identifier: '(breaking)' # this should be placed somewhere in the commit message like "feat: (breaking) some message"

- name: Build query validator
Expand Down
26 changes: 13 additions & 13 deletions EvitaDB.Client/Converters/DataTypes/ComplexDataObjectConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public static object GetSerializableForm(object? obj)

public static ComplexDataObject ConvertToGenericType<T>(T container)
{
IDataItem rootNode = ConvertToIDataItem(container);
IDataItem rootNode = ConvertToIDataItem(container!)!;

ComplexDataObject result = new ComplexDataObject(rootNode);
Assert.IsTrue(
!result.Empty,
"No usable properties found on " + container.GetType().Name + ". This is probably a problem."
"No usable properties found on " + container?.GetType().Name + ". This is probably a problem."
);
return result;
}
Expand All @@ -71,7 +71,7 @@ public static ComplexDataObject ConvertToGenericType<T>(T container)
// Add each item in the list to the DataItemArray
foreach (object item in list)
{
dataItemArray.Add(ConvertToIDataItem(item));
dataItemArray.Add(ConvertToIDataItem(item)!);
}

return new DataItemArray(dataItemArray.ToArray());
Expand All @@ -85,10 +85,10 @@ public static ComplexDataObject ConvertToGenericType<T>(T container)
// Add each key-value pair in the dictionary to the DataItemMap
foreach (DictionaryEntry entry in dictionary)
{
dataItemMap.Add(entry.Key.ToString(), ConvertToIDataItem(entry.Value));
dataItemMap.Add(entry.Key.ToString()!, ConvertToIDataItem(entry.Value!)!);
}

return new DataItemMap(dataItemMap);
return new DataItemMap(dataItemMap!);
}

if (properties.Length > 0)
Expand All @@ -103,10 +103,10 @@ public static ComplexDataObject ConvertToGenericType<T>(T container)
object? value = property.GetValue(obj);

// Add the property to the DataItemMap
dataItemMap.Add(property.Name, ConvertToIDataItem(value));
dataItemMap.Add(property.Name, ConvertToIDataItem(value!)!);
}

return new DataItemMap(dataItemMap);
return new DataItemMap(dataItemMap!);
}

return null;
Expand All @@ -128,14 +128,14 @@ public static ComplexDataObject ConvertToGenericType<T>(T container)
if (dataItem is DataItemArray dataItemArray)
{
// Create a list to hold the elements
Type arrayType = type.IsArray ? type.GetElementType() : type;
Array array = (Array)Activator.CreateInstance(arrayType.MakeArrayType(), dataItemArray.Children.Length);
Type arrayType = type.IsArray ? type.GetElementType()! : type;
Array array = (Array)Activator.CreateInstance(arrayType.MakeArrayType(), dataItemArray.Children.Length)!;

// Convert each IDataItem in the DataItemArray and add it to the list
for (int i = 0; i < dataItemArray.Children.Length; i++)
{
IDataItem? item = dataItemArray.Children[i];
array.SetValue(ConvertFromIComplexDataObject(item, type.GetElementType()), i);
array.SetValue(ConvertFromIComplexDataObject(item!, type.GetElementType()!), i);
}

return array;
Expand All @@ -146,12 +146,12 @@ public static ComplexDataObject ConvertToGenericType<T>(T container)
// Create an instance of the specified type
object? obj = Activator.CreateInstance(type);
// Use reflection to set the properties of the new object
foreach (KeyValuePair<string, IDataItem> entry in dataItemMap.ChildrenIndex)
foreach (KeyValuePair<string, IDataItem?> entry in dataItemMap.ChildrenIndex)
{
PropertyInfo? property = type.GetProperty(StringUtils.Capitalize(entry.Key));
PropertyInfo? property = type.GetProperty(StringUtils.Capitalize(entry.Key)!);
if (property != null)
{
property.SetValue(obj, ConvertFromIComplexDataObject(entry.Value, property.PropertyType));
property.SetValue(obj, ConvertFromIComplexDataObject(entry.Value!, property.PropertyType));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class JsonToComplexDataObjectConverter

if (jsonNode.Type == JTokenType.String)
{
var value = jsonNode.Value<string>();
string value = jsonNode.Value<string>()!;
if (LongNumber.IsMatch(value))
{
return new DataItemValue(long.Parse(value));
Expand Down
6 changes: 4 additions & 2 deletions EvitaDB.Client/Converters/Models/EvitaEnumConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ public static GrpcCaptureContent ToGrpcCaptureContent(CaptureContent captureCont
return captureContent switch
{
CaptureContent.Header => GrpcCaptureContent.Header,
CaptureContent.Body => GrpcCaptureContent.Body
CaptureContent.Body => GrpcCaptureContent.Body,
_ => throw new ArgumentOutOfRangeException(nameof(captureContent), captureContent, null)
};
}

Expand All @@ -468,7 +469,8 @@ public static GrpcOperation ToGrpcOperation(Operation operation)
{
Operation.Create => GrpcOperation.Create,
Operation.Update => GrpcOperation.Update,
Operation.Remove => GrpcOperation.Remove
Operation.Remove => GrpcOperation.Remove,
_ => throw new ArgumentOutOfRangeException(nameof(operation), operation, null)
};
}
}
2 changes: 1 addition & 1 deletion EvitaDB.Client/Converters/Models/ResponseConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ GrpcHierarchy grpcHierarchy
rootHierarchyConstraint,
cnt => cnt is IHierarchyRequireConstraint hrc && x.Key == hrc.OutputName
);
EntityFetch? entityFetch = QueryUtils.FindConstraint<EntityFetch>(hierarchyConstraint);
EntityFetch? entityFetch = QueryUtils.FindConstraint<EntityFetch>(hierarchyConstraint!);
return x.Value.LevelInfos.Select(y => ToLevelInfo(entitySchemaFetcher, evitaRequest, entityFetch, y)).ToList();
});
}
Expand Down
2 changes: 1 addition & 1 deletion EvitaDB.Client/DataTypes/ByteNumberRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static byte ParseByte(string toBeNumber)
{
return Convert.ToByte(toBeNumber);
}
catch (FormatException ex)
catch (FormatException)
{
throw new DataTypeParseException("String " + toBeNumber + " is not a byte number!");
}
Expand Down
2 changes: 1 addition & 1 deletion EvitaDB.Client/DataTypes/Data/DataItemArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ public override int GetHashCode()

public override string ToString()
{
return $"[{string.Join(", ", Children.Select(c => c.ToString()))}]";
return $"[{string.Join(", ", Children.Select(c => c?.ToString()))}]";
}
}
14 changes: 7 additions & 7 deletions EvitaDB.Client/DataTypes/EvitaDataTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,19 @@ public static bool IsSupportedTypeOrItsArray(Type type)
if (unknownObject.GetType().IsArray)
{
int inputArrayLength = (unknownObject as object[])!.Length;
result = Array.CreateInstance(baseRequestedType, inputArrayLength);
result = Array.CreateInstance(baseRequestedType!, inputArrayLength);
for (int i = 0; i < inputArrayLength; i++)
{
(result as object[])[i] = ConvertSingleObject(
(unknownObject as object[])[i],
baseRequestedType,
(result as object[])![i] = ConvertSingleObject(
(unknownObject as object[])?[i]!,
baseRequestedType!,
allowedDecimalPlaces
);
}
}
else
{
result = ConvertSingleObject(unknownObject, baseRequestedType, allowedDecimalPlaces);
result = ConvertSingleObject(unknownObject, baseRequestedType!, allowedDecimalPlaces);
}

if (requestedType.IsArray)
Expand All @@ -124,8 +124,8 @@ public static bool IsSupportedTypeOrItsArray(Type type)
return result;
}

object[] wrappedResult = Array.CreateInstance(baseRequestedType, 1) as object[];
wrappedResult[0] = result;
object[]? wrappedResult = Array.CreateInstance(baseRequestedType!, 1) as object[];
wrappedResult![0] = result;
return wrappedResult;
}

Expand Down
2 changes: 1 addition & 1 deletion EvitaDB.Client/DataTypes/IntegerNumberRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static int ParseInteger(string toBeNumber)
{
return Convert.ToInt32(toBeNumber);
}
catch (FormatException ex)
catch (FormatException)
{
throw new DataTypeParseException("String " + toBeNumber + " is not a integer number!");
}
Expand Down
2 changes: 1 addition & 1 deletion EvitaDB.Client/DataTypes/LongNumberRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static long ParseLong(string toBeNumber)
{
return Convert.ToInt64(toBeNumber);
}
catch (FormatException ex)
catch (FormatException)
{
throw new DataTypeParseException("String " + toBeNumber + " is not a long number!");
}
Expand Down
2 changes: 1 addition & 1 deletion EvitaDB.Client/DataTypes/ShortNumberRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private static short ParseShort(string toBeNumber)
{
return Convert.ToInt16(toBeNumber);
}
catch (FormatException ex)
catch (FormatException)
{
throw new DataTypeParseException("String " + toBeNumber + " is not a short number!");
}
Expand Down
24 changes: 12 additions & 12 deletions EvitaDB.Client/EvitaClientSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public IList<TS> QueryList<TS>(Query query) where TS : IEntityClassifier

if (typeof(IEntityReference).IsAssignableFrom(typeof(TS)))
{
return EntityConverter.ToEntityReferences(grpcResponse.EntityReferences) as IList<TS>;
return (IList<TS>) EntityConverter.ToEntityReferences(grpcResponse.EntityReferences);
}

if (typeof(ISealedEntity).IsAssignableFrom(typeof(TS)))
Expand Down Expand Up @@ -344,7 +344,7 @@ public EvitaResponse<ISealedEntity> QuerySealedEntity(Query query)
query.FilterBy,
query.OrderBy,
(Require) query.Require.GetCopyWithNewChildren(
new IRequireConstraint[] {Require(EntityFetch())}
new IRequireConstraint?[] {Require(EntityFetch())}
.Concat(query.Require.Children).ToArray(),
query.Require.AdditionalChildren
)
Expand Down Expand Up @@ -438,7 +438,7 @@ public int GetEntityCollectionSize(string entityType)
public int UpdateCatalogSchema(params ILocalCatalogSchemaMutation[] schemaMutation)
{
AssertActive();
return ExecuteInTransactionIfPossible(session =>
return ExecuteInTransactionIfPossible(_ =>
{
List<GrpcLocalCatalogSchemaMutation>
grpcSchemaMutations = schemaMutation
Expand Down Expand Up @@ -505,7 +505,7 @@ public DeletedHierarchy<ISealedEntity> DeleteEntityAndItsHierarchy(string entity
public bool DeleteEntity(string entityType, int primaryKey)
{
AssertActive();
return ExecuteInTransactionIfPossible(session =>
return ExecuteInTransactionIfPossible(_ =>
{
GrpcDeleteEntityResponse grpcResponse = ExecuteWithEvitaSessionService(evitaSessionService =>
evitaSessionService.DeleteEntity(
Expand All @@ -523,7 +523,7 @@ public bool DeleteEntity(string entityType, int primaryKey)
public ISealedEntity[] DeleteSealedEntitiesAndReturnBodies(Query query)
{
AssertActive();
return ExecuteInTransactionIfPossible(session =>
return ExecuteInTransactionIfPossible(_ =>
{
EvitaRequest evitaRequest = new EvitaRequest(
query,
Expand Down Expand Up @@ -564,7 +564,7 @@ public ISealedEntity[] DeleteSealedEntitiesAndReturnBodies(Query query)
public int DeleteEntities(Query query)
{
AssertActive();
return ExecuteInTransactionIfPossible(session =>
return ExecuteInTransactionIfPossible(_ =>
{
StringWithParameters stringWithParameters = ToStringWithParameterExtraction(query);
GrpcDeleteEntitiesResponse grpcResponse = ExecuteWithEvitaSessionService(evitaSessionService =>
Expand Down Expand Up @@ -627,7 +627,7 @@ public bool ReplaceCollection(string entityTypeToBeReplaced, string entityTypeTo
public int UpdateEntitySchema(ModifyEntitySchemaMutation schemaMutation)
{
AssertActive();
return ExecuteInTransactionIfPossible(session =>
return ExecuteInTransactionIfPossible(_ =>
{
GrpcModifyEntitySchemaMutation grpcSchemaMutation =
ModifyEntitySchemaMutationConverter.Convert(schemaMutation);
Expand All @@ -654,7 +654,7 @@ public int UpdateEntitySchema(IEntitySchemaBuilder entitySchemaBuilder)
public ISealedEntitySchema UpdateAndFetchEntitySchema(ModifyEntitySchemaMutation schemaMutation)
{
AssertActive();
return ExecuteInTransactionIfPossible(session =>
return ExecuteInTransactionIfPossible(_ =>
{
GrpcModifyEntitySchemaMutation grpcSchemaMutation =
ModifyEntitySchemaMutationConverter.Convert(schemaMutation);
Expand Down Expand Up @@ -736,7 +736,7 @@ private void CloseInternally()
public ISealedCatalogSchema UpdateAndFetchCatalogSchema(params ILocalCatalogSchemaMutation[] schemaMutation)
{
AssertActive();
return ExecuteInTransactionIfPossible(session =>
return ExecuteInTransactionIfPossible(_ =>
{
List<GrpcLocalCatalogSchemaMutation> grpcSchemaMutations = schemaMutation
.Select(CatalogSchemaMutationConverter.Convert)
Expand Down Expand Up @@ -887,7 +887,7 @@ public ISealedEntity UpsertAndFetchEntity(IEntityBuilder entityBuilder, params I
public ISealedEntity UpsertAndFetchEntity(IEntityMutation entityMutation, params IEntityContentRequire[] require)
{
AssertActive();
return ExecuteInTransactionIfPossible(session =>
return ExecuteInTransactionIfPossible(_ =>
{
GrpcEntityMutation grpcEntityMutation = EntityMutationConverter.Convert(entityMutation);
StringWithParameters stringWithParameters = ToStringWithParameterExtraction(require);
Expand Down Expand Up @@ -989,7 +989,7 @@ private EvitaClientTransaction CreateAndInitTransaction()
evitaSessionService.OpenTransaction(new Empty())
);

EvitaClientTransaction? tx = new EvitaClientTransaction(this, grpcResponse.TransactionId);
EvitaClientTransaction tx = new EvitaClientTransaction(this, grpcResponse.TransactionId);
_transactionAccessor.GetAndSet(transaction =>
{
Assert.IsPremiseValid(transaction == null, "Transaction unexpectedly found!");
Expand Down Expand Up @@ -1071,7 +1071,7 @@ public IList<ISealedEntity> QueryListOfSealedEntities(Query query)
query.FilterBy,
query.OrderBy,
(Require) query.Require.GetCopyWithNewChildren(
new IRequireConstraint[] {Require(EntityFetch())}.Concat(query.Require.Children).ToArray(),
new IRequireConstraint?[] {Require(EntityFetch())}.Concat(query.Require.Children).ToArray(),
query.Require.AdditionalChildren
)
)
Expand Down
1 change: 1 addition & 0 deletions EvitaDB.Client/Exceptions/EvitaInternalError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public EvitaInternalError(string publicMessage) : base(publicMessage)
private EvitaInternalError(string privateMessage, string publicMessage, string errorCode) : base(privateMessage)
{
PublicMessage = publicMessage;
PrivateMessage = privateMessage;
ErrorCode = errorCode;
}
}
2 changes: 1 addition & 1 deletion EvitaDB.Client/Models/Data/IAssociatedDataBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal static IAssociatedDataSchema CreateImplicitSchema(AssociatedDataValue a
null, null,
associatedDataValue.Key.Localized,
true,
associatedDataValue.Value.GetType()
associatedDataValue.Value?.GetType()!
);
}
}
2 changes: 1 addition & 1 deletion EvitaDB.Client/Models/Data/IAttributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static bool AnyAttributeDifferBetween(IAttributes<TS> first, IAttributes<TS> sec
{
object? thisValue = it.Value;
AttributeKey key = it.Key;
AttributeValue? other = second.GetAttributeValue(key.AttributeName, key.Locale);
AttributeValue? other = second.GetAttributeValue(key.AttributeName, key.Locale!);
if (other == null)
{
return true;
Expand Down
4 changes: 2 additions & 2 deletions EvitaDB.Client/Models/Data/ReferenceKeyWithAttributeKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public ReferenceKeyWithAttributeKey(ReferenceKey referenceKey, AttributeKey attr

public int CompareTo(ReferenceKeyWithAttributeKey? o)
{
int entityReferenceComparison = ReferenceKey.CompareTo(o.ReferenceKey);
return entityReferenceComparison == 0 ? AttributeKey.CompareTo(o.AttributeKey) : entityReferenceComparison;
int entityReferenceComparison = ReferenceKey.CompareTo(o?.ReferenceKey);
return entityReferenceComparison == 0 ? AttributeKey.CompareTo(o?.AttributeKey) : entityReferenceComparison;
}

public override bool Equals(object? o)
Expand Down
Loading

0 comments on commit 6cc3299

Please sign in to comment.