← every case · 2000 · string forms

2110-here_string_holding_an_apostrophe

an apostrophe inside a PowerShell here string. The body of a here string is literal and it ends only at a closer sitting at the start of a line, so the apostrophe in the word is a byte. The line under it begins with #, so a counter that ends the string at the apostrophe, or reads no here string at all, counts that line as a comment. Two real comments follow the closer, so a counter that also opens a string there and lets it run on loses both and cannot land on the right totals

read ascloc.defaultcloc.docstring-as-codecodestats.defaultmezura.contentmezura.regionscc.defaulttokei.default
input.ps1
1code$s = @'
2codeit is a here string with an apostrophe: don't
3code# and this line is inside it too
4code'@
5comments# a real comment
6comments# a second real comment
7code$x = 1

stringcommentthe tag around another language

What each tool answered

cloc.default ✗ fails

it reads no here strings, so the line beginning with # inside one counts as a comment

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

cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2110-here_string_holding_an_apostrophe/input.ps1

cloc.default ✗ fails

--strip-str-comments

it reads no here strings, so the line beginning with # inside one counts as a comment

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

cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2110-here_string_holding_an_apostrophe/input.ps1 --strip-str-comments

cloc.docstring-as-code ✗ fails

it reads no here strings, so the line beginning with # inside one counts as a comment

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

cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2110-here_string_holding_an_apostrophe/input.ps1 --docstring-as-code

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

codestats cases/2000-string_forms/2110-here_string_holding_an_apostrophe/input.ps1 --output json-compact --include-generated --no-gitignore --hidden --no-config

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

mezura cases/2000-string_forms/2110-here_string_holding_an_apostrophe/input.ps1 --output json --hide timing --no-default-config --no-local --counting content

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

mezura cases/2000-string_forms/2110-here_string_holding_an_apostrophe/input.ps1 --output json --hide timing --no-default-config --no-local --counting region

scc.default ✗ fails

it reads no here strings, so the line beginning with # inside one counts as a comment, and it answers the same with the apostrophe taken out

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

scc --format json --no-config cases/2000-string_forms/2110-here_string_holding_an_apostrophe/input.ps1

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

tokei --output json cases/2000-string_forms/2110-here_string_holding_an_apostrophe/input.ps1