← every case · 2000 · string forms

2127-heredoc_closing_word_indented_only_after_a_tilde_or_dash

In Ruby a heredoc opened with <<~ or <<- may close at its word written behind spaces, and one opened with a plain << closes only at its word at the very start of a line. The first heredoc here closes at an indented TEXT, so a counter that wants the word at the start of the line reads the rest of the file as string, the comment at the end included. The second, opened with a plain <<RUBY, holds the code it generates, whose indented RUBY closes nothing, so a counter that takes the word behind spaces after any opener ends it there and reads the line beginning with # under it as a comment

read ascloc.defaultcloc.docstring-as-codecodestats.defaultmezura.contentmezura.regionscc.defaulttokei.default
input.rb
1codedef usage
2code <<~TEXT
3code it's the usage
4code # not a comment
5code TEXT
6codeend
7blanks
8codedef generated
9code <<RUBY
10code x = <<~RUBY
11code it's generated
12code RUBY
13code # part of the generated code
14codeRUBY
15codeend
16comments# a real comment

stringcommentthe tag around another language

What each tool answered

cloc.default ✗ fails

reads no heredoc in Ruby, so lines 4 and 13, the lines of the heredocs beginning with #, count as comments

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

cloc --json --config /tmp/linejudge-empty-file cases/2000-string_forms/2127-heredoc_closing_word_indented_only_after_a_tilde_or_dash/input.rb

cloc.default ✗ fails

--strip-str-comments

reads no heredoc in Ruby, so lines 4 and 13, the lines of the heredocs beginning with #, count as comments

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

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

cloc.docstring-as-code ✗ fails

reads no heredoc in Ruby, so lines 4 and 13, the lines of the heredocs beginning with #, count as comments

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

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

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

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

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

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

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

mezura cases/2000-string_forms/2127-heredoc_closing_word_indented_only_after_a_tilde_or_dash/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 3 opens a string that the one on line 11 closes. The blank line 7 inside it counts as code, and line 13, beginning with #, as a comment

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

scc --format json --no-config cases/2000-string_forms/2127-heredoc_closing_word_indented_only_after_a_tilde_or_dash/input.rb

tokei.default ✗ fails

reads no heredoc in Ruby, so the apostrophe of it's on line 3 opens a string that the one on line 11 closes. The blank line 7 inside it counts as code, and line 13, beginning with #, as a comment

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

tokei --output json cases/2000-string_forms/2127-heredoc_closing_word_indented_only_after_a_tilde_or_dash/input.rb