Skip to content

Commit c4873a4

Browse files
authored
Meta: Setup dotnet linting CI (with GH annotations) (#53)
* 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
1 parent fea10d7 commit c4873a4

38 files changed

+177
-131
lines changed

.editorconfig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ end_of_line = lf
2121
[*.{cmd,bat}]
2222
end_of_line = crlf
2323

24+
[*.yml]
25+
indent_size = 2
26+
2427
[*.cs]
2528
#### .NET Coding Conventions ####
2629

@@ -143,7 +146,7 @@ csharp_indent_labels = one_less_than_current
143146
csharp_indent_switch_labels = true
144147

145148
# Space preferences
146-
csharp_space_after_cast = false
149+
csharp_space_after_cast = true
147150
csharp_space_after_colon_in_inheritance_clause = true
148151
csharp_space_after_comma = true
149152
csharp_space_after_dot = false

.github/workflows/dotnet.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CI-dotnet
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "**.cs"
7+
- "**.csproj"
8+
branches: [ master ]
9+
10+
# Allows you to run this workflow manually from the Actions tab
11+
workflow_dispatch:
12+
inputs:
13+
reason:
14+
description: 'The reason for running the workflow'
15+
required: true
16+
default: 'Force run CI'
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
name: Code analysis
22+
steps:
23+
- uses: actions/checkout@v2
24+
25+
- name: Setup dotnet
26+
uses: actions/setup-dotnet@v1
27+
with:
28+
dotnet-version: '3.1.x'
29+
30+
- name: Dotnet format annotations
31+
uses: xt0rted/dotnet-format-problem-matcher@v1
32+
33+
- name: Setup dotnet-format tool
34+
run: dotnet tool install -g dotnet-format --version 5.0.\*
35+
36+
- name: Run dotnet format
37+
run: dotnet format --check

code/gamemode/Game.Util.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using System.Collections.Generic;
21
using Sandbox;
2+
using System.Collections.Generic;
33
using TTTReborn.Player;
44

55
namespace TTTReborn.Gamemode

code/gamemode/Game.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
using System;
21
using Sandbox;
3-
4-
using TTTReborn.UI;
2+
using System;
53
using TTTReborn.Player;
64
using TTTReborn.Rounds;
5+
using TTTReborn.UI;
76

87
namespace TTTReborn.Gamemode
98
{
@@ -105,7 +104,7 @@ private async void StartGameTimer()
105104

106105
await GameTask.DelaySeconds(1);
107106
}
108-
catch(Exception e)
107+
catch (Exception e)
109108
{
110109
if (e.Message.Trim() == "A task was canceled.")
111110
{

code/items/equipments/TTTEquipment.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using System;
21
using Sandbox;
3-
2+
using System;
43
using TTTReborn.Player;
54

65
namespace TTTReborn.Items

code/items/weapons/AmmoType.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace TTTReborn.Items
1+
namespace TTTReborn.Items
22
{
33
public enum AmmoType
44
{

code/items/weapons/Knife.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Sandbox;
1+
using Sandbox;
22

33
namespace TTTReborn.Items
44
{

code/items/weapons/Pistol.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Sandbox;
1+
using Sandbox;
22

33
namespace TTTReborn.Items
44
{

code/items/weapons/SMG.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Sandbox;
1+
using Sandbox;
22

33
namespace TTTReborn.Items
44
{

code/items/weapons/Shotgun.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Sandbox;
1+
using Sandbox;
22

33
using TTTReborn.Player;
44

code/items/weapons/TTTWeapon.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
using System;
21
using Sandbox;
3-
2+
using System;
43
using TTTReborn.Player;
54
using TTTReborn.UI;
65

code/items/weapons/ViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Sandbox;
1+
using Sandbox;
22
using System;
33

44
namespace TTTReborn.Items

code/items/weapons/WeaponFunctions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1+
using Sandbox;
12
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45

5-
using Sandbox;
6-
76
namespace TTTReborn.Items
87
{
98
public static class WeaponFunctions

code/player/Inventory.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
using System;
2-
using System.Linq;
31
using Sandbox;
4-
2+
using System;
3+
using System.Linq;
54
using TTTReborn.Items;
65

76
namespace TTTReborn.Player

code/player/PlayerCorpse.cs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
1-
using Sandbox;
1+
using Sandbox;
22

33
namespace TTTReborn.Player
44
{
5-
public partial class PlayerCorpse : ModelEntity
6-
{
7-
public TTTPlayer Player { get; set; }
5+
public partial class PlayerCorpse : ModelEntity
6+
{
7+
public TTTPlayer Player { get; set; }
88

9-
[Net]
10-
public bool IsIdentified { get; set; } = false;
9+
[Net]
10+
public bool IsIdentified { get; set; } = false;
1111

12-
public PlayerCorpse()
13-
{
14-
MoveType = MoveType.Physics;
15-
UsePhysicsCollision = true;
12+
public PlayerCorpse()
13+
{
14+
MoveType = MoveType.Physics;
15+
UsePhysicsCollision = true;
1616

17-
SetInteractsAs(CollisionLayer.Debris);
18-
SetInteractsWith(CollisionLayer.WORLD_GEOMETRY);
19-
SetInteractsExclude(CollisionLayer.Player | CollisionLayer.Debris);
17+
SetInteractsAs(CollisionLayer.Debris);
18+
SetInteractsWith(CollisionLayer.WORLD_GEOMETRY);
19+
SetInteractsExclude(CollisionLayer.Player | CollisionLayer.Debris);
2020

21-
IsIdentified = false;
22-
}
21+
IsIdentified = false;
22+
}
2323

24-
public void CopyFrom(TTTPlayer player)
25-
{
26-
SetModel(player.GetModelName());
27-
TakeDecalsFrom(player);
24+
public void CopyFrom(TTTPlayer player)
25+
{
26+
SetModel(player.GetModelName());
27+
TakeDecalsFrom(player);
2828

29-
this.CopyBonesFrom(player);
30-
this.SetRagdollVelocityFrom(player);
29+
this.CopyBonesFrom(player);
30+
this.SetRagdollVelocityFrom(player);
3131

32-
foreach (Entity child in player.Children)
33-
{
34-
if (child is ModelEntity e)
35-
{
36-
string model = e.GetModelName();
32+
foreach (Entity child in player.Children)
33+
{
34+
if (child is ModelEntity e)
35+
{
36+
string model = e.GetModelName();
3737

38-
if (model != null && !model.Contains("clothes"))
39-
{
40-
continue;
41-
}
38+
if (model != null && !model.Contains("clothes"))
39+
{
40+
continue;
41+
}
4242

43-
ModelEntity clothing = new ModelEntity();
44-
clothing.SetModel(model);
45-
clothing.SetParent(this, true);
46-
}
47-
}
48-
}
43+
ModelEntity clothing = new ModelEntity();
44+
clothing.SetModel(model);
45+
clothing.SetParent(this, true);
46+
}
47+
}
48+
}
4949

50-
public void ApplyForceToBone(Vector3 force, int forceBone)
51-
{
52-
PhysicsGroup.AddVelocity(force);
50+
public void ApplyForceToBone(Vector3 force, int forceBone)
51+
{
52+
PhysicsGroup.AddVelocity(force);
5353

5454
if (forceBone < 0)
5555
{
@@ -67,5 +67,5 @@ public void ApplyForceToBone(Vector3 force, int forceBone)
6767
PhysicsGroup.AddVelocity(force);
6868
}
6969
}
70-
}
70+
}
7171
}

code/player/TTTPlayer.Ammo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Sandbox;
1+
using Sandbox;
22
using System;
33
using System.Collections.Generic;
44

@@ -18,7 +18,7 @@ public void ClearAmmo()
1818

1919
public int AmmoCount(AmmoType type)
2020
{
21-
int iType = (int)type;
21+
int iType = (int) type;
2222

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

3131
public bool SetAmmo(AmmoType type, int amount)
3232
{
33-
int iType = (int)type;
33+
int iType = (int) type;
3434

3535
if (!Host.IsServer || Ammo == null)
3636
{

code/player/TTTPlayer.Clothes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Sandbox;
1+
using Sandbox;
22
using System.Collections.Generic;
33

44
namespace TTTReborn.Player

code/player/TTTPlayer.Commands.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
using Sandbox;
12
using System;
2-
using System.Linq;
33
using System.Collections.Generic;
4-
using Sandbox;
5-
4+
using System.Linq;
65
using TTTReborn.Items;
76
using TTTReborn.Roles;
87

code/player/TTTPlayer.Confirmation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Sandbox;
1+
using Sandbox;
22

33
namespace TTTReborn.Player
44
{

code/player/TTTPlayer.FallDamage.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using System;
21
using Sandbox;
2+
using System;
33

44
namespace TTTReborn.Player
55
{
@@ -40,9 +40,9 @@ public void OnPlayerHitGround(float fallingHeight)
4040
{
4141
Attacker = this,
4242
Body = PhysicsBody,
43-
Damage = (float)Math.Round(0.15f * (fallingHeight - FALLING_OBLIGINGNESS)),
43+
Damage = (float) Math.Round(0.15f * (fallingHeight - FALLING_OBLIGINGNESS)),
4444
Flags = DamageFlags.Fall,
45-
HitboxIndex = (int)HitboxIndex.LeftFoot,
45+
HitboxIndex = (int) HitboxIndex.LeftFoot,
4646
Position = Position
4747
};
4848

code/player/TTTPlayer.RPCs.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using Sandbox;
2-
32
using TTTReborn.Roles;
4-
using TTTReborn.UI;
53
using TTTReborn.Teams;
4+
using TTTReborn.UI;
65

76
namespace TTTReborn.Player
87
{

code/player/TTTPlayer.Roles.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
using TTTReborn.Roles;
1+
using TTTReborn.Roles;
22
using TTTReborn.Teams;
33

44
namespace TTTReborn.Player
55
{
66
partial class TTTPlayer
77
{
8-
public TTTRole Role {
8+
public TTTRole Role
9+
{
910
get
1011
{
1112
if (_role == null)

code/player/TTTPlayer.Status.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using System;
21
using Sandbox;
2+
using System;
33

44
namespace TTTReborn.Player
55
{

code/player/TTTPlayer.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using Sandbox;
2-
2+
using TTTReborn.Items;
33
using TTTReborn.Player.Camera;
44
using TTTReborn.Roles;
5-
using TTTReborn.Items;
65

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

4645
// sync roles
47-
using(Prediction.Off())
46+
using (Prediction.Off())
4847
{
4948
foreach (TTTPlayer player in Gamemode.Game.GetPlayers())
5049
{
@@ -78,7 +77,7 @@ public override void Respawn()
7877

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

81-
using(Prediction.Off())
80+
using (Prediction.Off())
8281
{
8382
ClientOnPlayerSpawned(this);
8483
ClientSetRole(To.Single(this), Role.Name);
@@ -115,7 +114,7 @@ public override void OnKilled()
115114
Inventory.DropActive();
116115
Inventory.DeleteContents();
117116

118-
using(Prediction.Off())
117+
using (Prediction.Off())
119118
{
120119
ClientOnPlayerDied(To.Single(this), this);
121120
}

0 commit comments

Comments
 (0)