← every case · 2000 · string forms
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
| 1 | codecodecodecodecodecodecode | def usage |
| 2 | codecodecodecodecodecodecode | <<~TEXT |
| 3 | codecodecodecodecodecodecode | it's the usage |
| 4 | codecodecodecodecodecodecode | # not a comment |
| 5 | codecodecodecodecodecodecode | TEXT |
| 6 | codecodecodecodecodecodecode | end |
| 7 | blanksblanksblanksextrablanksblanksblanks | |
| 8 | codecodecodecodecodecodecode | def generated |
| 9 | codecodecodecodecodecodecode | <<RUBY |
| 10 | codecodecodecodecodecodecode | x = <<~RUBY |
| 11 | codecodecodecodecodecodecode | it's generated |
| 12 | codecodecodecodecodecodecode | RUBY |
| 13 | codecodecodecodecodecodecode | # part of the generated code |
| 14 | codecodecodecodecodecodecode | RUBY |
| 15 | codecodecodecodecodecodecode | end |
| 16 | commentscommentscommentscommentscommentscommentscomments | # a real comment |
stringcommentthe tag around another language
reads no heredoc in Ruby, so lines 4 and 13, the lines of the heredocs beginning with #, count as 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
reads no heredoc in Ruby, so lines 4 and 13, the lines of the heredocs beginning with #, count as 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
reads no heredoc in Ruby, so lines 4 and 13, the lines of the heredocs beginning with #, count as 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 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 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 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
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
scc --format json --no-config cases/2000-string_forms/2127-heredoc_closing_word_indented_only_after_a_tilde_or_dash/input.rb
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
tokei --output json cases/2000-string_forms/2127-heredoc_closing_word_indented_only_after_a_tilde_or_dash/input.rb