Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Commit b3917fb

Browse files
committed
Clean code smells
1 parent 6ca1af7 commit b3917fb

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/ModelStateExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static IDictionary<string, string> CheckPayloadTooLargeAndReturnError(thi
2828
var modelStateErrors = modelState.Where(s => s.Value.Errors.Count > 0);
2929
if(modelStateErrors.Count() != 1)
3030
{
31-
return null;
31+
return new Dictionary<string, string>();
3232
}
3333

3434

@@ -45,13 +45,13 @@ public static IDictionary<string, string> CheckPayloadTooLargeAndReturnError(thi
4545
.Replace("failed to read the request form. multipart body length limit ", "")
4646
.Replace(" exceeded.", "");
4747

48-
return new Dictionary<string, string>
48+
return new Dictionary<string, string>()
4949
{
5050
{ BODY_PROPERTY_NAME, "MAX:" + maxSize }
5151
};
5252
}
5353

54-
return null;
54+
return new Dictionary<string, string>();
5555
}
5656

5757
private static (string Property, string Error) _mappingModelStateErrors(this KeyValuePair<string, ModelStateEntry> modelStateError)

src/ProblemDetailsFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public ProblemDetailsResponse Create(HttpContext httpContext, IEnumerable<KeyVal
5050
internal ProblemDetailsResponse Create(ActionContext actionContext)
5151
{
5252
var payloadTooLargeError = actionContext.ModelState.CheckPayloadTooLargeAndReturnError();
53-
if(payloadTooLargeError != null)
53+
if(payloadTooLargeError.Count == 1)
5454
{ // When the payload is too large, we return a 413 status code
5555
actionContext.HttpContext.Response.StatusCode = StatusCodes.Status413RequestEntityTooLarge;
5656

0 commit comments

Comments
 (0)