Skip to content

Commit 27770bd

Browse files
HanSur94claude
andcommitted
fix(dashboard): reduce MultiStatusWidget nesting depth for lint
Extract threshold color derivation into private deriveColor method to stay within the project's max control nesting depth of 5. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3097878 commit 27770bd

1 file changed

Lines changed: 23 additions & 17 deletions

File tree

libs/Dashboard/MultiStatusWidget.m

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,8 @@ function refresh(obj)
5858
cx = (col + 0.5) / cols;
5959
cy = 1 - (row + 0.5) / rows;
6060

61-
% Determine color from sensor thresholds
6261
sensor = obj.Sensors{i};
63-
color = okColor;
64-
if ~isempty(sensor) && ~isempty(sensor.Y)
65-
val = sensor.Y(end);
66-
if ~isempty(sensor.ThresholdRules)
67-
for k = 1:numel(sensor.ThresholdRules)
68-
rule = sensor.ThresholdRules{k};
69-
if ~isempty(rule.Color)
70-
if rule.IsUpper && val >= rule.Value
71-
color = rule.Color;
72-
elseif ~rule.IsUpper && val <= rule.Value
73-
color = rule.Color;
74-
end
75-
end
76-
end
77-
end
78-
end
62+
color = obj.deriveColor(sensor, okColor);
7963

8064
% Draw indicator
8165
r = 0.3 / max(cols, rows);
@@ -128,6 +112,28 @@ function refresh(obj)
128112
end
129113
end
130114

115+
methods (Access = private)
116+
function color = deriveColor(~, sensor, defaultColor)
117+
color = defaultColor;
118+
if isempty(sensor) || isempty(sensor.Y)
119+
return;
120+
end
121+
val = sensor.Y(end);
122+
if isempty(sensor.ThresholdRules)
123+
return;
124+
end
125+
for k = 1:numel(sensor.ThresholdRules)
126+
rule = sensor.ThresholdRules{k};
127+
if isempty(rule.Color), continue; end
128+
if rule.IsUpper && val >= rule.Value
129+
color = rule.Color;
130+
elseif ~rule.IsUpper && val <= rule.Value
131+
color = rule.Color;
132+
end
133+
end
134+
end
135+
end
136+
131137
methods (Static)
132138
function obj = fromStruct(s)
133139
obj = MultiStatusWidget();

0 commit comments

Comments
 (0)