Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task<ServiceResponse<string>> Handle(UpdateProfileCommand request,
return new ServiceResponse<string>(false, "Failed to update profile");
}

return new ServiceResponse<string>(true, "Profile updated successfully");
return new ServiceResponse<string>(true, "Profile updated successfully", "Profile updated successfully");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify ServiceResponse constructor signatures and usage patterns

# Find ServiceResponse class definition
echo "=== ServiceResponse class definition ==="
ast-grep --pattern 'class ServiceResponse<$_> {
  $$$
}'

# Find constructor definitions
echo -e "\n=== ServiceResponse constructors ==="
rg -n -A 5 'class ServiceResponse' --type cs

# Find other usages of 3-parameter ServiceResponse constructor
echo -e "\n=== Other usages of 3-parameter ServiceResponse<string> constructor ==="
rg -n 'new ServiceResponse<string>\([^,]+,[^,]+,[^)]+\)' --type cs -C 2

Repository: PiedTeam/pied-lms

Length of output: 9443


🏁 Script executed:

find . -name "*.cs" -type f | head -20

Repository: PiedTeam/pied-lms

Length of output: 1357


🏁 Script executed:

rg -l "class ServiceResponse" --type cs

Repository: PiedTeam/pied-lms

Length of output: 43


🏁 Script executed:

fd -e cs -x grep -l "class ServiceResponse" {} \;

Repository: PiedTeam/pied-lms

Length of output: 43


🏁 Script executed:

find ./backend -name "*.cs" -type f -exec grep -l "class ServiceResponse" {} \;

Repository: PiedTeam/pied-lms

Length of output: 43


🏁 Script executed:

grep -r "class ServiceResponse" ./backend --include="*.cs" -n

Repository: PiedTeam/pied-lms

Length of output: 43


🏁 Script executed:

grep -r "using.*ServiceResponse\|ServiceResponse.*namespace" ./backend --include="*.cs" -B 2 -A 2

Repository: PiedTeam/pied-lms

Length of output: 43


🏁 Script executed:

grep -r "ServiceResponse<" ./backend --include="*.cs" | head -20

Repository: PiedTeam/pied-lms

Length of output: 3485


🏁 Script executed:

cat ./backend/Src/PIED_LMS.Application/UserCases/Commands/Identity/UpdateProfileHandler.cs | head -80

Repository: PiedTeam/pied-lms

Length of output: 3119


🏁 Script executed:

find ./backend -type d -name "*Contract*" -o -name "*Shared*" -o -name "*Common*" | head -20

Repository: PiedTeam/pied-lms

Length of output: 145


🏁 Script executed:

find ./backend -name "*.cs" -type f | xargs grep -l "class ServiceResponse" 2>/dev/null

Repository: PiedTeam/pied-lms

Length of output: 45


🏁 Script executed:

find . -path "*/Contract/*" -name "*.cs" -type f | head -30

Repository: PiedTeam/pied-lms

Length of output: 43


🏁 Script executed:

find ./backend/Src/PIED_LMS.Contract -name "*.cs" -type f | xargs grep -l "ServiceResponse"

Repository: PiedTeam/pied-lms

Length of output: 1774


🏁 Script executed:

ls -la ./backend/Src/PIED_LMS.Contract/

Repository: PiedTeam/pied-lms

Length of output: 621


🏁 Script executed:

find ./backend/Src/PIED_LMS.Contract -name "*.cs" -type f -exec grep -l "class ServiceResponse" {} \;

Repository: PiedTeam/pied-lms

Length of output: 43


🏁 Script executed:

find ./backend/Src/PIED_LMS.Contract/Abstractions -name "*.cs" -type f

Repository: PiedTeam/pied-lms

Length of output: 908


🏁 Script executed:

cat ./backend/Src/PIED_LMS.Contract/GlobalUsings.cs

Repository: PiedTeam/pied-lms

Length of output: 235


🏁 Script executed:

grep -r "ServiceResponse" ./backend/Src/PIED_LMS.Contract/Abstractions --include="*.cs" -n

Repository: PiedTeam/pied-lms

Length of output: 197


🏁 Script executed:

cat ./backend/Src/PIED_LMS.Contract/Abstractions/Shared/ResultT.cs

Repository: PiedTeam/pied-lms

Length of output: 706


🏁 Script executed:

cat ./backend/Src/PIED_LMS.Contract/Abstractions/Shared/Result.cs

Repository: PiedTeam/pied-lms

Length of output: 1165


🏁 Script executed:

grep -r "ServiceResponse\|using.*Result\|alias" ./backend/Src/PIED_LMS.Contract --include="*.cs" -n | head -30

Repository: PiedTeam/pied-lms

Length of output: 3680


🏁 Script executed:

grep -r "class ServiceResponse\|record ServiceResponse" ./backend --include="*.cs"

Repository: PiedTeam/pied-lms

Length of output: 157


🏁 Script executed:

find ./backend -name "*.csproj" -type f -exec cat {} \; | grep -i "serviceresponse\|package"

Repository: PiedTeam/pied-lms

Length of output: 2465


🏁 Script executed:

rg "class ServiceResponse|namespace.*ServiceResponse" ./backend --type cs -i

Repository: PiedTeam/pied-lms

Length of output: 43


🏁 Script executed:

cat ./backend/Src/PIED_LMS.Contract/Services/Identity/Response.cs

Repository: PiedTeam/pied-lms

Length of output: 1427


Remove the redundant duplicate string in the Data parameter.

The ServiceResponse<T> constructor accepts a Data field to carry meaningful information, yet you're passing "Profile updated successfully" as both the Message and Data parameters. This duplication is wasteful and defeats the purpose of the Data field.

Choose one approach:

  1. Return the updated user profile data as a DTO
  2. Return a specific success indicator (e.g., the user ID or updated timestamp)
  3. Use a simpler response type like ServiceResponse<bool> with true as the data value
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@backend/Src/PIED_LMS.Application/UserCases/Commands/Identity/UpdateProfileHandler.cs`
at line 66, The ServiceResponse<string> returned in UpdateProfileHandler is
using the same message for both Message and Data; replace the redundant Data
value with a meaningful payload (preferably return the updated user DTO from
your updated model, e.g., UpdatedUserDto or UserProfileDto) or switch the
response type to ServiceResponse<bool> and return true as Data; update the
return in UpdateProfileHandler.Handle to construct ServiceResponse with the
chosen Data (e.g., the updated user DTO or a boolean) instead of the duplicate
"Profile updated successfully" string.

}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ public static IResult ToActionResult<T>(this ServiceResponse<T> result, HttpCont
{
if (result.Success)
{
if (result.Data is null && typeof(T).IsClass)
return Results.NotFound(result);

return Results.Ok(result);
}

Expand All @@ -25,7 +22,7 @@ public static IResult ToActionResult<T>(this ServiceResponse<T> result, HttpCont
return Results.Json(result, statusCode: StatusCodes.Status401Unauthorized);

if (result.ErrorCode == "FORBIDDEN" || result.ErrorCode == "ACCESS_DENIED" ||
(result.Message.Contains("authorized") || result.Message.Contains("permission")))
(result.Message is not null && (result.Message.Contains("authorized") || result.Message.Contains("permission"))))
return Results.Json(result, statusCode: StatusCodes.Status403Forbidden);

return result.ErrorCode switch
Expand Down
Loading