Skip to content

Commit

Permalink
ci: set up lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nattb8 committed May 28, 2024
1 parent 968ba19 commit faa898f
Show file tree
Hide file tree
Showing 45 changed files with 189 additions and 125 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
#################################
#################################
## Super Linter GitHub Actions ##
#################################
#################################
name: Lint Code Base

#############################
# Start the job on all push #
#############################
on:
push:
branches-ignore: [main]
# Remove the line above to run when pushing to master
pull_request:
branches: [main]

###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Lint Code Base
# Set the agent to run on
runs-on: ubuntu-latest

############################################
# Grant status permission for MULTI_STATUS #
############################################
permissions:
contents: read
packages: read
statuses: write

##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v3
with:
# Full git history is needed to get a proper
# list of changed files within `super-linter`
fetch-depth: 0

################################
# Run Linter against code base #
################################
- name: Lint Code Base
uses: github/super-linter@v5
env:
VALIDATE_ALL_CODEBASE: true
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILTER_REGEX_EXCLUDE: (.*mint-backend/dest/.*|.*json-server/dest/.*)
VALIDATE_MARKDOWN: false
VALIDATE_GITLEAKS: false
VALIDATE_JSCPD: false
6 changes: 3 additions & 3 deletions Assets/Core/Scripts/EventSystem/AppPauseDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public class AppPauseDetector : MonoBehaviour
{
[SerializeField]
AbstractGameEvent m_PauseEvent;

/// <summary>
/// Returns the current pause state of the application
/// </summary>
public bool IsPaused { get; private set; }

void OnApplicationFocus(bool hasFocus)
{
IsPaused = !hasFocus;
Expand All @@ -29,7 +29,7 @@ void OnApplicationFocus(bool hasFocus)
void OnApplicationPause(bool pauseStatus)
{
IsPaused = pauseStatus;

if (IsPaused)
m_PauseEvent.Raise();
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/Core/Scripts/StateMachine/AbstractState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public abstract class AbstractState : IState
/// </summary>
public virtual string Name { get; set; }

readonly List<ILink> m_Links = new ();
readonly List<ILink> m_Links = new();

public virtual void Enter()
{
Expand Down Expand Up @@ -74,7 +74,7 @@ public void EnableLinks()
link.Enable();
}
}

public void DisableLinks()
{
foreach (var link in m_Links)
Expand Down
2 changes: 1 addition & 1 deletion Assets/Core/Scripts/StateMachine/DelayState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class DelayState : AbstractState
public override string Name => nameof(DelayState);

readonly float m_DelayInSeconds;

/// <param name="delayInSeconds">delay in seconds</param>
public DelayState(float delayInSeconds)
{
Expand Down
8 changes: 4 additions & 4 deletions Assets/Core/Scripts/StateMachine/EventLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class EventLink : ILink, IGameEventListener
IState m_NextState;
AbstractGameEvent m_GameEvent;
bool m_EventRaised;

/// <param name="gameEvent">the event this link listens to</param>
/// <param name="nextState">the next state</param>
public EventLink(AbstractGameEvent gameEvent, IState nextState)
Expand All @@ -25,13 +25,13 @@ public bool Validate(out IState nextState)
{
nextState = null;
bool result = false;

if (m_EventRaised)
{
nextState = m_NextState;
result = true;
}

return result;
}

Expand All @@ -45,7 +45,7 @@ public void Enable()
m_GameEvent.AddListener(this);
m_EventRaised = false;
}

public void Disable()
{
m_GameEvent.RemoveListener(this);
Expand Down
8 changes: 4 additions & 4 deletions Assets/Core/Scripts/StateMachine/ILink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public interface ILink
/// <param name="nextState">The next state that this link points to</param>
/// <returns>true: the link is open for transition</returns>
bool Validate(out IState nextState);

/// <summary>
/// Activates the link
/// </summary>
void Enable(){}
void Enable() { }

/// <summary>
/// Deactivates the link
/// </summary>
void Disable(){}
void Disable() { }
}
}
2 changes: 1 addition & 1 deletion Assets/Core/Scripts/StateMachine/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace HyperCasual.Core
public class Link : ILink
{
readonly IState m_NextState;

/// <param name="nextState">the next state</param>
public Link(IState nextState)
{
Expand Down
6 changes: 3 additions & 3 deletions Assets/Core/Scripts/StateMachine/LoadSceneState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class LoadSceneState : AbstractState
readonly string m_Scene;
readonly SceneController m_SceneController;
readonly Action m_OnLoadCompleted;

public override string Name => $"{nameof(LoadSceneState)}: {m_Scene}";

/// <param name="sceneController">The SceneController for the current loading operation</param>
/// <param name="scene">The path to the scene</param>
/// <param name="onLoadCompleted">An action that is invoked when scene loading is finished</param>
Expand All @@ -25,7 +25,7 @@ public LoadSceneState(SceneController sceneController, string scene, Action onLo
m_SceneController = sceneController;
m_OnLoadCompleted = onLoadCompleted;
}

public override IEnumerator Execute()
{
yield return m_SceneController.LoadScene(m_Scene);
Expand Down
6 changes: 3 additions & 3 deletions Assets/Core/Scripts/StateMachine/PauseState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace HyperCasual.Core
public class PauseState : AbstractState
{
readonly Action m_OnPause;

public override string Name => $"{nameof(PauseState)}";

/// <param name="onPause">The action that is invoked when the game loop paused</param>
public PauseState(Action onPause)
{
Expand All @@ -30,7 +30,7 @@ public override IEnumerator Execute()
{
yield return null;
}

public override void Exit()
{
Time.timeScale = 1f;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Core/Scripts/StateMachine/State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace HyperCasual.Core
public class State : AbstractState
{
readonly Action m_OnExecute;

/// <param name="onExecute">An event that is invoked when the state is executed</param>
public State(Action onExecute)
{
Expand Down
28 changes: 14 additions & 14 deletions Assets/Core/Scripts/StateMachine/StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace HyperCasual.Core
public class StateMachine
{
public IState CurrentState { get; private set; }

/// <summary>
/// Finalizes the previous state and then runs the new state
/// </summary>
Expand All @@ -22,12 +22,12 @@ public virtual void SetCurrentState(IState state)
if (state == null)
throw new ArgumentNullException(nameof(state));

if (CurrentState != null && m_CurrentPlayCoroutine != null)
if (CurrentState != null && m_CurrentPlayCoroutine != null)
{
//interrupt currently executing state
Skip();
}

CurrentState = state;
Coroutines.StartCoroutine(Play());
}
Expand All @@ -43,14 +43,14 @@ IEnumerator Play()
if (!m_PlayLock)
{
m_PlayLock = true;

CurrentState.Enter();

//keep a ref to execute coroutine of the current state
//to support stopping it later.
m_CurrentPlayCoroutine = Coroutines.StartCoroutine(CurrentState.Execute());
yield return m_CurrentPlayCoroutine;

m_CurrentPlayCoroutine = null;
}
}
Expand All @@ -63,7 +63,7 @@ void Skip()
{
if (CurrentState == null)
throw new Exception($"{nameof(CurrentState)} is null!");

if (m_CurrentPlayCoroutine != null)
{
Coroutines.StopCoroutine(ref m_CurrentPlayCoroutine);
Expand All @@ -73,24 +73,24 @@ void Skip()
m_PlayLock = false;
}
}

public virtual void Run(IState state)
{
SetCurrentState(state);
Run();
}

Coroutine m_LoopCoroutine;
/// <summary>
/// Turns on the main loop of the StateMachine.
/// This method does not resume previous state if called after Stop()
/// and the client needs to set the state manually.
/// </summary>
public virtual void Run()
public virtual void Run()
{
if (m_LoopCoroutine != null) //already running
return;

m_LoopCoroutine = Coroutines.StartCoroutine(Loop());
}

Expand All @@ -101,13 +101,13 @@ public void Stop()
{
if (m_LoopCoroutine == null) //already stopped
return;
if (CurrentState != null && m_CurrentPlayCoroutine != null)

if (CurrentState != null && m_CurrentPlayCoroutine != null)
{
//interrupt currently executing state
Skip();
}

Coroutines.StopCoroutine(ref m_LoopCoroutine);
CurrentState = null;
}
Expand All @@ -133,7 +133,7 @@ protected virtual IEnumerator Loop()
}
CurrentState.DisableLinks();
SetCurrentState(nextState);
CurrentState.EnableLinks();
CurrentState.EnableLinks();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/Core/Scripts/StateMachine/UnloadLastSceneState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public UnloadLastSceneState(SceneController sceneController)
{
m_SceneController = sceneController;
}

public override IEnumerator Execute()
{
yield return m_SceneController.UnloadLastScene();
Expand Down
4 changes: 2 additions & 2 deletions Assets/Core/Scripts/UI/UIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public class UIManager : AbstractSingleton<UIManager>

View m_CurrentView;

readonly Stack<View> m_History = new ();
readonly Stack<View> m_History = new();

void Start()
{
m_Views = m_Root.GetComponentsInChildren<View>(true).ToList();
Init();

// m_ViewLayer.ResizeToSafeArea(m_Canvas);
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/Core/Scripts/UI/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public abstract class View : MonoBehaviour
public virtual void Initialize()
{
}

/// <summary>
/// Makes the View visible
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions Assets/Core/Scripts/Utils/CoroutineUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace HyperCasual.Core
/// It instantiates a hidden GameObject and adds an empty MonoBehaviour component
/// to it that is used for starting/stopping coroutines.
/// </summary>
public static class Coroutines
public static class Coroutines
{
public class CoroutineHelper : MonoBehaviour { }

static MonoBehaviour s_Instance;

static MonoBehaviour Instance
Expand All @@ -32,7 +32,7 @@ static MonoBehaviour Instance
return s_Instance;
}
}

/// <summary>
/// Starts a coroutine
/// </summary>
Expand Down
Loading

0 comments on commit faa898f

Please sign in to comment.