Avoid empty Unity message

Rule ND3202 API Usage / Unity

Unity messages are called by the runtime even if they don't contain any code.

How to fix

Remove matched methods to avoid unnecessary processing.

CQLinq source

This rule is written in CQLinq, C# LINQ over the NDepend code model. It ships with every new NDepend project: you can read it, adapt it, or use it as a starting point for your own custom rules.

// <Name>Avoid empty Unity message</Name>
// <Id>ND3202:AvoidEmptyUnityMessage</Id>
warnif count > 0
from t in Application.Types
where t.DeriveFrom("UnityEngine.MonoBehaviour".AllowNoMatch())
from m in t.InstanceMethods where 
   !m.IsConstructor &&
   !m.IsPropertyGetter &&
   !m.IsPropertySetter &&
    m.NbLinesOfCode == 0 &&
    m.SimpleNameEqualsAny("Start","Update","FixedUpdate","LateUpdate",
                           "OnGUI","OnDisable","OnEnable")
select new { 
  m, 
  Debt = 5.ToMinutes().ToDebt(),
  Severity = Severity.Low
 }

//<Expl>
// The *{0}* is an empty Unity message and is still called by the runtime.
// Comment it or remove it.
//</Expl>

//<Desc>
// Unity messages are called by the runtime even if they don't contain any code.
//</Desc>

//<HowToFix>
// Remove matched methods to avoid unnecessary processing.
//</HowToFix>

API Usage / Unity: all 9 items