← every case · 1000 · comments

1280-matlab_block_markers_sharing_their_line

MATLAB's %{ and %} open and close a block comment only when they are alone on their line, spaces aside. The %} followed by words inside the block closes nothing, and the %{ followed by words is an ordinary % comment, so the line under it is code. A counter that takes either symbol anywhere on its line closes the block early and opens one over the last line, and the two mistakes do not cancel

read ascloc.defaultcloc.docstring-as-codecodestats.defaultmezura.contentmezura.regionscc.defaulttokei.default
input.m
1codefunction z = f(x)
2comments%{
3comments%} not the end
4commentsz = x;
5comments%}
6comments%{ note
7codez = x + 1;

stringcommentthe tag around another language

What each tool answered

cloc.default ✗ fails

the %} with words after it on line 3 closes the block, so those words and line 4 count as code, and the %{ with words after it on line 6 opens one over line 7. With the words on those two lines written as plain text the file reads right

the rules ask7 lines · 0 blanks · 2 code · 5 comments
it answers7 lines · 0 blanks · 3 code · 4 comments

cloc --json --config /tmp/linejudge-empty-file cases/1000-comments/1280-matlab_block_markers_sharing_their_line/input.m

cloc.default ✗ fails

--strip-str-comments

the %} with words after it on line 3 closes the block, so those words and line 4 count as code, and the %{ with words after it on line 6 opens one over line 7. With the words on those two lines written as plain text the file reads right

the rules ask7 lines · 0 blanks · 2 code · 5 comments
it answers7 lines · 0 blanks · 3 code · 4 comments

cloc --json --config /tmp/linejudge-empty-file cases/1000-comments/1280-matlab_block_markers_sharing_their_line/input.m --strip-str-comments

cloc.docstring-as-code ✗ fails

the %} with words after it on line 3 closes the block, so those words and line 4 count as code, and the %{ with words after it on line 6 opens one over line 7. With the words on those two lines written as plain text the file reads right

the rules ask7 lines · 0 blanks · 2 code · 5 comments
it answers7 lines · 0 blanks · 3 code · 4 comments

cloc --json --config /tmp/linejudge-empty-file cases/1000-comments/1280-matlab_block_markers_sharing_their_line/input.m --docstring-as-code

codestats.default ✓ agrees
the rules ask7 lines · 0 blanks · 2 code · 5 comments
it answers7 lines · 0 blanks · 2 code · 5 comments

codestats cases/1000-comments/1280-matlab_block_markers_sharing_their_line/input.m --output json-compact --include-generated --no-gitignore --hidden --no-config

mezura.content ✓ agrees
the rules ask7 lines · 2 code · 3 comments · 2 extra
it answers7 lines · 2 code · 3 comments · 2 extra

mezura cases/1000-comments/1280-matlab_block_markers_sharing_their_line/input.m --output json --hide timing --no-default-config --no-local --counting content

mezura.region ✓ agrees
the rules ask7 lines · 0 blanks · 2 code · 5 comments
it answers7 lines · 0 blanks · 2 code · 5 comments

mezura cases/1000-comments/1280-matlab_block_markers_sharing_their_line/input.m --output json --hide timing --no-default-config --no-local --counting region

scc.default ✗ fails

the %} with words after it on line 3 closes the block, so those words and line 4 count as code, and the %{ with words after it on line 6 opens one over line 7. With the words on those two lines written as plain text the file reads right

the rules ask7 lines · 0 blanks · 2 code · 5 comments
it answers7 lines · 0 blanks · 3 code · 4 comments

scc --format json --no-config cases/1000-comments/1280-matlab_block_markers_sharing_their_line/input.m

tokei.default ✗ fails

knows no MATLAB and counts every .m file as Objective-C, whose comments do not begin with %, so every line is code

the rules ask7 lines · 0 blanks · 2 code · 5 comments
it answers7 lines · 0 blanks · 7 code · 0 comments

tokei --output json cases/1000-comments/1280-matlab_block_markers_sharing_their_line/input.m