← every case · 2000 · string forms

2125-operator_spelled_like_a_heredoc_opener

In Ruby, class <<self opens the class of self itself, and the << there is an operator. Read as a heredoc, it would need a line holding self alone further down, and Ruby refuses to parse a heredoc that never closes. A counter that opens one there reads every line after it as string, the comment under it included. The real heredoc further down holds an apostrophe and a line beginning with #, so a counter that reads no heredocs gets that one wrong, and the comment after it as well

read ascloc.defaultcloc.docstring-as-codecodestats.defaultmezura.contentmezura.regionscc.defaulttokei.default
input.rb
1codeclass Report
2code class <<self
3comments # the class methods
4code def title
5code 'Totals'
6code end
7code end
8blanks
9code def body
10code <<TEXT
11codeit's the body
12code# not a comment
13codeTEXT
14code end
15comments # a real comment
16codeend

stringcommentthe tag around another language

What each tool answered

cloc.default ✗ fails

reads no heredoc in Ruby, so the line of the heredoc that begins with # counts as a comment

the rules ask16 lines · 1 blanks · 13 code · 2 comments
it answers16 lines · 1 blanks · 12 code · 3 comments

cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2125-operator_spelled_like_a_heredoc_opener/input.rb

cloc.default ✗ fails

--strip-str-comments

reads no heredoc in Ruby, so the line of the heredoc that begins with # counts as a comment

the rules ask16 lines · 1 blanks · 13 code · 2 comments
it answers16 lines · 1 blanks · 12 code · 3 comments

cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2125-operator_spelled_like_a_heredoc_opener/input.rb --strip-str-comments

cloc.docstring-as-code ✗ fails

reads no heredoc in Ruby, so the line of the heredoc that begins with # counts as a comment

the rules ask16 lines · 1 blanks · 13 code · 2 comments
it answers16 lines · 1 blanks · 12 code · 3 comments

cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2125-operator_spelled_like_a_heredoc_opener/input.rb --docstring-as-code

codestats.default ✓ agrees
the rules ask16 lines · 1 blanks · 13 code · 2 comments
it answers16 lines · 1 blanks · 13 code · 2 comments

codestats cases/2000-string_forms/2125-operator_spelled_like_a_heredoc_opener/input.rb --output json-compact --include-generated --no-gitignore --hidden --no-config

mezura.content ✓ agrees
the rules ask16 lines · 13 code · 2 comments · 1 extra
it answers16 lines · 13 code · 2 comments · 1 extra

mezura cases/2000-string_forms/2125-operator_spelled_like_a_heredoc_opener/input.rb --output json --hide timing --no-default-config --no-local --counting content

mezura.region ✓ agrees
the rules ask16 lines · 1 blanks · 13 code · 2 comments
it answers16 lines · 1 blanks · 13 code · 2 comments

mezura cases/2000-string_forms/2125-operator_spelled_like_a_heredoc_opener/input.rb --output json --hide timing --no-default-config --no-local --counting region

scc.default ✗ fails

reads no heredoc in Ruby, so the apostrophe of it's on line 11 opens a string that runs to the end of the file, and the comment on line 15 counts as code

the rules ask16 lines · 1 blanks · 13 code · 2 comments
it answers16 lines · 1 blanks · 14 code · 1 comments

scc --format json --no-config cases/2000-string_forms/2125-operator_spelled_like_a_heredoc_opener/input.rb

tokei.default ✗ fails

reads no heredoc in Ruby, so the apostrophe of it's on line 11 opens a string that runs to the end of the file, and the comment on line 15 counts as code

the rules ask16 lines · 1 blanks · 13 code · 2 comments
it answers16 lines · 1 blanks · 14 code · 1 comments

tokei --output json cases/2000-string_forms/2125-operator_spelled_like_a_heredoc_opener/input.rb