Skip to content

Commit 2154d0d

Browse files
HanSur94claude
andcommitted
ci: enforce MISS_HIT complexity metrics and enable more style rules
Add mh_metric --ci to CI workflow with thresholds for cyclomatic complexity, nesting depth, parameter count, and function length. Un-suppress 7 low-count style rules and auto-fix violations across the codebase (whitespace around brackets, semicolons, colons, assignments, continuations, and operator placement). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f6ddb44 commit 2154d0d

64 files changed

Lines changed: 117 additions & 113 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
- name: Run linter
2626
run: mh_lint libs/ tests/ examples/
2727

28+
- name: Run complexity metrics
29+
run: mh_metric --ci libs/ tests/ examples/
30+
2831
build-mex:
2932
name: Build MEX (Linux)
3033
if: github.event_name != 'schedule'

examples/example_dashboard_all_widgets.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
% --- Machine mode state channel (idle=0, running=1, maintenance=2) ---
2727
modeChangeTimes = [0, 3600, 7200, 28800, 36000, 72000, 79200, 82800];
28-
modeValues = [0, 1, 1, 2, 1, 0, 1, 1 ];
28+
modeValues = [0, 1, 1, 2, 1, 0, 1, 1];
2929

3030
scMode = StateChannel('machine');
3131
scMode.X = modeChangeTimes;

examples/example_dashboard_engine.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
% Machine mode state channel: idle(0) -> running(1) -> idle(0) -> running(1)
2222
scMode = StateChannel('machine');
2323
scMode.X = [0, 7200, 43200, 57600];
24-
scMode.Y = [0, 1, 0, 1 ];
24+
scMode.Y = [0, 1, 0, 1];
2525

2626
% Temperature sensor with mode-dependent thresholds
2727
sTemp = Sensor('T-401', 'Name', 'Temperature');

examples/example_dashboard_live.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ function example_dashboard_live_run()
105105
'Alignment', 'left');
106106

107107
% Sensor-bound: auto-derives value + trend from Sensor.Y
108-
d.addWidget('number', 'Title', 'Temperature',...
108+
d.addWidget('number', 'Title', 'Temperature', ...
109109
'Position', [5 1 5 2], ...
110110
'Sensor', sTemp, ...
111111
'Format', '%.1f');
112112

113-
d.addWidget('number', 'Title', 'Pressure',...
113+
d.addWidget('number', 'Title', 'Pressure', ...
114114
'Position', [10 1 5 2], ...
115115
'Sensor', sPress, ...
116116
'Format', '%.0f');

examples/example_datetime.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
n = 50000000;
99
x = datenum(2024,1,1) + (0:n-1)/86400; % ~579 days
1010
t = (0:n-1) / 86400; % time in days
11-
y = 20 + 5*sin(t * 2*pi - pi/2) ... % daily cycle (peak at midday)
12-
+ 0.3*sin(t * 2*pi*24) ... % hourly ripple
13-
+ 0.1*randn(1,n); % sensor noise
11+
y = 20 + 5*sin(t * 2*pi - pi/2) + ... % daily cycle (peak at midday)
12+
0.3*sin(t * 2*pi*24) + ... % hourly ripple
13+
0.1*randn(1,n); % sensor noise
1414

1515
fprintf('Datetime example: %dM points (~579 days, 1-second resolution)...\n', n/1e6);
1616

examples/example_sensor_detail_dock.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,9 @@
204204
% Simple moving-window Pearson correlation (no toolbox needed)
205205
c = nan(1, numel(x));
206206
half = floor(w / 2);
207-
for i = half+1 : numel(x)-half
208-
xi = x(i-half : i+half);
209-
yi = y(i-half : i+half);
207+
for i = half+1:numel(x)-half
208+
xi = x(i-half:i+half);
209+
yi = y(i-half:i+half);
210210
xi = xi - mean(xi);
211211
yi = yi - mean(yi);
212212
denom = sqrt(sum(xi.^2) * sum(yi.^2));

examples/example_stress_test.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
gasNoise = [5 4 3 2 1.5 8];
165165
gasSizes = [3e6 3e6 2e6 2e6 2e6 3e6];
166166
gasWarnOff = [25 20 15 8 5 40];
167-
gasAlarmOff= [40 35 25 14 10 65];
167+
gasAlarmOff = [40 35 25 14 10 65];
168168

169169
for gi = 1:6
170170
s = make_sensor(lower(gasNames{gi}), [gasNames{gi} ' Flow'], ...

examples/example_vibration.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
f_shaft = rpm / 60;
1414
f_bearing = 5.2 * f_shaft; % BPFO frequency
1515

16-
y = 0.5 * sin(2*pi*f_shaft*x) ... % 1x shaft
17-
+ 0.2 * sin(2*pi*2*f_shaft*x) ... % 2x harmonic
18-
+ 0.05 * randn(1, n); % noise floor
16+
y = 0.5 * sin(2*pi*f_shaft*x) + ... % 1x shaft
17+
0.2 * sin(2*pi*2*f_shaft*x) + ... % 2x harmonic
18+
0.05 * randn(1, n); % noise floor
1919

2020
% Add intermittent bearing defect bursts
2121
burst_times = [50 120 250 350]; % seconds

examples/example_widget_fastsense.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
% Machine mode state channel (idle=0, running=1)
3232
scMode = StateChannel('machine');
3333
scMode.X = [0, 7200, 43200, 57600];
34-
scMode.Y = [0, 1, 0, 1 ];
34+
scMode.Y = [0, 1, 0, 1];
3535

3636
% Temperature sensor — state-dependent thresholds
3737
sTemp = Sensor('T-401', 'Name', 'Temperature', 'Units', [char(176) 'C']);

libs/Dashboard/DashboardBuilder.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ function drawGrid(obj, theme)
833833
'Color', 'none', ...
834834
'Visible', 'off', ...
835835
'HitTest', 'off');
836-
try set(hAx, 'PickableParts', 'none'); catch, end
836+
try set(hAx, 'PickableParts', 'none'); catch , end
837837
hold(hAx, 'on');
838838

839839
gc = theme.GridLineColor;
@@ -854,7 +854,7 @@ function drawGrid(obj, theme)
854854
end
855855
hL = line(hAx, xV, yV, 'Color', gc, ...
856856
'LineStyle', ':', 'LineWidth', 0.5, 'HitTest', 'off');
857-
try set(hL, 'PickableParts', 'none'); catch, end
857+
try set(hL, 'PickableParts', 'none'); catch , end
858858

859859
% Build all horizontal lines as a single NaN-separated line
860860
nH = rows + 1;
@@ -872,7 +872,7 @@ function drawGrid(obj, theme)
872872
end
873873
hL = line(hAx, xH, yH, 'Color', gc, ...
874874
'LineStyle', ':', 'LineWidth', 0.5, 'HitTest', 'off');
875-
try set(hL, 'PickableParts', 'none'); catch, end
875+
try set(hL, 'PickableParts', 'none'); catch , end
876876

877877
hold(hAx, 'off');
878878
obj.hGridOverlay = hAx;

0 commit comments

Comments
 (0)