Showing 6 of 18 total issues
Method AffectTroops
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
Open
public static (TroopStatistics Statistics, List<WeakReference<Agent>> AffectedAgents) AffectTroops(Agent causingAgent, Settings settings)
{
var vec2Pos = causingAgent.Position.AsVec2;
var team = causingAgent.Team;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method AffectTroops
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static (TroopStatistics Statistics, List<WeakReference<Agent>> AffectedAgents) AffectTroops(Agent causingAgent, Settings settings)
{
var vec2Pos = causingAgent.Position.AsVec2;
var team = causingAgent.Team;
Method ShowDetailedMessage
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static void ShowDetailedMessage(TroopStatistics troopsStatistics, bool showDetailedMessageText)
{
if (showDetailedMessageText)
{
InformationManager.DisplayMessage(new(Strings.AlliesInspired.SetTextVariable("INSPIRED", troopsStatistics.Inspired).ToString()));
Method DelayAndReact
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
protected virtual void DelayAndReact()
{
if (Settings is not { } settings) return;
foreach (var weakReference in _affectedAgents.ToList())
Avoid too many return
statements within this method. Open
Open
if (!state.CanInspire()) return;
Avoid too many return
statements within this method. Open
Open
if (!state.CanInspire(out _)) return;