address argus: catch nix /* */ block comments too
mode_of mapped .nix to hash-mode (# only); nix also supports /* */ block comments, so a long one would slip past. Split .nix into its own 'nix' mode that handles BOTH # line comments and /* */ blocks. .sh stays hash (no block comments in sh). Verified: tree still 6 offenders (no nix block offenders), and a 33-line nix /* */ block is now caught.
This commit is contained in:
parent
bd86a3c1dd
commit
34e12e97a3
1 changed files with 8 additions and 3 deletions
|
|
@ -11,8 +11,8 @@
|
|||
#
|
||||
# Scope: tracked *.rs *.nix *.sh *.js *.ts *.css *.html. Markdown is exempt
|
||||
# (it is prose by nature). Comment forms: `#` line comments (nix/sh), `//`
|
||||
# line comments (rs/js/ts), and `/* */` (rs/js/ts/css) + `<!-- -->` (html)
|
||||
# block comments. A blank line separates two line-comment blocks (does NOT
|
||||
# line comments (rs/js/ts), and `/* */` block comments (nix/rs/js/ts/css) +
|
||||
# `<!-- -->` (html). A blank line separates two line-comment blocks (does NOT
|
||||
# extend a run); a blank inside a `/* */` / `<!-- -->` block stays part of it.
|
||||
#
|
||||
# Escape hatch: a `lint:allow-long-comment` marker anywhere in a block
|
||||
|
|
@ -27,7 +27,8 @@ hits="$(
|
|||
git ls-files -z '*.rs' '*.nix' '*.sh' '*.js' '*.ts' '*.css' '*.html' \
|
||||
| xargs -0 -r awk -v MAX="$MAX" '
|
||||
function mode_of(fn) {
|
||||
if (fn ~ /\.(nix|sh)$/) return "hash"
|
||||
if (fn ~ /\.nix$/) return "nix"
|
||||
if (fn ~ /\.sh$/) return "hash"
|
||||
if (fn ~ /\.(rs|js|ts)$/) return "slash"
|
||||
if (fn ~ /\.css$/) return "cstyle"
|
||||
if (fn ~ /\.html$/) return "html"
|
||||
|
|
@ -47,6 +48,10 @@ hits="$(
|
|||
if (index($0, blockend) > 0) inblock = 0
|
||||
} else if (mode == "hash") {
|
||||
if ($0 ~ /^[ \t]*#/) c = 1
|
||||
} else if (mode == "nix") {
|
||||
# nix: `#` line comments AND `/* */` block comments.
|
||||
if ($0 ~ /^[ \t]*#/) c = 1
|
||||
else if ($0 ~ /^[ \t]*\/\*/) { c = 1; if (index($0, "*/") == 0) { inblock = 1; blockend = "*/" } }
|
||||
} else if (mode == "slash") {
|
||||
if ($0 ~ /^[ \t]*\/\//) c = 1
|
||||
else if ($0 ~ /^[ \t]*\/\*/) { c = 1; if (index($0, "*/") == 0) { inblock = 1; blockend = "*/" } }
|
||||
|
|
|
|||
Loading…
Reference in a new issue