Skip to content

Commit

Permalink
Fix editorconfig problems and ensure fails pipelin
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliveriver committed Jul 27, 2024
1 parent c6e6efa commit 4b1e3c0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 deletions.
14 changes: 13 additions & 1 deletion server/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ csharp_style_var_for_built_in_types = true:error
csharp_style_var_when_type_is_apparent = true:error
csharp_style_var_elsewhere = true:error
csharp_space_around_binary_operators = before_and_after
dotnet_diagnostic.IDE0051.severity = error
dotnet_diagnostic.IDE0052.severity = error
dotnet_diagnostic.IDE0064.severity = error
dotnet_diagnostic.IDE0076.severity = error
dotnet_diagnostic.IDE0077.severity = error
dotnet_diagnostic.IDE0043.severity = error
dotnet_diagnostic.IDE0059.severity = error
dotnet_diagnostic.IDE0058.severity = none

# Xml files
[*.xml]
Expand Down Expand Up @@ -114,7 +122,7 @@ dotnet_style_null_propagation = true:error
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error
dotnet_style_prefer_auto_properties = true:error
dotnet_style_object_initializer = true:error
dotnet_style_prefer_collection_expression = true:error
dotnet_style_prefer_collection_expression = when_types_exactly_match:error
dotnet_style_collection_initializer = true:error
dotnet_style_prefer_simplified_boolean_expressions = true:error
dotnet_style_prefer_conditional_expression_over_assignment = true:error
Expand All @@ -141,3 +149,7 @@ dotnet_style_qualification_for_property = false:error
dotnet_style_qualification_for_method = false:error
dotnet_style_qualification_for_event = false:error
insert_final_newline = true

dotnet_analyzer_diagnostic.category-Style.severity = error
dotnet_analyzer_diagnostic.category-Design.severity = error
dotnet_analyzer_diagnostic.category-Naming.severity = error
5 changes: 4 additions & 1 deletion server/5dDiplomacyWithMultiverseTimeTravel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>false</InvariantGlobalization>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591;CS1573</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
Expand Down
16 changes: 8 additions & 8 deletions server/Controllers/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public async Task<ActionResult<Game>> CreateGame([FromBody] GameCreationRequest

if (isSandbox && player != null)
{
logger.LogError("Attempted to create sandbox game with nation {player} specified", player);
logger.LogError("Attempted to create sandbox game with nation {Player} specified", player);
return BadRequest("Sandbox must be created with no player specified");
}

Expand All @@ -49,7 +49,7 @@ public async Task<ActionResult<Game>> CreateGame([FromBody] GameCreationRequest
public async Task<ActionResult<Game>> JoinGame([FromRoute] int gameId, [FromBody] GameJoinRequest request)
{
var player = request.Player;
logger.LogInformation("Requesting to join game {gameId} as {player}", gameId, player);
logger.LogInformation("Requesting to join game {GameId} as {Player}", gameId, player);

try
{
Expand All @@ -58,12 +58,12 @@ public async Task<ActionResult<Game>> JoinGame([FromRoute] int gameId, [FromBody
}
catch (KeyNotFoundException)
{
logger.LogError("Attempted to join non-existent game {gameId}", gameId);
logger.LogError("Attempted to join non-existent game {GameId}", gameId);
return NotFound($"No game with ID {gameId} found");
}
catch (InvalidOperationException)
{
logger.LogWarning("Failed to join game {gameId}", gameId);
logger.LogWarning("Failed to join game {GameId}", gameId);
return BadRequest("Unable to join in-progress game as random nation");
}
}
Expand All @@ -72,7 +72,7 @@ public async Task<ActionResult<Game>> JoinGame([FromRoute] int gameId, [FromBody
[Route("{gameId}")]
public async Task<ActionResult<World>> GetWorld([FromRoute] int gameId)
{
logger.LogInformation("Fetching world for game {gameId}", gameId);
logger.LogInformation("Fetching world for game {GameId}", gameId);

try
{
Expand All @@ -81,7 +81,7 @@ public async Task<ActionResult<World>> GetWorld([FromRoute] int gameId)
}
catch (KeyNotFoundException)
{
logger.LogWarning("Failed to find world with ID {gameId}", gameId);
logger.LogWarning("Failed to find world with ID {GameId}", gameId);
return NotFound($"No world with game ID {gameId} found");
}
}
Expand All @@ -92,7 +92,7 @@ public async Task<ActionResult> SubmitOrders([FromRoute] int gameId, [FromBody]
{
var players = request.Players;
var orders = request.Orders;
logger.LogInformation("Adding submitted orders as player {players} for game {gameId}", players, gameId);
logger.LogInformation("Adding submitted orders as player {Players} for game {GameId}", players, gameId);

if (players.Length == 0)
{
Expand All @@ -114,7 +114,7 @@ public async Task<ActionResult> SubmitOrders([FromRoute] int gameId, [FromBody]
}
catch (KeyNotFoundException)
{
logger.LogWarning("Failed to find world with ID {gameId}", gameId);
logger.LogWarning("Failed to find world with ID {GameId}", gameId);
return NotFound($"No world with game ID {gameId} found");
}
}
Expand Down
6 changes: 3 additions & 3 deletions server/Repositories/GameRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class GameRepository(ILogger<GameRepository> logger, GameContext context,

public async Task<(Game game, Nation player)> CreateNormalGame(Nation? player)
{
logger.LogInformation("Creating game as {player}", player);
logger.LogInformation("Creating game as {Player}", player);

var defaultWorld = defaultWorldFactory.CreateWorld();

Expand Down Expand Up @@ -54,7 +54,7 @@ public async Task<Game> CreateSandboxGame()

public async Task<(Game game, Nation player)> JoinGame(int id, Nation? player)
{
logger.LogInformation("Joining game {id} as player {player}", id, player);
logger.LogInformation("Joining game {Id} as player {Player}", id, player);

var game = await context.Games.FindAsync(id) ?? throw new KeyNotFoundException("Game not found");

Expand All @@ -77,7 +77,7 @@ public async Task<Game> CreateSandboxGame()
private Nation GetRandomNation()
{
var player = Constants.Nations.ElementAt(random.Next(Constants.Nations.Count));
logger.LogInformation("Selected random nation {player}", player);
logger.LogInformation("Selected random nation {Player}", player);
return player;
}
}
Expand Down
8 changes: 4 additions & 4 deletions server/Repositories/WorldRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class WorldRepository(ILogger<WorldRepository> logger, GameContext contex

public async Task<World> GetWorld(int gameId)
{
logger.LogInformation("Querying world for game {gameId}", gameId);
logger.LogInformation("Querying world for game {GameId}", gameId);

var world = await context.Worlds
.Include(w => w.Boards).ThenInclude(b => b.Centres)
Expand All @@ -29,7 +29,7 @@ public async Task<World> GetWorld(int gameId)

public async Task AddOrders(int gameId, Nation[] players, IEnumerable<Order> orders)
{
logger.LogInformation("Submitting orders for game {gameId}", gameId);
logger.LogInformation("Submitting orders for game {GameId}", gameId);

var game = await context.Games.FindAsync(gameId)
?? throw new KeyNotFoundException("Game not found");
Expand All @@ -41,7 +41,7 @@ public async Task AddOrders(int gameId, Nation[] players, IEnumerable<Order> ord

if (game.PlayersSubmitted.Count == Constants.Nations.Count)
{
logger.LogInformation("Adjudicating game {gameId}", gameId);
logger.LogInformation("Adjudicating game {GameId}", gameId);

game.PlayersSubmitted = [];

Expand All @@ -53,7 +53,7 @@ public async Task AddOrders(int gameId, Nation[] players, IEnumerable<Order> ord
adjudicator.Adjudicate(world, map);
world.Iteration++;

logger.LogInformation("Adjudicated game {gameId}", gameId);
logger.LogInformation("Adjudicated game {GameId}", gameId);
}

await context.SaveChangesAsync();
Expand Down

0 comments on commit 4b1e3c0

Please sign in to comment.