Skip to content

Commit e208f1d

Browse files
authored
Merge pull request #338 from nanotaboada/feature/address-sonarqube-findings
chore: address SonarQube code quality findings
2 parents c915288 + c493e2c commit e208f1d

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

scripts/run-migrations-and-copy-database.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ log() {
1717
local timestamp
1818
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
1919
echo "$emoji [$timestamp] [$level] $message"
20+
return 0
2021
}
2122

2223
# Check if the EF Core CLI tool is installed
@@ -33,18 +34,18 @@ touch "$TARGET_FILE_PATH"
3334
# Run the database migration
3435
log "" "INFO" "Running EF Core database migration for project at '$PROJECT_ROOT_PATH'..."
3536
dotnet ef database update --project "$PROJECT_ROOT_PATH"
36-
if [ $? -ne 0 ]; then
37+
if [[ $? -ne 0 ]]; then
3738
log "" "ERROR" "Migration failed. See error above."
3839
exit 1
3940
fi
4041

4142
# Check and copy database
42-
if [ -f "$SOURCE_FILE_PATH" ]; then
43+
if [[ -f "$SOURCE_FILE_PATH" ]]; then
4344
log "" "INFO" "Found database at '$SOURCE_FILE_PATH'"
4445
log "" "INFO" "Copying to '$TARGET_FILE_PATH'..."
4546
cp -f "$SOURCE_FILE_PATH" "$TARGET_FILE_PATH"
4647

47-
if [ $? -eq 0 ]; then
48+
if [[ $? -eq 0 ]]; then
4849
log "" "INFO" "Database successfully copied to '$TARGET_FILE_PATH'"
4950
else
5051
log "" "ERROR" "Failed to copy the database file."
@@ -57,9 +58,9 @@ else
5758
fi
5859

5960
# Confirm destination file exists
60-
if [ -f "$TARGET_FILE_PATH" ]; then
61+
if [[ -f "$TARGET_FILE_PATH" ]]; then
6162
log "" "INFO" "Done. The database is now available at '$TARGET_FILE_PATH'"
6263
else
6364
log "⚠️" "WARNING" "Something went wrong. The destination file was not found."
6465
exit 1
65-
fi
66+
fi

src/Dotnet.Samples.AspNetCore.WebApi/Controllers/PlayerController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ [FromBody] PlayerRequestModel player
177177
.ToArray();
178178

179179
logger.LogWarning(
180-
"PUT /players/{squadNumber} validation failed: {@Errors}",
180+
"PUT /players/{SquadNumber} validation failed: {@Errors}",
181181
squadNumber,
182182
errors
183183
);

src/Dotnet.Samples.AspNetCore.WebApi/Models/PlayerRequestModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class PlayerRequestModel
2020

2121
public DateTime? DateOfBirth { get; set; }
2222

23-
public int SquadNumber { get; set; }
23+
public required int SquadNumber { get; set; }
2424

2525
public string? AbbrPosition { get; set; }
2626

src/Dotnet.Samples.AspNetCore.WebApi/Validators/PlayerRequestModelValidator.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public PlayerRequestModelValidator(IPlayerRepository playerRepository)
3333
.WithMessage("SquadNumber must be greater than 0.")
3434
.MustAsync(BeUniqueSquadNumber)
3535
.WithMessage("SquadNumber must be unique.");
36-
;
3736

3837
RuleFor(player => player.AbbrPosition)
3938
.NotEmpty()

0 commit comments

Comments
 (0)