Skip to content

Commit

Permalink
Meta: Setup dotnet linting CI (with GH annotations) (#53)
Browse files Browse the repository at this point in the history
* Setup dotnet CI
* editorconfig: Add space after cast
* Downgrade dotnet-format and move .csproj

Use an older version of dotnet-format because the newer version shows
absolute paths which breaks the 'dotnet-format-problem-matcher'. [1]

Also move the dummy .csproj file to the root of the repo so that
annotations will be created. [2]

[1] xt0rted/dotnet-format-problem-matcher#206
[2] xt0rted/dotnet-format-problem-matcher#91
  • Loading branch information
Histalek committed Jun 24, 2021
1 parent fea10d7 commit c4873a4
Show file tree
Hide file tree
Showing 38 changed files with 177 additions and 131 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ end_of_line = lf
[*.{cmd,bat}]
end_of_line = crlf

[*.yml]
indent_size = 2

[*.cs]
#### .NET Coding Conventions ####

Expand Down Expand Up @@ -143,7 +146,7 @@ csharp_indent_labels = one_less_than_current
csharp_indent_switch_labels = true

# Space preferences
csharp_space_after_cast = false
csharp_space_after_cast = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI-dotnet

on:
pull_request:
paths:
- "**.cs"
- "**.csproj"
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
reason:
description: 'The reason for running the workflow'
required: true
default: 'Force run CI'

jobs:
build:
runs-on: ubuntu-latest
name: Code analysis
steps:
- uses: actions/checkout@v2

- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'

- name: Dotnet format annotations
uses: xt0rted/dotnet-format-problem-matcher@v1

- name: Setup dotnet-format tool
run: dotnet tool install -g dotnet-format --version 5.0.\*

- name: Run dotnet format
run: dotnet format --check
2 changes: 1 addition & 1 deletion code/gamemode/Game.Util.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Collections.Generic;
using Sandbox;
using System.Collections.Generic;
using TTTReborn.Player;

namespace TTTReborn.Gamemode
Expand Down
7 changes: 3 additions & 4 deletions code/gamemode/Game.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using Sandbox;

using TTTReborn.UI;
using System;
using TTTReborn.Player;
using TTTReborn.Rounds;
using TTTReborn.UI;

namespace TTTReborn.Gamemode
{
Expand Down Expand Up @@ -105,7 +104,7 @@ private async void StartGameTimer()

await GameTask.DelaySeconds(1);
}
catch(Exception e)
catch (Exception e)
{
if (e.Message.Trim() == "A task was canceled.")
{
Expand Down
3 changes: 1 addition & 2 deletions code/items/equipments/TTTEquipment.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using Sandbox;

using System;
using TTTReborn.Player;

namespace TTTReborn.Items
Expand Down
2 changes: 1 addition & 1 deletion code/items/weapons/AmmoType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace TTTReborn.Items
namespace TTTReborn.Items
{
public enum AmmoType
{
Expand Down
2 changes: 1 addition & 1 deletion code/items/weapons/Knife.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Sandbox;
using Sandbox;

namespace TTTReborn.Items
{
Expand Down
2 changes: 1 addition & 1 deletion code/items/weapons/Pistol.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Sandbox;
using Sandbox;

namespace TTTReborn.Items
{
Expand Down
2 changes: 1 addition & 1 deletion code/items/weapons/SMG.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Sandbox;
using Sandbox;

namespace TTTReborn.Items
{
Expand Down
2 changes: 1 addition & 1 deletion code/items/weapons/Shotgun.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Sandbox;
using Sandbox;

using TTTReborn.Player;

Expand Down
3 changes: 1 addition & 2 deletions code/items/weapons/TTTWeapon.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using Sandbox;

using System;
using TTTReborn.Player;
using TTTReborn.UI;

Expand Down
2 changes: 1 addition & 1 deletion code/items/weapons/ViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Sandbox;
using Sandbox;
using System;

namespace TTTReborn.Items
Expand Down
3 changes: 1 addition & 2 deletions code/items/weapons/WeaponFunctions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using Sandbox;
using System;
using System.Collections.Generic;
using System.Linq;

using Sandbox;

namespace TTTReborn.Items
{
public static class WeaponFunctions
Expand Down
5 changes: 2 additions & 3 deletions code/player/Inventory.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Linq;
using Sandbox;

using System;
using System.Linq;
using TTTReborn.Items;

namespace TTTReborn.Player
Expand Down
80 changes: 40 additions & 40 deletions code/player/PlayerCorpse.cs
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
using Sandbox;
using Sandbox;

namespace TTTReborn.Player
{
public partial class PlayerCorpse : ModelEntity
{
public TTTPlayer Player { get; set; }
public partial class PlayerCorpse : ModelEntity
{
public TTTPlayer Player { get; set; }

[Net]
public bool IsIdentified { get; set; } = false;
[Net]
public bool IsIdentified { get; set; } = false;

public PlayerCorpse()
{
MoveType = MoveType.Physics;
UsePhysicsCollision = true;
public PlayerCorpse()
{
MoveType = MoveType.Physics;
UsePhysicsCollision = true;

SetInteractsAs(CollisionLayer.Debris);
SetInteractsWith(CollisionLayer.WORLD_GEOMETRY);
SetInteractsExclude(CollisionLayer.Player | CollisionLayer.Debris);
SetInteractsAs(CollisionLayer.Debris);
SetInteractsWith(CollisionLayer.WORLD_GEOMETRY);
SetInteractsExclude(CollisionLayer.Player | CollisionLayer.Debris);

IsIdentified = false;
}
IsIdentified = false;
}

public void CopyFrom(TTTPlayer player)
{
SetModel(player.GetModelName());
TakeDecalsFrom(player);
public void CopyFrom(TTTPlayer player)
{
SetModel(player.GetModelName());
TakeDecalsFrom(player);

this.CopyBonesFrom(player);
this.SetRagdollVelocityFrom(player);
this.CopyBonesFrom(player);
this.SetRagdollVelocityFrom(player);

foreach (Entity child in player.Children)
{
if (child is ModelEntity e)
{
string model = e.GetModelName();
foreach (Entity child in player.Children)
{
if (child is ModelEntity e)
{
string model = e.GetModelName();

if (model != null && !model.Contains("clothes"))
{
continue;
}
if (model != null && !model.Contains("clothes"))
{
continue;
}

ModelEntity clothing = new ModelEntity();
clothing.SetModel(model);
clothing.SetParent(this, true);
}
}
}
ModelEntity clothing = new ModelEntity();
clothing.SetModel(model);
clothing.SetParent(this, true);
}
}
}

public void ApplyForceToBone(Vector3 force, int forceBone)
{
PhysicsGroup.AddVelocity(force);
public void ApplyForceToBone(Vector3 force, int forceBone)
{
PhysicsGroup.AddVelocity(force);

if (forceBone < 0)
{
Expand All @@ -67,5 +67,5 @@ public void ApplyForceToBone(Vector3 force, int forceBone)
PhysicsGroup.AddVelocity(force);
}
}
}
}
}
6 changes: 3 additions & 3 deletions code/player/TTTPlayer.Ammo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Sandbox;
using Sandbox;
using System;
using System.Collections.Generic;

Expand All @@ -18,7 +18,7 @@ public void ClearAmmo()

public int AmmoCount(AmmoType type)
{
int iType = (int)type;
int iType = (int) type;

if (Ammo == null || Ammo.Count <= iType)
{
Expand All @@ -30,7 +30,7 @@ public int AmmoCount(AmmoType type)

public bool SetAmmo(AmmoType type, int amount)
{
int iType = (int)type;
int iType = (int) type;

if (!Host.IsServer || Ammo == null)
{
Expand Down
2 changes: 1 addition & 1 deletion code/player/TTTPlayer.Clothes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Sandbox;
using Sandbox;
using System.Collections.Generic;

namespace TTTReborn.Player
Expand Down
5 changes: 2 additions & 3 deletions code/player/TTTPlayer.Commands.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Sandbox;
using System;
using System.Linq;
using System.Collections.Generic;
using Sandbox;

using System.Linq;
using TTTReborn.Items;
using TTTReborn.Roles;

Expand Down
2 changes: 1 addition & 1 deletion code/player/TTTPlayer.Confirmation.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Sandbox;
using Sandbox;

namespace TTTReborn.Player
{
Expand Down
6 changes: 3 additions & 3 deletions code/player/TTTPlayer.FallDamage.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Sandbox;
using System;

namespace TTTReborn.Player
{
Expand Down Expand Up @@ -40,9 +40,9 @@ public void OnPlayerHitGround(float fallingHeight)
{
Attacker = this,
Body = PhysicsBody,
Damage = (float)Math.Round(0.15f * (fallingHeight - FALLING_OBLIGINGNESS)),
Damage = (float) Math.Round(0.15f * (fallingHeight - FALLING_OBLIGINGNESS)),
Flags = DamageFlags.Fall,
HitboxIndex = (int)HitboxIndex.LeftFoot,
HitboxIndex = (int) HitboxIndex.LeftFoot,
Position = Position
};

Expand Down
3 changes: 1 addition & 2 deletions code/player/TTTPlayer.RPCs.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Sandbox;

using TTTReborn.Roles;
using TTTReborn.UI;
using TTTReborn.Teams;
using TTTReborn.UI;

namespace TTTReborn.Player
{
Expand Down
5 changes: 3 additions & 2 deletions code/player/TTTPlayer.Roles.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using TTTReborn.Roles;
using TTTReborn.Roles;
using TTTReborn.Teams;

namespace TTTReborn.Player
{
partial class TTTPlayer
{
public TTTRole Role {
public TTTRole Role
{
get
{
if (_role == null)
Expand Down
2 changes: 1 addition & 1 deletion code/player/TTTPlayer.Status.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Sandbox;
using System;

namespace TTTReborn.Player
{
Expand Down
9 changes: 4 additions & 5 deletions code/player/TTTPlayer.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Sandbox;

using TTTReborn.Items;
using TTTReborn.Player.Camera;
using TTTReborn.Roles;
using TTTReborn.Items;

namespace TTTReborn.Player
{
Expand Down Expand Up @@ -44,7 +43,7 @@ public void InitialRespawn()
bool isPostRound = Gamemode.Game.Instance.Round is Rounds.PostRound;

// sync roles
using(Prediction.Off())
using (Prediction.Off())
{
foreach (TTTPlayer player in Gamemode.Game.GetPlayers())
{
Expand Down Expand Up @@ -78,7 +77,7 @@ public override void Respawn()

GetClientOwner().SetScore("alive", true);

using(Prediction.Off())
using (Prediction.Off())
{
ClientOnPlayerSpawned(this);
ClientSetRole(To.Single(this), Role.Name);
Expand Down Expand Up @@ -115,7 +114,7 @@ public override void OnKilled()
Inventory.DropActive();
Inventory.DeleteContents();

using(Prediction.Off())
using (Prediction.Off())
{
ClientOnPlayerDied(To.Single(this), this);
}
Expand Down
Loading

0 comments on commit c4873a4

Please sign in to comment.