Skip to content

fix(compile): fail when a doxygen header closes early - #288

Merged
allanbowe merged 1 commit into
mainfrom
fix/doxygen-header-nested-comment
Oct 27, 2026
Merged

allanbowe merged 1 commit into
mainfrom
fix/doxygen-header-nested-comment

Conversation

@sasjs-dev

@sasjs-dev sasjs-dev Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Issue

sasjs/cli#1499 - a nested block comment inside a doxygen header truncates the
header and the remainder is emitted as live SAS.

Intent

Fail the compile, at the header, when a doxygen header is cut short by a block
comment inside it.

The file is invalid SAS: block comments do not nest, so the inner close marker
ends the header in the lexer as well and SAS executes what follows it. Nothing
in the compiler can make such a file run - the value here is that the failure
names the file, the line and the cause instead of surfacing hundreds of lines
away as an unrelated syntax error.

Implementation

  • src/compileTree/doxygenHeader.ts reads the doxygen header a file opens with
    (/**, after any leading whitespace): where it starts, where the lexer
    closes it, whether a nested /* precedes that close, and the **/ that
    belongs to it. Every field that can be absent is number | null - there is
    no -1 sentinel to trip over in a caller's arithmetic.
  • The terminator has to arrive before anything else opens a comment. A **/
    behind another /* closes that comment, not this header, so one header's
    verdict does not depend on what happens to follow it in the file.
  • throwIfDoxygenHeaderClosesEarly raises when the header closes on a plain
    */ while its own terminator follows - a combination only reachable when
    something ended the header early.
  • Wired at every place that owns a header: removeHeader (macro leaves,
    through CompileTree.addLeaf, which passes leaf.location),
    loadDependenciesFile (services, jobs, tests and plain files, whose headers
    stay in the compiled output) and getDependencies for an included program
    read without a compile tree, where the file goes in as read and the header is
    never stripped. The CLI and the server compile paths both go through these,
    so both fail here rather than at deploy.

Behaviour that stays as it is, deliberately:

  • A file opening with a plain /* comment is not a doxygen header and is not
    checked. That shape is what the hasDoxygenHeader style rule reports.
  • A /* inside a header that the terminator closes first is header text. SAS
    never acts on it, so it stays accepted.
  • A header closed by a plain */ with no terminator of its own is not
    reported: nothing there says the header was meant to continue. That shape is
    a different defect - getList returns an empty dependency list for it and
    the macros silently do not ship - and it needs its own issue.

Two message shapes, because the cause differs:

src/services/nested.sas: the doxygen header is closed at line 7, before its **/ terminator at line 11: the close marker on line 7 belongs to the block comment opened at line 6. SAS block comments do not nest - a block comment ends at the first close marker it meets - so lines 8-11 - including the header's closing **/ - would be compiled as SAS. Remove the block comment from the header, or move it below the header.

A /*/ in header text - a glob such as src/*/file.sas - ends the header in
SAS for the same reason, without any comment being involved, so that case names
the sequence and asks for the wording to change rather than for a comment to be
removed:

the doxygen header is closed at line 3, before its **/ terminator at line 6: the /*/ on line 3 holds that close marker. ... Reword the header text so that it holds no comment terminator.

Checks

  • Code is formatted correctly (npm run lint:fix).
  • All unit tests are passing (npm test) - 488 tests, 42 suites.
  • All sasjs-cli unit tests are passing (npm test).
  • Reviewer is assigned.

Migration

If sasjs compile starts failing with the doxygen header is closed at line N, the file it names has a /* inside its doxygen header (or header text
holding /*/). SAS ends the header at that close marker, so the build was
already producing a service that failed at run time. The fix is in the file:
remove the block comment from the header or move it below the header, or reword
text that contains /*/.

Release type

Kept as fix, so a patch release. removeHeader is public and now throws on
input it previously passed through, which is a contract change in the narrow
sense - but the input is invalid SAS that cannot compile, so no working project
can regress, and the alternative (fix!) would force a major on every consumer
(the CLI, adapter, VS Code extension, server) for a guard that only fires on
broken files. Say the word if you would rather have the major.

Coverage of the guard itself

Scoped mutation run over src/compileTree/doxygenHeader.ts only, with
coverageAnalysis: all and the three specs that reach it
(doxygenHeader.spec.ts, compileTree.spec.ts,
loadDependenciesFile.spec.ts), on Stryker 10.1.1 in a throwaway copy of the
repo:

All files         |  93.48 | 93.48 | 86 killed | 0 timeout | 6 survived | 0 no cov | 0 errors
 doxygenHeader.ts |  93.48 | 93.48 | 86 killed | 0 timeout | 6 survived | 0 no cov | 0 errors

The six survivors, and why each one is not a missing spec:

  • 28:7 start === -1 -> false: startsWith coerces the position to 0, and
    content with no non-whitespace character cannot open with /** at index 0,
    so both forms return null.
  • 30:40 start + 2 -> start - 2: the two searches differ only for a close
    marker at index start + 1, which needs the file to open /*/. That is not
    a header, and no spec pins a meaning for it.
  • 37:31 nestedComment < close -> <=: the two indexes point at a / and a
    * respectively, so they are never equal.
  • 38:17, 38:27 and 81:5 are the null sentinel's branches: close is
    null only when the file holds no close marker at all, in which case it also
    holds no **/ (a terminator contains one), and nestedComment is null in
    the same state. The three guards are equivalent by construction and one of
    them exists for the type system - header.close === null is what lets the
    compiler accept content[header.close - 1].

An earlier run of the same scope scored 77.32% against a longer version of the
module that preferred a line-leading **/ and looped to find it. That
preference defended nothing - it produced ten surviving mutants and four
timeouts of its own - so the terminator search is a single indexOf.

Reverting any of the three call sites (removeHeader, loadDependenciesFile,
the getDependencies branch) makes its spec fail, so the wiring is covered and
not only the module.

Run against the real corpus, the same function accepts every doxygen header in
sasjs/core, sasjs/cli, sasjs/utils and sasjs/adapter: 639 headers
checked, 1 raised, and that one is the deliberate bad fixture this PR adds for
getDependencies.

Not in this PR

  • The CLI calls removeHeader without a path for SASJsFileType.file, so that
    one path reports line numbers without the file name. One-line follow-up in
    sasjs/cli once this is released: pass filePath.
  • A @sasjs/lint rule for the same shape is the author-time gate and belongs
    in that repo; this PR is the compile-time one.

@sasjs-dev sasjs-dev Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full diff: new src/compileTree/doxygenHeader.ts, its call sites in removeHeader, getDependencies and loadDependenciesFile, plus the specs and the two fixtures.

  • src/compileTree/doxygenHeader.ts:24 - the check keys off "the file starts with a block comment" (/*), not off a doxygen header (/**). A file whose first comment is an ordinary block comment that contains a /* before its close, in a file that has a **/ later on, throws "the doxygen header is closed early" although there is no doxygen header there - a hard build failure on valid SAS. Gate the check on the opener being /** (content[start + 2] === '*') so the condition matches the function name and the message, or reword the message if every leading block comment is meant to be covered.

No blocking issues.

@sasjs-dev
sasjs-dev Bot force-pushed the fix/doxygen-header-nested-comment branch from e417675 to 3473d78 Compare October 27, 2026 00:49
@sasjs-dev

sasjs-dev Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Good catch, and fixed in 3473d78.

You are right that the check keyed off "file opens with a block comment" while the function, the message and the intent are all about a doxygen header. A leading plain /* comment that holds a /*, with a **/ somewhere later in the file, would have thrown on valid SAS.

The gate is now /** (after leading whitespace): a file that opens with a plain block comment returns null and is not checked. That shape is what hasDoxygenHeader reports as a style problem, so it is not lost, it is just not this check's business.

The specs pin the case you described - getDoxygenHeader returns null and no throw - and the scoped mutation run still scores 95.65% with the same three justified survivors (the /** comparison itself is killed by that new spec, so the gate cannot be loosened without a spec failing).

The corpus check is unchanged: all 637 doxygen headers in core, cli, utils and adapter are accepted.

@sasjs-dev sasjs-dev Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked the full base...head diff: the doxygen header guard, its wiring into CompileTree, getDependencies and loadDependenciesFile, and the new specs.

  • src/compileTree/doxygenHeader.ts:30-34 - the terminator search runs unbounded from close, so whether a header that is closed by a single */ counts as truncated depends on any **/ appearing later in the file (a second macro header, for example). The same defect is reported or silently ignored depending on unrelated downstream text. Bound the search to the header's own extent, or drop the terminator requirement for the single-*/ case, so the verdict is local to the header.

  • src/compileTree/doxygenHeader.ts:30-31 - indexOf('*/', start + 2) and indexOf('/*', start + 2) are text searches, not lexing. Header text containing /*/ - a glob such as src/*/file.sas in @details, or a literal /*/ - gives nestedComment < close with content[close - 1] === '/', so a well-formed header fails the build with the truncation error. Require the close marker to be a real one (the */ that belongs to the terminator, or preceded by whitespace/EOL) before treating it as the header close.

  • src/compileTree/compileTree.ts:117 - removeHeader is exported from the package root and previously never threw; it now fails on input it used to pass through. That is the intent, but it changes the contract of a public API, so a fix(compile) commit cuts only a patch release. Add a breaking-change note in the changelog, or use fix! if the guard should read as breaking.

Tests cover the nested-comment, single-asterisk and plain-comment cases; the /*/-in-header-text and multi-header cases above have no coverage - a regression test for each would pin the intended behaviour.

3 findings above for review.

@sasjs-dev
sasjs-dev Bot force-pushed the fix/doxygen-header-nested-comment branch from 3473d78 to 20502d8 Compare October 27, 2026 01:08
@sasjs-dev

sasjs-dev Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

All three are addressed in 20502d8, though I read the second one differently.

1. Unbounded terminator search (fixed). Right that the verdict was not local. The terminator now has to arrive before anything else opens a comment: a **/ sitting behind another /* closes that comment, not this header, so it is not evidence about this one. The second-header case is now silent whichever way the file is arranged, and should not take a later header terminator as its own pins it. Cost: a genuinely truncated header whose leaked remainder happens to contain another /* is not reported. That is a miss on an already doubly-broken file rather than a wrong verdict on a good one, which is the trade I want here.

2. /*/ in header text - mechanism right, premise wrong. indexOf cannot tell a comment from a glob, agreed. But the conclusion that the header is well-formed does not hold: @details outputs land in src/*/file.sas really does end the header at that */ in SAS, so the file is broken and failing the build is correct. What was wrong is the message - it blamed a block comment that does not exist, and the remedy sent the author looking for one. That is now its own wording:

the doxygen header is closed at line 3, before its **/ terminator at line 6: the /*/ on line 3 holds that close marker. ... Reword the header text so that it holds no comment terminator.

Shape detection is nestedComment === close - 1, i.e. an opener immediately followed by a close marker. should report a glob that carries a comment terminator as literal text covers it.

3. Release type - keeping fix, deliberately. removeHeader does now throw where it used to pass through, but the input it throws on cannot compile: it is invalid SAS that fails at run time with an error naming nothing. A major would force every consumer (CLI, adapter, VS Code extension, server) to bump for a guard that only fires on already-broken files, so the note lives in the PR body under "Release type" instead of in the commit subject. Happy to take fix! if you read the contract change as worth the cascade - it is your call, not mine to make quietly.

Mutation after the changes: 96.25% over doxygenHeader.ts (77 killed, 3 survived, both directions of the gate covered), and the three survivors are the documented ones - two equivalent by construction, one distinguishable only by a file opening /*/.

Also worth mentioning: the first version of the new JSDoc contained **/ inside a /* */ block, which terminated the comment the module describes. Prettier turned the remainder into an empty statement so nothing failed to compile, and the mutation run is what surfaced it (a mutant on a line that should not have existed). It is // comments now.

@sasjs-dev sasjs-dev Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full diff: the new doxygenHeader module and its specs, and the removeHeader / CompileTree / getDependencies / loadDependenciesFile integration. The detection logic holds up on the cases that matter - non-nesting semantics, single-line /* ... */ inside a header, the /*/ glob form, and no report for unterminated headers or plain block comments ahead of the header.

  • Release impact: this turns a silent miscompile into a hard build failure for any input file whose doxygen header holds a nested /*, including header text like src/*/file.sas in @details, and there is no opt-out. Builds that succeeded before will fail after this lands, so fix(compile): (patch) understates it - put the migration note in the PR body and consider fix!: / a BREAKING CHANGE: footer so semantic-release cuts the release this warrants.
  • src/compileTree/doxygenHeader.ts:7: close: number uses -1 for "no close marker" while nestedComment and terminator use null. This is exported public API (index.ts re-exports the module) and the -1 sentinel is easy to misuse by consumers doing content[header.close - 1] arithmetic - make it number | null, or document the sentinel on the field.
  • CI has not reported on this head (state pending, no check contexts), so the new specs are unverified from the review side. A green run is needed before merge.

3 findings above for review.

@sasjs-dev
sasjs-dev Bot force-pushed the fix/doxygen-header-nested-comment branch from 20502d8 to 1280c39 Compare October 27, 2026 01:28
@sasjs-dev

sasjs-dev Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

2. Sentinel inconsistency (fixed). Agreed - close: number used -1 while its neighbours used null, on an interface re-exported from the package root, and the module itself does content[header.close - 1], which is exactly the arithmetic a consumer would copy. close is now number | null, and terminator/nestedComment are null in the same state, so there is one absence marker in the type. Shipped in 1280c39.

3. CI on 20502d8. It ran and passed: two test (22) check-runs, both completed/success, on that head. Link: GET /repos/sasjs/utils/commits/20502d8/check-runs. The pending state you saw was the first minute after the push.

1. Release impact. The migration note is now in the PR body ("Migration"), naming the exact error text and the two edits that clear it. On the version marker, I am holding at fix(compile) deliberately, and not quietly: removeHeader now throws only on input that cannot compile - the header holds a /* or a /*/, SAS ends the comment there, and the rest of the header runs as code. Nothing that built and ran correctly can start failing, because that input was already failing at run time; the difference is where it fails.

fix! would cut a major for @sasjs/utils, and the CLI, adapter, VS Code extension and server all take @sasjs/utils on a caret, so each needs a deliberate major bump for a guard that only fires on broken files. That is a call for the repo owner rather than for me to make in a PR body, so I have put the trade in front of them with the recommendation to keep fix. If they say major, the subject becomes fix! in one amend and the note stays exactly as it is.

Mutation after adding the sentinel: 93.48% (86 killed, 6 survived, 0 uncovered). The three extra survivors are the sentinel's own branches - close is null only when the file has no close marker at all, in which case it also has no terminator and no nested comment, so those guards are equivalent by construction and one exists to satisfy the type checker.

@sasjs-dev sasjs-dev Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full PR diff: new src/compileTree/doxygenHeader.ts, its wiring into CompileTree.removeHeader, getDependencies and loadDependenciesFile, the new exports, and the added specs. Logic, API surface and style are otherwise consistent with the repo.

  • src/compileTree/doxygenHeader.ts:84 - spurious failure. getOwnTerminator (lines 49-55) binds the first **/ after the close that has no /* between them, wherever it sits in the file. A header terminated with a single */ and holding a /* in its text therefore starts throwing as soon as any later line holds a literal **/ with no /* before it, even though nothing was truncated. Decide the header's own style from the header block itself instead of scanning to the end of the file for a **/.

  • src/compileTree/doxygenHeader.ts:82 - the check only fires when nestedComment is non-null, so a header closed early by a bare */ in header text (for example a glob such as /var/*/out on an @details line) still passes and the remainder, including the **/, is compiled as SAS. That is the same failure this PR sets out to catch, and the title says "fail when a doxygen header closes early". Extend the check, or narrow the title and the doc comment to the nested comment case.

  • src/compileTree/compileTree.ts:117 - removeHeader keeps a compatible signature, but the new throw turns previously passing builds into hard failures (a header carrying /*/, e.g. src/*/file.sas). Worth calling out in the release notes, and worth running the sasjs/cli suite as a consumer of @sasjs/utils.

3 findings above for review.

sasjs-dev Bot added a commit to sasjs/lint that referenced this pull request Oct 27, 2026
A doxygen header is a SAS block comment, and SAS block comments do not nest:
the first close marker ends the comment. A `/* ... */` inside the header
therefore closes the header early, and the rest of it - `@param` lines, and any
code in a usage example - is compiled as live SAS. The same happens to header
text that holds `/*/`, such as a glob like `src/*/file.sas`.

`sasjs compile` now fails on that shape (sasjs/utils#288), which tells the
author several hundred lines away from the header. This rule reports it where
the header is edited: an error at the nested opener, or at the `/*/` when no
comment was involved.

The rule is registered behind `noNestedCommentsInHeader !== false`, and a spec
pins that it is left out when the setting is false - without it the branch
coverage threshold for `src/types/` fails.

The rule is on by default and reports at ERROR severity, because the shape it
finds cannot compile. It stays silent in the three states where nothing is
truncated - a `**/` that closes the header first, a header with no terminator
of its own, and a `**/` that belongs to a later comment - so it agrees with the
compile check rather than reporting files that build.
@sasjs-dev
sasjs-dev Bot force-pushed the fix/doxygen-header-nested-comment branch from 1280c39 to f674bc3 Compare October 27, 2026 02:15

@sasjs-dev sasjs-dev Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full base...head diff: new src/compileTree/doxygenHeader.ts, the guard wired into removeHeader, getDependencies and loadDependenciesFile, plus specs.

  • src/compileTree/doxygenHeader.ts:107 - the content[header.close - 1] === '*' early return assumes a **/ close marker is always the header's own terminator. A nested comment inside the header that closes with **/ (for example a /** @file x **/ snippet in @details) makes SAS end the header at that inner marker, but this branch returns before reporting it, so the truncation the check exists to catch goes through silently. Gate the branch on header.nestedComment === null and treat a **/ close with a nested opener before it as truncation; add a spec for it.

  • CI: no check contexts reported at f674bc3 (state pending) - confirm the pipeline is green before merge.

2 findings above for review.

sasjs-dev Bot added a commit to sasjs/lint that referenced this pull request Oct 27, 2026
A doxygen header is a SAS block comment, and SAS block comments do not nest:
the first close marker ends the comment. A `/* ... */` inside the header
therefore closes the header early, and the rest of it - `@param` lines, and any
code in a usage example - is compiled as live SAS. The same happens to header
text that holds `/*/`, such as a glob like `src/*/file.sas`.

`sasjs compile` now fails on that shape (sasjs/utils#288), which tells the
author several hundred lines away from the header. This rule reports it where
the header is edited: an error at the nested opener, or at the `/*/` when no
comment was involved.

The rule is registered behind `noNestedCommentsInHeader !== false`, and a spec
pins that it is left out when the setting is false - without it the branch
coverage threshold for `src/types/` fails.

The rule is on by default and reports at WARNING severity, like the other
header rules: `sasjs lint` keeps its return code, and the build still fails at
the same shape through the compile check. It covers a nested comment, a
literal sequence straight after an opener, and a bare close marker, and stays
silent in the three states where nothing is truncated - a `**/` that closes the
header first, a header with no terminator of its own, and a `**/` that belongs
to a later header.
@sasjs-dev

sasjs-dev Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

All three handled in f674bc3.

1. A literal **/ further down the file (right, and the worst of the three). My bound only excluded a **/ sitting behind another opener, so a **/ in a string after a single-*/ header did start throwing on valid SAS - your example is exactly the regression I had introduced when I dropped the line-leading rule. The terminator now has to stand alone on its line, so a **/ inside a statement or a comment is that statement's text and cannot be the header's end. Two specs pin it: one where the header holds a /* and a later put holds **/, one where it holds neither. The house style writes the terminator alone on its line, and all 636 headers in core, cli and utils already do.

2. A bare */ in header text (right). Widened rather than narrowed the title: the check now fires on any close marker that ends the header before its own terminator, and says which of the three causes it was - a nested comment, a /*/, or bare text. @details the close marker */ ends this header is now reported with "the close marker on line 3 is text in the header" and the reword remedy, where it used to pass. A useful side effect: with the terminator required to be alone on its line, the close marker and the terminator are always on different lines, so the same-line branch became dead code and is gone.

Worth being explicit about the remaining trade: a header that closes with a plain */ and has a stray **/ alone on a later line, with no header opened in between, is still reported. Such a **/ is itself odd - it closes nothing - and the alternative is to miss the case you asked me to cover.

3. Release notes and the CLI suite. The Migration section names the error and the two edits that clear it. On running the CLI suite as a consumer: the CLI takes @sasjs/utils on a caret, so proving it against this branch means editing its lockfile to an unpublished build, and the CLI suite that matters here needs a live SAS target - it is not a check I can make meaningful from here. What I did instead: harvested every doxygen header in core, cli, utils and adapter through the new function (639 headers, 1 raised, and that one is the bad fixture this PR adds), plus the 489 unit tests.

Mutation after the changes: 90.38%, 94 killed, 10 survived, 0 uncovered. All ten are equivalent and I spliced each replacement into the built module to check rather than eyeballing them - the null/-1 guard families, the startsWith coercion, the two index comparisons that cannot be equal, and one mutant Stryker reports on a span that does not correspond to a behavioural change (nested !== null inside a conjunction where nested cannot be null at that point).

sasjs-dev Bot added a commit to sasjs/lint that referenced this pull request Oct 27, 2026
A doxygen header is a SAS block comment, and SAS block comments do not nest:
the first close marker ends the comment. A `/* ... */` inside the header
therefore closes the header early, and the rest of it - `@param` lines, and any
code in a usage example - is compiled as live SAS. The same happens to header
text that holds `/*/`, such as a glob like `src/*/file.sas`.

`sasjs compile` now fails on that shape (sasjs/utils#288), which tells the
author several hundred lines away from the header. This rule reports it where
the header is edited: an error at the nested opener, or at the `/*/` when no
comment was involved.

The rule is registered behind `noNestedCommentsInHeader !== false`, and a spec
pins that it is left out when the setting is false - without it the branch
coverage threshold for `src/types/` fails.

The rule is on by default and reports at WARNING severity, like the other
header rules: `sasjs lint` keeps its return code, and the build still fails at
the same shape through the compile check. It covers a nested comment, a
literal sequence straight after an opener, and a bare close marker, and stays
silent in the three states where nothing is truncated - a `**/` that closes the
header first, a header with no terminator of its own, and a `**/` that belongs
to a later header.
A doxygen header is a SAS block comment, and SAS block comments do not nest:
the first close marker ends the comment. A header that contains a block
comment of its own is therefore truncated at that inner close marker, and the
rest of the header - including any `@param` lines and any code in a usage
example - is compiled as live SAS. The run then fails somewhere else entirely,
with an error that names nothing near the cause.

`DoxygenHeader.close` is `number | null` rather than an index with a `-1`
sentinel, so a caller reading the module cannot carry the sentinel into its own
arithmetic.

`removeHeader` strips to the first close marker, which matches the SAS lexer,
so the compiled output was faithful and the defect was that nothing said so.
It now raises before stripping, naming the file, the line that closes the
header, the line that opened the nested comment and the lines that would run
as SAS.

The check is shared rather than local to one call site: `removeHeader` (which
serves macro leaves through `CompileTree.addLeaf`), `loadDependenciesFile`
(which serves services, jobs, tests and files, whose headers stay in the
compiled output) and `getDependencies` for included programs read without a
compile tree, where the file goes in as read and its header is never stripped.
The CLI and the server compile paths both fail here.

Detection stays close to the lexer instead of inventing a parser: the header
ends at the first close marker, and its terminator is a `**/` standing alone on
its line before anything else opens a comment. The header
closes at the first close marker; the terminator is the `**/` that arrives
before anything else opens a comment, so one header's verdict does not depend
on text further down the file. A plain `*/` close with a terminator of its own
following is the truncation; the nested `/*` is what causes it, and a literal
`/*/` (a glob such as `src/*/file.sas`) gets its own wording. A `/*` inside a
header that the terminator closes first is header text and stays accepted, as
does a header with no terminator at all - that is a different defect, where the
dependency lists read as empty.
@sasjs-dev
sasjs-dev Bot force-pushed the fix/doxygen-header-nested-comment branch from f674bc3 to a727988 Compare October 27, 2026 02:49
sasjs-dev Bot added a commit to sasjs/lint that referenced this pull request Oct 27, 2026
A doxygen header is a SAS block comment, and SAS block comments do not nest:
the first close marker ends the comment. A `/* ... */` inside the header
therefore closes the header early, and the rest of it - `@param` lines, and any
code in a usage example - is compiled as live SAS. The same happens to header
text that holds `/*/`, such as a glob like `src/*/file.sas`.

`sasjs compile` now fails on that shape (sasjs/utils#288), which tells the
author several hundred lines away from the header. This rule reports it where
the header is edited: an error at the nested opener, or at the `/*/` when no
comment was involved.

The rule is registered behind `noNestedCommentsInHeader !== false`, and a spec
pins that it is left out when the setting is false - without it the branch
coverage threshold for `src/types/` fails.

The rule is on by default and reports at WARNING severity, like the other
header rules: `sasjs lint` keeps its return code, and the build still fails at
the same shape through the compile check. It covers a nested comment, a
literal sequence straight after an opener, and a bare close marker, and stays
silent in the three states where nothing is truncated - a `**/` that closes the
header first, a header with no terminator of its own, and a `**/` that belongs
to a later header.
@sasjs-dev

sasjs-dev Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Right on both counts - fixed in a727988.

The **/ early return (accepted). content[close - 1] === '*' treated any double-asterisk close as the header's own terminator, so a @details snippet like /** @file x **/ ended the header silently. The discriminator is now the terminator itself: the check returns only when terminator === close - 1, i.e. the marker that closed the header is the marker the file uses to end it. Your fixture is a spec (should report an inner snippet that closes with its own terminator) and reports at line 2 against the terminator on line 5.

That change also required the loop I had removed: the terminator is now the first candidate that stands alone on its line, so an inner mid-line **/ is skipped rather than ending the search. The cost is visible in the mutation score - 89.81%, with four terminator-loop mutants recorded as timeouts rather than kills - and it buys the case you named plus the earlier literal-**/-in-code false positive.

The case that must stay silent still does: a header whose only /* is text and whose **/ closes it, because there the terminator equals the close minus one and the guard returns.

CI on f674bc3 was green - two test (22) runs, both success. a727988 is running now; I will report if it is not.

One thing I did not do: the CLI suite as a consumer. The CLI takes @sasjs/utils on a caret and cannot install an unreleased build without a lockfile edit, and the suite that would matter needs a live SAS target. The consumer evidence I have is instead the corpus: 639 doxygen headers across core, cli, utils and adapter, one raised, and that one is the deliberate fixture this PR adds.

@sasjs-dev sasjs-dev Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full base...head diff: the new doxygen header check (src/compileTree/doxygenHeader.ts), its three call sites (CompileTree.addLeaf, loadDependenciesFile, getDependencies), the specs and the SAS test fixtures. package.json, .npmrc (ignore-scripts + save-exact), the pinned gitleaks hook and the semantic-release config are untouched by this PR and already conform; the commit subject is a valid fix(compile) type.

  • src/compileTree/compileTree.ts:117 - removeHeader is re-exported from the package (src/compileTree/index.ts) and now throws on content it previously returned unchanged. Any external caller passing arbitrary SAS content gets an exception where it used to get a string, which is a contract change on an exported function shipped under a fix: type (patch release). Call it out in the release notes, or carry a BREAKING CHANGE: footer if the maintainer judges the exception to be part of the public contract.

1 finding above for review.

sasjs-dev Bot added a commit to sasjs/lint that referenced this pull request Oct 27, 2026
A doxygen header is a SAS block comment, and SAS block comments do not nest:
the first close marker ends the comment. A `/* ... */` inside the header
therefore closes the header early, and the rest of it - `@param` lines, and any
code in a usage example - is compiled as live SAS. The same happens to header
text that holds `/*/`, such as a glob like `src/*/file.sas`.

`sasjs compile` now fails on that shape (sasjs/utils#288), which tells the
author several hundred lines away from the header. This rule reports it where
the header is edited: an error at the nested opener, or at the `/*/` when no
comment was involved.

The rule is registered behind `noNestedCommentsInHeader !== false`, and a spec
pins that it is left out when the setting is false - without it the branch
coverage threshold for `src/types/` fails.

The rule is on by default and reports at WARNING severity, like the other
header rules: `sasjs lint` keeps its return code, and the build still fails at
the same shape through the compile check. It covers a nested comment, a
literal sequence straight after an opener, and a bare close marker, and stays
silent in the three states where nothing is truncated - a `**/` that closes the
header first, a header with no terminator of its own, and a `**/` that belongs
to a later header.
@sasjs-dev

sasjs-dev Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

This is the release-type point again, and it is answered in the PR body rather than by a code change, so I want to be explicit about why it stays fix(compile).

The body carries a Migration section (the error text and the two edits that clear it) and a Release type section stating the trade: removeHeader now throws, but only on input that cannot compile - a header holding /*, /*/ or an inner snippet is already truncated by SAS, so nothing that built and ran correctly can start failing. fix! cuts a major for @sasjs/utils, and the CLI, adapter, VS Code extension and server all take it on a caret, so each needs a deliberate major bump for a guard that only fires on broken files.

That judgement belongs to the maintainer, not to me inside a PR body, so I have put the trade in front of them with the recommendation. If they want the major, it is one line - fix! in the title, or a BREAKING CHANGE: footer - and the Migration text is already written to go with it. I would rather leave it as an explicit decision than change the release semantics of four packages unilaterally.

Everything else in the diff you reviewed is green: test (22) passes on this head.

sasjs-dev Bot added a commit to sasjs/lint that referenced this pull request Oct 27, 2026
A doxygen header is a SAS block comment, and SAS block comments do not nest:
the first close marker ends the comment. A `/* ... */` inside the header
therefore closes the header early, and the rest of it - `@param` lines, and any
code in a usage example - is compiled as live SAS. The same happens to header
text that holds `/*/`, such as a glob like `src/*/file.sas`.

`sasjs compile` now fails on that shape (sasjs/utils#288), which tells the
author several hundred lines away from the header. This rule reports it where
the header is edited: an error at the nested opener, or at the `/*/` when no
comment was involved.

The rule is registered behind `noNestedCommentsInHeader !== false`, and a spec
pins that it is left out when the setting is false - without it the branch
coverage threshold for `src/types/` fails.

The rule is on by default and reports at WARNING severity, like the other
header rules: `sasjs lint` keeps its return code, and the build still fails at
the same shape through the compile check. It covers a nested comment, a
literal sequence straight after an opener, and a bare close marker, and stays
silent in the three states where nothing is truncated - a `**/` that closes the
header first, a header with no terminator of its own, and a `**/` that belongs
to a later header.
@sasjs-dev

sasjs-dev Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Decision from the maintainer: this ships as a regular fix, not a major.

Their reasoning, recorded here so the thread carries the answer rather than my recommendation: the guard only fires on input that cannot compile, so no working project can regress, and a major on @sasjs/utils would force a deliberate bump across the CLI, adapter, VS Code extension and server for a check that never fires on a healthy file. The Migration section in the PR body stays as the release note.

So: fix(compile): fail when a doxygen header closes early, no ! and no BREAKING CHANGE footer. Nothing further to change for this finding.

sasjs-dev Bot added a commit to sasjs/lint that referenced this pull request Oct 27, 2026
A doxygen header is a SAS block comment, and SAS block comments do not nest:
the first close marker ends the comment. A `/* ... */` inside the header
therefore closes the header early, and the rest of it - `@param` lines, and any
code in a usage example - is compiled as live SAS. The same happens to header
text that holds `/*/`, such as a glob like `src/*/file.sas`.

`sasjs compile` now fails on that shape (sasjs/utils#288), which tells the
author several hundred lines away from the header. This rule reports it where
the header is edited: an error at the nested opener, or at the `/*/` when no
comment was involved.

The formatter guard lives in `hasDoxygenHeader`, the rule that already owns the
header's form: it reports a header that closes with a single asterisk, and its
fix widens that close marker to the double-asterisk form, which is what puts the
header back where the truncation rule can locate its end. A header whose body
holds a comment opener is left alone - the first close marker may belong to that
comment, and that call is the author's.

The rule is registered behind `noNestedCommentsInHeader !== false`, and a spec
pins that it is left out when the setting is false - without it the branch
coverage threshold for `src/types/` fails.

The rule is on by default and reports at WARNING severity, like the other
header rules: `sasjs lint` keeps its return code, and the build still fails at
the same shape through the compile check. It covers a nested comment, a
literal sequence straight after an opener, and a bare close marker, and stays
silent in the three states where nothing is truncated - a `**/` that closes the
header first, a header with no terminator of its own, and a `**/` that belongs
to a later header.
sasjs-dev Bot added a commit to sasjs/lint that referenced this pull request Oct 27, 2026
A doxygen header is a SAS block comment, and SAS block comments do not nest:
the first close marker ends the comment. A `/* ... */` inside the header
therefore closes the header early, and the rest of it - `@param` lines, and any
code in a usage example - is compiled as live SAS. The same happens to header
text that holds `/*/`, such as a glob like `src/*/file.sas`.

`sasjs compile` now fails on that shape (sasjs/utils#288), which tells the
author several hundred lines away from the header. This rule reports it where
the header is edited: an error at the nested opener, or at the `/*/` when no
comment was involved.

The formatter guard lives in `hasDoxygenHeader`, the rule that already owns the
header's form: it reports a header that closes with a single asterisk, and its
fix widens that close marker to the double-asterisk form, which is what puts the
header back where the truncation rule can locate its end. A header whose body
holds a comment opener is left alone - the first close marker may belong to that
comment, and that call is the author's.

The rule is registered behind `noNestedCommentsInHeader !== false`, and a spec
pins that it is left out when the setting is false - without it the branch
coverage threshold for `src/types/` fails.

Upgrade note: `noNestedCommentsInHeader` is on by default, and `hasDoxygenHeader`
now also reports a header that closes with a single asterisk where it used to
check the opener only. Both report at WARNING, so `sasjs lint` keeps its return
code and this stays a minor.

The rule is on by default and reports at WARNING severity, like the other
header rules: `sasjs lint` keeps its return code, and the build still fails at
the same shape through the compile check. It covers a nested comment, a
literal sequence straight after an opener, and a bare close marker, and stays
silent in the three states where nothing is truncated - a `**/` that closes the
header first, a header with no terminator of its own, and a `**/` that belongs
to a later header.
sasjs-dev Bot added a commit to sasjs/lint that referenced this pull request Oct 27, 2026
A doxygen header is a SAS block comment, and SAS block comments do not nest:
the first close marker ends the comment. A `/* ... */` inside the header
therefore closes the header early, and the rest of it - `@param` lines, and any
code in a usage example - is compiled as live SAS. The same happens to header
text that holds `/*/`, such as a glob like `src/*/file.sas`.

`sasjs compile` now fails on that shape (sasjs/utils#288), which tells the
author several hundred lines away from the header. This rule reports it where
the header is edited: an error at the nested opener, or at the `/*/` when no
comment was involved.

The formatter guard lives in `hasDoxygenHeader`, the rule that already owns the
header's form: it reports a header that closes with a single asterisk, and its
fix widens that close marker to the double-asterisk form, which is what puts the
header back where the truncation rule can locate its end. A header whose body
holds a comment opener is left alone - the first close marker may belong to that
comment, and that call is the author's.

The rule is registered behind `noNestedCommentsInHeader !== false`, and a spec
pins that it is left out when the setting is false - without it the branch
coverage threshold for `src/types/` fails.

Upgrade note: `noNestedCommentsInHeader` is on by default, and `hasDoxygenHeader`
now also reports a header that closes with a single asterisk where it used to
check the opener only. Both report at WARNING, so `sasjs lint` keeps its return
code and this stays a minor.

The rule is on by default and reports at WARNING severity, like the other
header rules: `sasjs lint` keeps its return code, and the build still fails at
the same shape through the compile check. It covers a nested comment, a
literal sequence straight after an opener, and a bare close marker, and stays
silent in the three states where nothing is truncated - a `**/` that closes the
header first, a header with no terminator of its own, and a `**/` that belongs
to a later header.
@allanbowe
allanbowe merged commit 98ef347 into main Oct 27, 2026
2 checks passed
@allanbowe
allanbowe deleted the fix/doxygen-header-nested-comment branch October 27, 2026 11:21
sasjs-gha Bot pushed a commit that referenced this pull request Oct 27, 2026
## [4.1.1](v4.1.0...v4.1.1) (2026-10-27)

### Bug Fixes

* **compile:** fail when a doxygen header closes early ([#288](#288)) ([98ef347](98ef347))
@sasjs-gha

sasjs-gha Bot commented Oct 27, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 4.1.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@sasjs-gha sasjs-gha Bot added the released label Oct 27, 2026
sasjs-dev Bot pushed a commit to sasjs/cli that referenced this pull request Oct 27, 2026
`@sasjs/utils` 4.1.1 adds the file path to the doxygen header check
(sasjs/utils#288), so `removeHeader` can name the file it failed on. Both call
sites that read a file and strip its header now pass it: the compile path for
`SASJsFileType.file`, and the build path that reads program files.

Before this, a truncated header reported line numbers with no file name on those
paths, which is the defect the compile-time check exists to avoid.

The new spec pins the message on the `.file` path, and fails without the
argument.
sasjs-gha Bot pushed a commit to sasjs/lint that referenced this pull request Oct 27, 2026
# [4.4.0](v4.3.3...v4.4.0) (2026-10-27)

### Features

* **lint:** add the noNestedCommentsInHeader rule ([d4ef50d](d4ef50d)), closes [sasjs/utils#288](sasjs/utils#288)
sasjs-dev Bot pushed a commit to sasjs/cli that referenced this pull request Oct 27, 2026
The compile-time half of this (sasjs/utils#288) and the author-time half
(sasjs/lint#265) are released; this brings them to the CLI and names the file
in the error.

`removeHeader` takes the source path from `@sasjs/utils` 4.1.1, so both call
sites that read a file and strip its header pass it: the compile path for
`SASJsFileType.file`, and the build path that reads program files. A truncated
header used to report line numbers with no file name on those paths, which is
the failure the check exists to prevent.

Dependencies, all in this one commit because they share `package-lock.json`:

- `@sasjs/utils` ^4.1.0 -> ^4.1.1, the release carrying the path argument.
- `@sasjs/lint` ^4.3.2 -> ^4.4.0, carrying `noNestedCommentsInHeader` and the
  `hasDoxygenHeader` single-asterisk close check and fix. Both report at
  WARNING, so a project's lint return code does not change on upgrade.
- `@sasjs/core` ^6.0.0 -> ^6.1.1, the `mx_execute` Viya outlogds fix
  (sasjs/core#477) - a patch with no API change.

The `@sasjs/lint` devDependencies entry is gone: it is a runtime dependency of
`src/commands/lint/processLint.ts`, so the second declaration was dead weight.
Its peer range moves to ^4.4.0, since 4.4.0 is where the rule the CLI ships
comes from.

One unplanned effect of the lint bump: 4.3.2 pinned `@sasjs/utils` exactly and
nested a second copy at 4.0.0 under `node_modules/@sasjs/lint`. 4.4.0 ranges
it, so the tree carries a single utils at 4.1.1 and the lockfile loses 49
lines. That nesting is why these remain caret ranges rather than exact pins.

CI: `.github/workflows/run-tests.yml` gains `HTTP_PORT=5000` in the server
`.env`. `sasjs/server` 3.0.0 (released 2026-10-26 23:35) refuses to start with
no listener enabled, and the job downloads `releases/latest`, so the server
step failed before any test ran on every PR opened since. The wait step polls
port 5000, which is why that is the port.

Verified: `npm ci` on the new lockfile (one copy of each package), `npm audit
--production` clean, tsc and prettier clean, mocked suite 629 passed with only
the environmental `printVersion` failure that also fails on main in this
environment. The new spec fails with the path argument reverted.
sasjs-dev Bot pushed a commit to sasjs/cli that referenced this pull request Oct 27, 2026
The compile-time half of this (sasjs/utils#288) and the author-time half
(sasjs/lint#265) are released; this brings them to the CLI and names the file
in the error.

What changes for a project: a SAS file whose doxygen header is cut short by a
block comment inside it used to compile, and the header text after the cut was
handed to SAS as code. It now fails the compile with a message naming the file
and the lines involved. The input cannot compile - SAS block comments do not
nest, so the first `*/` ends the comment - and the old behaviour silently ran
whatever followed. This is the check from @sasjs/utils 4.1.1, which this
release adopts.

`removeHeader` takes the source path from @sasjs/utils 4.1.1, so both call
sites that read a file and strip its header pass it: the compile path for
`SASJsFileType.file`, and the build path that reads program files. Without it
the diagnostic reported line numbers with no file name on exactly the paths
where a user meets it.

Dependencies, all in this one commit because they share `package-lock.json`:

- `@sasjs/utils` ^4.1.0 -> ^4.1.1, the release carrying the path argument.
- `@sasjs/lint` ^4.3.2 -> ^4.4.0 in `devDependencies` and `peerDependencies`,
  carrying `noNestedCommentsInHeader` and the `hasDoxygenHeader`
  single-asterisk close check and fix. Both report at WARNING, so a project's
  lint return code does not change on upgrade. The declaration stays peer plus
  dev, as on main: lint is imported at runtime and npm 7+ installs a peer
  automatically, so it is not promoted to a hard dependency.
- `@sasjs/core` ^6.0.0 -> ^6.1.1, the `mx_execute` Viya outlogds fix
  (sasjs/core#477) - a patch with no API change.

One unplanned effect of the lint bump: 4.3.2 pinned `@sasjs/utils` exactly and
nested a second copy at 4.0.0 under `node_modules/@sasjs/lint`. 4.4.0 ranges
it, so the tree carries a single utils at 4.1.1 and the lockfile loses 49
lines. That nesting is why these remain caret ranges rather than exact pins.

CI: `.github/workflows/run-tests.yml` gains `HTTP_PORT=5000` in the server
`.env`. `sasjs/server` 3.0.0 (released 2026-10-26 23:35) refuses to start with
no listener enabled, and the job downloads `releases/latest`, so the server
step failed before any test ran on every PR opened since. The wait step polls
port 5000, which is why that is the port.

Verified: `npm ci` on the new lockfile (one copy of each package), `npm audit
--production` clean, tsc and prettier clean, mocked suite 629 passed with only
the environmental `printVersion` failure that also fails on main in this
environment. The spec that pins the file name fails when the path argument is
reverted, and asserts the diagnostic's shape rather than the library's wording.
sasjs-dev Bot pushed a commit to sasjs/cli that referenced this pull request Oct 27, 2026
The compile-time half of this (sasjs/utils#288) and the author-time half
(sasjs/lint#265) are released; this brings them to the CLI and names the file
in the error.

What changes for a project: a SAS file whose doxygen header is cut short by a
block comment inside it used to compile, and the header text after the cut was
handed to SAS as code. It now fails the compile with a message naming the file
and the lines involved. The input cannot compile - SAS block comments do not
nest, so the first `*/` ends the comment - and the old behaviour silently ran
whatever followed. This is the check from @sasjs/utils 4.1.1, which this
release adopts.

`removeHeader` takes the source path from @sasjs/utils 4.1.1, so both call
sites that read a file and strip its header pass it: the compile path for
`SASJsFileType.file`, and the build path that reads program files. Without it
the diagnostic reported line numbers with no file name on exactly the paths
where a user meets it.

Dependencies, all in this one commit because they share `package-lock.json`:

- `@sasjs/utils` ^4.1.0 -> ^4.1.1, the release carrying the path argument.
- `@sasjs/lint` ^4.3.2 -> ^4.4.0 in `devDependencies` and `peerDependencies`,
  carrying `noNestedCommentsInHeader` and the `hasDoxygenHeader`
  single-asterisk close check and fix. Both report at WARNING, so a project's
  lint return code does not change on upgrade. The declaration stays peer plus
  dev, as on main: lint is imported at runtime and npm 7+ installs a peer
  automatically, so it is not promoted to a hard dependency.
- `@sasjs/core` ^6.0.0 -> ^6.1.1, the `mx_execute` Viya outlogds fix
  (sasjs/core#477) - a patch with no API change.

One unplanned effect of the lint bump: 4.3.2 pinned `@sasjs/utils` exactly and
nested a second copy at 4.0.0 under `node_modules/@sasjs/lint`. 4.4.0 ranges
it, so the tree carries a single utils at 4.1.1 and the lockfile loses 49
lines. That nesting is why these remain caret ranges rather than exact pins.

CI: `.github/workflows/run-tests.yml` gains `HTTP_PORT=5000` in the server
`.env`. `sasjs/server` 3.0.0 (released 2026-10-26 23:35) refuses to start with
no listener enabled, and the job downloads `releases/latest`, so the server
step failed before any test ran on every PR opened since. The wait step polls
port 5000, which is why that is the port.

Verified: `npm ci` on the new lockfile (one copy of each package), `npm audit
--production` clean, tsc and prettier clean, mocked suite 629 passed with only
the environmental `printVersion` failure that also fails on main in this
environment. The spec that pins the file name fails when the path argument is
reverted, and asserts the diagnostic's shape rather than the library's wording.
sasjs-dev Bot pushed a commit to sasjs/cli that referenced this pull request Oct 27, 2026
The compile-time half of this (sasjs/utils#288) and the author-time half
(sasjs/lint#265) are released; this brings them to the CLI and names the file
in the error.

What changes for a project: a SAS file whose doxygen header is cut short by a
block comment inside it used to compile, and the header text after the cut was
handed to SAS as code. It now fails the compile with a message naming the file
and the lines involved. The input cannot compile - SAS block comments do not
nest, so the first `*/` ends the comment - and the old behaviour silently ran
whatever followed. This is the check from @sasjs/utils 4.1.1, which this
release adopts.

`removeHeader` takes the source path from @sasjs/utils 4.1.1, so both call
sites that read a file and strip its header pass it: the compile path for
`SASJsFileType.file`, and the build path that reads program files. Without it
the diagnostic reported line numbers with no file name on exactly the paths
where a user meets it.

Dependencies, all in this one commit because they share `package-lock.json`:

- `@sasjs/utils` ^4.1.0 -> ^4.1.1, the release carrying the path argument.
- `@sasjs/lint` ^4.3.2 -> ^4.4.0 in `devDependencies` and `peerDependencies`,
  carrying `noNestedCommentsInHeader` and the `hasDoxygenHeader`
  single-asterisk close check and fix. Both report at WARNING, so a project's
  lint return code does not change on upgrade. The declaration stays peer plus
  dev, as on main: lint is imported at runtime and npm 7+ installs a peer
  automatically, so it is not promoted to a hard dependency.
- `@sasjs/core` ^6.0.0 -> ^6.1.1, the `mx_execute` Viya outlogds fix
  (sasjs/core#477) - a patch with no API change.

One unplanned effect of the lint bump: 4.3.2 pinned `@sasjs/utils` exactly and
nested a second copy at 4.0.0 under `node_modules/@sasjs/lint`. 4.4.0 ranges
it, so the tree carries a single utils at 4.1.1 and the lockfile loses 49
lines. That nesting is why these remain caret ranges rather than exact pins.

CI: `.github/workflows/run-tests.yml` gains `HTTP_PORT=5000` in the server
`.env`. `sasjs/server` 3.0.0 (released 2026-10-26 23:35) refuses to start with
no listener enabled, and the job downloads `releases/latest`, so the server
step failed before any test ran on every PR opened since. The wait step polls
port 5000, which is why that is the port.

Verified: `npm ci` on the new lockfile (one copy of each package), `npm audit
--production` clean, tsc and prettier clean, mocked suite 629 passed with only
the environmental `printVersion` failure that also fails on main in this
environment. The spec that pins the file name fails when the path argument is
reverted, and asserts the diagnostic's shape rather than the library's wording.
allanbowe pushed a commit to sasjs/cli that referenced this pull request Oct 27, 2026
…1500)

The compile-time half of this (sasjs/utils#288) and the author-time half
(sasjs/lint#265) are released; this brings them to the CLI and names the file
in the error.

What changes for a project: a SAS file whose doxygen header is cut short by a
block comment inside it used to compile, and the header text after the cut was
handed to SAS as code. It now fails the compile with a message naming the file
and the lines involved. The input cannot compile - SAS block comments do not
nest, so the first `*/` ends the comment - and the old behaviour silently ran
whatever followed. This is the check from @sasjs/utils 4.1.1, which this
release adopts.

`removeHeader` takes the source path from @sasjs/utils 4.1.1, so both call
sites that read a file and strip its header pass it: the compile path for
`SASJsFileType.file`, and the build path that reads program files. Without it
the diagnostic reported line numbers with no file name on exactly the paths
where a user meets it.

Dependencies, all in this one commit because they share `package-lock.json`:

- `@sasjs/utils` ^4.1.0 -> ^4.1.1, the release carrying the path argument.
- `@sasjs/lint` ^4.3.2 -> ^4.4.0 in `devDependencies` and `peerDependencies`,
  carrying `noNestedCommentsInHeader` and the `hasDoxygenHeader`
  single-asterisk close check and fix. Both report at WARNING, so a project's
  lint return code does not change on upgrade. The declaration stays peer plus
  dev, as on main: lint is imported at runtime and npm 7+ installs a peer
  automatically, so it is not promoted to a hard dependency.
- `@sasjs/core` ^6.0.0 -> ^6.1.1, the `mx_execute` Viya outlogds fix
  (sasjs/core#477) - a patch with no API change.

One unplanned effect of the lint bump: 4.3.2 pinned `@sasjs/utils` exactly and
nested a second copy at 4.0.0 under `node_modules/@sasjs/lint`. 4.4.0 ranges
it, so the tree carries a single utils at 4.1.1 and the lockfile loses 49
lines. That nesting is why these remain caret ranges rather than exact pins.

CI: `.github/workflows/run-tests.yml` gains `HTTP_PORT=5000` in the server
`.env`. `sasjs/server` 3.0.0 (released 2026-10-26 23:35) refuses to start with
no listener enabled, and the job downloads `releases/latest`, so the server
step failed before any test ran on every PR opened since. The wait step polls
port 5000, which is why that is the port.

Verified: `npm ci` on the new lockfile (one copy of each package), `npm audit
--production` clean, tsc and prettier clean, mocked suite 629 passed with only
the environmental `printVersion` failure that also fails on main in this
environment. The spec that pins the file name fails when the path argument is
reverted, and asserts the diagnostic's shape rather than the library's wording.

Co-authored-by: [email protected] <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant