refactor: consolidate duplicate if (isNew) checks (S2589)

This commit is contained in:
Miha Kralj
2026-01-26 20:17:13 -08:00
parent 13a895b6b6
commit 8ac15f1efa
5 changed files with 17 additions and 37 deletions
+4 -8
View File
@@ -102,20 +102,16 @@ public sealed class Dchannel : ITValuePublisher
if (isNew)
{
_p_state = _state;
}
else
{
_state = _p_state;
}
if (isNew)
{
_index++;
if (_count < _period)
{
_count++;
}
}
else
{
_state = _p_state;
}
int bufIdx = (int)(_index % _period);
var (high, low) = GetValid(input.High, input.Low);
+4 -8
View File
@@ -221,20 +221,16 @@ public sealed class Fcb : ITValuePublisher
if (isNew)
{
_p_state = _state;
}
else
{
_state = _p_state;
}
if (isNew)
{
_index++;
if (_count < _period)
{
_count++;
}
}
else
{
_state = _p_state;
}
var (high, low) = GetValid(input.High, input.Low);
+4 -8
View File
@@ -101,20 +101,16 @@ public sealed class Mmchannel : ITValuePublisher
if (isNew)
{
_p_state = _state;
}
else
{
_state = _p_state;
}
if (isNew)
{
_index++;
if (_count < _period)
{
_count++;
}
}
else
{
_state = _p_state;
}
int bufIdx = (int)(_index % _period);
var (high, low) = GetValid(input.High, input.Low);
+4 -8
View File
@@ -197,20 +197,16 @@ public sealed class Pchannel : ITValuePublisher
if (isNew)
{
_p_state = _state;
}
else
{
_state = _p_state;
}
if (isNew)
{
_index++;
if (_count < _period)
{
_count++;
}
}
else
{
_state = _p_state;
}
int bufIdx = (int)(_index % _period);
var (high, low) = GetValid(input.High, input.Low);
+1 -5
View File
@@ -66,17 +66,13 @@ public sealed class Mgdi : AbstractBase
if (isNew)
{
_p_state = _state;
_state.Count++;
}
else
{
_state = _p_state;
}
if (isNew)
{
_state.Count++;
}
double price = input.Value;
if (!double.IsFinite(price))
{