Skip to content
This repository has been archived by the owner on Oct 20, 2021. It is now read-only.

Commit

Permalink
Add linting (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Brynes authored Feb 28, 2020
1 parent b9cb368 commit 979cf09
Show file tree
Hide file tree
Showing 62 changed files with 169 additions and 97 deletions.
18 changes: 11 additions & 7 deletions .buildkite/premerge.steps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# You may find the example pipeline steps listed here helpful: https://buildkite.com/docs/pipelines/defining-steps#example-pipeline but please
# note that the setup is already done, so you should not manually adjust anything through the BuildKite interface.
#
common: &common
windows: &windows
agents:
- "capable_of_building=gdk-for-unity"
- "environment=production"
Expand Down Expand Up @@ -66,10 +66,14 @@ macos: &macos
dag: true

steps:
- label: ":debian: ~ lint :lint-roller:"
command: bash -c ci/lint.sh
<<: *linux

- label: ":windows: ~ test"
id: "test"
command: bash -c ci/test.sh
<<: *common
<<: *windows
artifact_paths:
- logs/**/*

Expand All @@ -89,7 +93,7 @@ steps:

- label: ":windows: ~ build :android:"
command: bash -c .shared-ci/scripts/build-worker.sh
<<: *common
<<: *windows
artifact_paths:
- logs/**/*
env:
Expand All @@ -112,7 +116,7 @@ steps:

- label: ":windows: ~ build UnityClient mono"
command: bash -c .shared-ci/scripts/build-worker.sh
<<: *common
<<: *windows
artifact_paths:
- logs/**/*
env:
Expand All @@ -122,7 +126,7 @@ steps:

- label: ":windows: ~ build UnityClient il2cpp"
command: bash -c .shared-ci/scripts/build-worker.sh
<<: *common
<<: *windows
artifact_paths:
- logs/**/*
env:
Expand All @@ -132,7 +136,7 @@ steps:

- label: ":windows: ~ build UnityGameLogic mono"
command: bash -c .shared-ci/scripts/build-worker.sh
<<: *common
<<: *windows
artifact_paths:
- logs/**/*
env:
Expand All @@ -142,7 +146,7 @@ steps:

- label: ":windows: ~ build SimulatedPlayerCoordinator mono"
command: bash -c .shared-ci/scripts/build-worker.sh
<<: *common
<<: *windows
artifact_paths:
- logs/**/*
env:
Expand Down
31 changes: 31 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,37 @@ max_line_length = 120
[*.cs]
indent_size = 4

# New line preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true

# Indentation preferences
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left

# Space preferences
csharp_space_after_cast = true
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false

# Wrapping preferences
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true

[*.json]
indent_size = 2

Expand Down
21 changes: 1 addition & 20 deletions ci/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,7 @@ cd "$(dirname "$0")/../"

echo "--- Bootstrapping :boot:"

SHARED_CI_DIR="$(pwd)/.shared-ci"
CLONE_URL="[email protected]:spatialos/gdk-for-unity-shared-ci.git"
PINNED_SHARED_CI_BRANCH=$(cat ./ci/shared-ci.pinned | cut -d' ' -f 1)
PINNED_SHARED_CI_VERSION=$(cat ./ci/shared-ci.pinned | cut -d' ' -f 2)

# Clone the HEAD of the shared CI repo into ".shared-ci"

if [[ -d "${SHARED_CI_DIR}" ]]; then
rm -rf "${SHARED_CI_DIR}"
fi

mkdir "${SHARED_CI_DIR}"

# Workaround for being unable to clone a specific commit with depth of 1.
pushd "${SHARED_CI_DIR}"
git init
git remote add origin "${CLONE_URL}"
git fetch --depth 20 origin "${PINNED_SHARED_CI_BRANCH}"
git checkout "${PINNED_SHARED_CI_VERSION}"
popd
./ci/get-shared-ci.sh

# Clone the GDK for Unity repository

Expand Down
26 changes: 26 additions & 0 deletions ci/get-shared-ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -e -u -o pipefail

if [[ -n "${DEBUG-}" ]]; then
set -x
fi

SHARED_CI_DIR="$(pwd)/.shared-ci"
CLONE_URL="[email protected]:spatialos/gdk-for-unity-shared-ci.git"
PINNED_SHARED_CI_BRANCH=$(cat ./ci/shared-ci.pinned | cut -d' ' -f 1)
PINNED_SHARED_CI_VERSION=$(cat ./ci/shared-ci.pinned | cut -d' ' -f 2)

if [[ -d "${SHARED_CI_DIR}" ]]; then
rm -rf "${SHARED_CI_DIR}"
fi

mkdir "${SHARED_CI_DIR}"

# Clone the HEAD of the shared CI repo into ".shared-ci"
# Workaround for being unable to clone a specific commit with depth of 1.
pushd "${SHARED_CI_DIR}"
git init
git remote add origin "${CLONE_URL}"
git fetch --depth 20 origin "${PINNED_SHARED_CI_BRANCH}"
git checkout "${PINNED_SHARED_CI_VERSION}"
popd
12 changes: 12 additions & 0 deletions ci/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -e -u -o pipefail

if [[ -n "${DEBUG-}" ]]; then
set -x
fi

cd "$(dirname "$0")/.."

./ci/get-shared-ci.sh
./.shared-ci/scripts/lint.sh ./workers/unity --check
2 changes: 1 addition & 1 deletion ci/shared-ci.pinned
Original file line number Diff line number Diff line change
@@ -1 +1 @@
master a6c1fcd9562bf40160214acddc7e1a732a66faf4
master 7980ef5db74d8db47c0f683378a38d64accd2c0a
5 changes: 3 additions & 2 deletions workers/unity/Assets/Fps/Scripts/Animation/FpsAnimator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Fps.Movement;
using Fps.Movement;
using UnityEngine;

namespace Fps.Animation
Expand Down Expand Up @@ -43,7 +43,8 @@ private class AnimationBoolParameter
public bool LastValue;
}

[SerializeField] private AnimationSettings animationSettings = new AnimationSettings
[SerializeField]
private AnimationSettings animationSettings = new AnimationSettings
{
InterpolatePitchDuration = 0.1f,
InterpolateMovementDuration = 0.1f,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Fps.Movement;
using Fps.Movement;
using Fps.SchemaExtensions;
using Improbable.Gdk.Subscriptions;
using UnityEngine;
Expand Down
2 changes: 1 addition & 1 deletion workers/unity/Assets/Fps/Scripts/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Improbable.Fps.Editor")]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Fps.Movement;
using Fps.SchemaExtensions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;

namespace Fps.Config
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Fps.Guns;
using Fps.Guns;
using UnityEngine;

namespace Fps.Config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Fps.Config
namespace Fps.Config
{
public interface ISettingsPublisher
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Fps.WorldTiles;
using Fps.WorldTiles;
using UnityEngine;

namespace Fps.Config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Fps.UI;
using UnityEditor;
using UnityEngine;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using Fps.WorldTiles;
using UnityEditor;
using UnityEngine;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Fps.WorldTiles;
using UnityEditor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using UnityEngine.Rendering;

namespace Fps.Guns
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Fps.Guns
namespace Fps.Guns
{
public interface IRecoil
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ private struct BulletDetails
[SerializeField]
private float fullLengthShotThreshold = 50f;

[Tooltip("If false, the BarrelLerpThreshold will not be used.")] [SerializeField]
[Tooltip("If false, the BarrelLerpThreshold will not be used.")]
[SerializeField]
private bool barrelSnap = true;

private bool muzzleFlashNeedsRefresh;
Expand Down
15 changes: 10 additions & 5 deletions workers/unity/Assets/Fps/Scripts/Guns/Settings/GunSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public class GunSettings : ScriptableObject

[SerializeField] private bool isAutomatic;

[Tooltip("In 'Shots per second'. If <= 0, there will be no cooldown between shots.")] [SerializeField]
[Tooltip("In 'Shots per second'. If <= 0, there will be no cooldown between shots.")]
[SerializeField]
private float rateOfFire;

[SerializeField] [HideInInspector] private float shotCooldown;
Expand All @@ -29,16 +30,20 @@ public class GunSettings : ScriptableObject
[SerializeField] private float aimFov = 60;
[SerializeField] private float fovChangeTime = 0.1f;

[Tooltip("Bullets fired when not aiming will have this spread in meters at 50m range.")] [SerializeField]
[Tooltip("Bullets fired when not aiming will have this spread in meters at 50m range.")]
[SerializeField]
private float inaccuracyFromHip;

[Tooltip("Bullets fired when aiming will have this spread in meters at 50m range.")] [SerializeField]
[Tooltip("Bullets fired when aiming will have this spread in meters at 50m range.")]
[SerializeField]
private float inaccuracyWhileAiming;

[Tooltip("Whilst aiming, override the camera's Pitch Speed with this value.")] [SerializeField]
[Tooltip("Whilst aiming, override the camera's Pitch Speed with this value.")]
[SerializeField]
private float aimPitchSpeed = 1;

[Tooltip("Whilst aiming, override the camera's Yaw Speed with this value.")] [SerializeField]
[Tooltip("Whilst aiming, override the camera's Yaw Speed with this value.")]
[SerializeField]
private float aimYawSpeed = 1;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Fps.Health
namespace Fps.Health
{
public static class PlayerHealthSettings
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Fps.Config;
using Improbable.Gdk.Subscriptions;
using UnityEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public class ClientMovementDriver : GroundCheckingDriver
[SerializeField] [HideInInspector] private float transformUpdateDelta;
[SerializeField] [HideInInspector] private float rotationUpdateDelta;

[SerializeField] private MovementSettings movementSettings = new MovementSettings
[SerializeField]
private MovementSettings movementSettings = new MovementSettings
{
MovementSpeed = new MovementSpeedSettings
{
Expand All @@ -35,7 +36,8 @@ public class ClientMovementDriver : GroundCheckingDriver
InAirDamping = 1.0f
};

[SerializeField] private RotationConstraints rotationConstraints = new RotationConstraints
[SerializeField]
private RotationConstraints rotationConstraints = new RotationConstraints
{
XAxisRotation = true,
YAxisRotation = true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using Fps.Animation;
using Fps.Guns;
Expand Down Expand Up @@ -38,7 +38,8 @@ private struct CameraSettings
[SerializeField] private Transform pitchTransform;
[SerializeField] private new Camera camera;

[SerializeField] private CameraSettings cameraSettings = new CameraSettings
[SerializeField]
private CameraSettings cameraSettings = new CameraSettings
{
PitchSpeed = 1.0f,
YawSpeed = 1.0f,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;

namespace Fps.Movement
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;

namespace Fps.Movement
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public class ProxyMovementDriver : GroundCheckingDriver
[Require] private ClientRotationReader client;
#pragma warning restore 649

[SerializeField] private RotationConstraints rotationConstraints = new RotationConstraints
[SerializeField]
private RotationConstraints rotationConstraints = new RotationConstraints
{
XAxisRotation = true,
YAxisRotation = true,
Expand Down
Loading

0 comments on commit 979cf09

Please sign in to comment.