Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions sql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,16 @@ single-line comments.

### comment-stacked-dashes

A run of 3 or more consecutive `--` lines must use `/* */` syntax instead.
Up to 2 consecutive `--` lines is fine — a short remark reads fine as `--`.
A run of 2 or more consecutive `--` lines must use `/* */` syntax instead
(or carry an explicit `sql-lint:disable comment-stacked-dashes` exception).
Only a single `--` line is allowed on its own.

```sql
-- Bad: stacked dashes
-- spanning three
-- spanning two
-- or more lines

-- Good: 2 lines is fine
-- as a short remark
-- Good: a single short remark

/*
* Good: block comment
Expand Down
6 changes: 3 additions & 3 deletions sql/bin/sql-lint
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ sub check_stacked_dashes {
my @out;
my ($start, $end) = (0, 0);

# Up to 2 consecutive -- lines is allowed (a short two-line remark reads
# fine as --); only 3+ must become a /* */ block.
# Only a single -- line is allowed; 2+ consecutive lines must become a
# /* */ block (or carry an explicit sql-lint:disable exception).
my $flush = sub {
return unless $start && ($end - $start) >= 2;
return unless $start && ($end - $start) >= 1;
my $n = $end - $start + 1;
maybe_finding(\@out, $lines, $file, $start, 'comment-stacked-dashes',
"$n consecutive -- comment lines ($start-$end); use /* */ for multi-line comments");
Expand Down
5 changes: 4 additions & 1 deletion sql/test/fixtures/comment-stacked-dashes.bad.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
-- expect-findings: 2
-- expect-findings: 3
-- This is a multi-line comment
-- written with stacked dash lines.
-- It should use /* */ instead.

-- This is another
-- stacked comment
-- spanning three lines.

-- Even two consecutive lines
-- are no longer allowed.
3 changes: 0 additions & 3 deletions sql/test/fixtures/comment-stacked-dashes.good.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

-- Another single-line comment, separated by a blank line.

-- Two consecutive -- lines are also fine;
-- only a run of 3+ must become a /* */ block.

-- /* this is a line comment, not a block comment opening

--/* no space variant
Expand Down