Skip to content

Commit 9991dca

Browse files
committed
fix mh metric issues
1 parent 7aac9bb commit 9991dca

File tree

4 files changed

+53
-44
lines changed

4 files changed

+53
-44
lines changed

manualTests/miss_hit.cfg

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# style guide (https://florianschanda.github.io/miss_hit/style_checker.html)
12
line_length: 100
23
regex_function_name: "((test_[a-z]+)|[a-z]+)(([A-Z]){1}[A-Za-z]+)*"
3-
suppress_rule: "copyright_notice"
4+
suppress_rule: "copyright_notice"
5+
6+
# metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html)
7+
metric "cnest": limit 4
8+
metric "file_length": limit 500
9+
metric "cyc": limit 15
10+
metric "parameters": limit 5

miss_hit.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# styly guide (https://florianschanda.github.io/miss_hit/style_checker.html)
1+
# style guide (https://florianschanda.github.io/miss_hit/style_checker.html)
22
line_length: 100
33
regex_function_name: "[a-z]+(([A-Z]){1}[A-Za-z]+)*"
44
suppress_rule: "copyright_notice"

tests/miss_hit.cfg

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# style guide (https://florianschanda.github.io/miss_hit/style_checker.html)
12
line_length: 100
23
regex_function_name: "((test_[a-z]+)|[a-z]+)(([A-Z]){1}[A-Za-z]+)*"
3-
suppress_rule: "copyright_notice"
4+
suppress_rule: "copyright_notice"
5+
6+
# metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html)
7+
metric "cnest": limit 4
8+
metric "file_length": limit 500
9+
metric "cyc": limit 15
10+
metric "parameters": limit 5
Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function test_suite = test_setTargetPositionInSequence %#ok<*STOUT>
2-
2+
33
initEnv();
4-
4+
55
try % assignment of 'localfunctions' is necessary in Matlab >= 2016
66
test_functions = localfunctions(); %#ok<*NASGU>
77
catch % no problem; early Matlab versions can use initTestSuite fine
@@ -10,68 +10,63 @@
1010
end
1111

1212
function test_setTargetPositionInSequenceBasic()
13-
13+
1414
seqLength = 12;
1515
nbTarget = 3;
1616
forbiddenPos = [1 5 10];
17-
17+
1818
% Create a hundred draws of targer positiona and ensure that
1919
% - the forbidden position are never drawn
2020
% - the interval between target is superior to 1
2121
for i = 1:100
2222
chosenPositions(i, :) = setTargetPositionInSequence(seqLength, nbTarget, forbiddenPos);
2323
end
24-
24+
2525
assertFalse(any(ismember(chosenPositions(:), forbiddenPos)));
26-
26+
2727
interval = abs(diff(chosenPositions, [], 2));
2828
assertTrue(all(interval(:) > 1));
29-
29+
3030
end
3131

3232
function initEnv
33-
34-
octaveVersion = '4.0.3';
35-
matlabVersion = '8.6.0';
36-
37-
installlist = {'io', 'statistics', 'image'};
38-
33+
34+
installlist = {'io', 'statistics'};
35+
3936
if isOctave
40-
41-
% Exit if min version is not satisfied
42-
if ~compare_versions(OCTAVE_VERSION, octaveVersion, '>=')
43-
error('Minimum required Octave version: %s', octaveVersion);
44-
end
45-
37+
4638
for ii = 1:length(installlist)
39+
40+
packageName = installlist{ii};
41+
4742
try
4843
% Try loading Octave packages
49-
disp(['loading ' installlist{ii}]);
50-
pkg('load', installlist{ii});
51-
44+
disp(['loading ' packageName]);
45+
pkg('load', packageName);
46+
5247
catch
53-
errorcount = 1;
54-
while errorcount % Attempt twice in case installation fails
55-
try
56-
pkg('install', '-forge', installlist{ii});
57-
pkg('load', installlist{ii});
58-
errorcount = 0;
59-
catch err
60-
errorcount = errorcount + 1;
61-
if errorcount > 2
62-
error(err.message);
63-
end
64-
end
65-
end
48+
tryInstallFromForge(packageName);
6649
end
6750
end
51+
52+
end
53+
54+
end
6855

69-
else % MATLAB ----------------------------
70-
71-
if verLessThan('matlab', matlabVersion)
72-
error('Sorry, minimum required version is R2017b. :(');
56+
function tryInstallFromForge(packageName)
57+
58+
errorcount = 1;
59+
while errorcount % Attempt twice in case installation fails
60+
try
61+
pkg('install', '-forge', packageName);
62+
pkg('load', packageName);
63+
errorcount = 0;
64+
catch err
65+
errorcount = errorcount + 1;
66+
if errorcount > 2
67+
error(err.message);
68+
end
7369
end
74-
7570
end
76-
71+
7772
end

0 commit comments

Comments
 (0)