Closed EmilyGraceSeville7cf closed 3 years ago
So the problem with the second file is basically the same that you encountered in #198.
When MISS_HIT encounters a parse error then weird things start to happen. The indenter in particular will get super confused; I should maybe disable any style checking if a parse error is encountered. So these messages are just not helpful.
If you fix the syntax error by moving the function at the end, i.e:
clear all;
n = 4;
x = [1 3 5 7]';
y = [2 2 4 4]';
for i = 1:n
for j = 1:n
X(i, j) = x(i)^(j - 1);
end
end
a = X^(-1) * y;
disp(a)
f(2, a)
f(4, a)
f(6, a)
function z = f(x, a)
n = size(a);
sum = 0;
for i = 1:1:n(1)
sum = sum + a(i) * x^(i - 1);
end
z = sum;
end
Then you'll get this output:
| clear all;
| ^^^^^ style: file does not appear to contain any copyright header
In potato.m, line 14
| disp(a)
| ^ style: end statement with a semicolon
In potato.m, line 16
| f(2, a)
| ^ style: end statement with a semicolon
In potato.m, line 17
| f(4, a)
| ^ style: end statement with a semicolon
In potato.m, line 18
| f(6, a)
| ^ style: end statement with a semicolon
In potato.m, line 20
| function z = f(x, a)
| ^ style: violates naming scheme for function
Which makes a lot more sense (i.e. it's happy with the indentation)
I'll use this ticket to remove the confusing style messages if a parse error is encountered.
Thank you for bringing this to my attention!
@alvinseville7cf this is fixed on master and will be in the next release. For your original code you now just get:
In test_1.m, line 1
| % Taken from issue #199 (by alvinseville7cf)
| ^ style: No copyright notice found in header
In test_1.m, line 16
| n = 4;
| ^ error: expected end of file, found IDENTIFIER instead
MISS_HIT Style Summary: 1 file(s) analysed, 1 style issue(s), 1 error(s)
When I implement #198 I will also improve the error message here, because it would be way more helpful to say something like "in-script functions are an Octave feature and are not valid MATLAB"
MISS_HIT Component affected Please choose one from:
Your operating system and Python version
python3 --version
3.8.7Describe the bug When I run
mh_style test.m
for:it outputs only this:
But when I run the same command for:
it outputs several indention issues:
It is confusing not only because these issues are not shown persistently but also indention rules are different from other language ones like in C#.