Repository navigation
fix(compile): fail when a doxygen header closes early - #288
Conversation
c1d3599 to
e417675
Compare
There was a problem hiding this comment.
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.
e417675 to
3473d78
Compare
|
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 The gate is now The specs pin the case you described - The corpus check is unchanged: all 637 doxygen headers in core, cli, utils and adapter are accepted. |
There was a problem hiding this comment.
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)andindexOf('/*', start + 2)are text searches, not lexing. Header text containing/*/- a glob such assrc/*/file.sasin @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 -
removeHeaderis 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 afix(compile)commit cuts only a patch release. Add a breaking-change note in the changelog, or usefix!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.
3473d78 to
20502d8
Compare
|
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 2. Shape detection is 3. Release type - keeping Mutation after the changes: 96.25% over Also worth mentioning: the first version of the new JSDoc contained |
There was a problem hiding this comment.
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 likesrc/*/file.sasin @details, and there is no opt-out. Builds that succeeded before will fail after this lands, sofix(compile):(patch) understates it - put the migration note in the PR body and considerfix!:/ aBREAKING CHANGE:footer so semantic-release cuts the release this warrants. - src/compileTree/doxygenHeader.ts:7:
close: numberuses -1 for "no close marker" whilenestedCommentandterminatoruse null. This is exported public API (index.ts re-exports the module) and the -1 sentinel is easy to misuse by consumers doingcontent[header.close - 1]arithmetic - make itnumber | 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.
20502d8 to
1280c39
Compare
|
2. Sentinel inconsistency (fixed). Agreed - 3. CI on 20502d8. It ran and passed: two 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
Mutation after adding the sentinel: 93.48% (86 killed, 6 survived, 0 uncovered). The three extra survivors are the sentinel's own branches - |
There was a problem hiding this comment.
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.
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.
1280c39 to
f674bc3
Compare
There was a problem hiding this comment.
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 onheader.nestedComment === nulland 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.
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.
|
All three handled in f674bc3. 1. A literal 2. A bare Worth being explicit about the remaining trade: a header that closes with a plain 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 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 |
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.
f674bc3 to
a727988
Compare
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.
|
Right on both counts - fixed in a727988. The 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 The case that must stay silent still does: a header whose only CI on f674bc3 was green - two One thing I did not do: the CLI suite as a consumer. The CLI takes |
There was a problem hiding this comment.
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.
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.
|
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 The body carries a Migration section (the error text and the two edits that clear it) and a Release type section stating the trade: 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 - Everything else in the diff you reviewed is green: |
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.
|
Decision from the maintainer: this ships as a regular 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 So: |
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.
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.
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.
## [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))
|
🎉 This PR is included in version 4.1.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
`@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.
# [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)
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.
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.
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.
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.
…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]>
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.tsreads the doxygen header a file opens with(
/**, after any leading whitespace): where it starts, where the lexercloses it, whether a nested
/*precedes that close, and the**/thatbelongs to it. Every field that can be absent is
number | null- there isno
-1sentinel to trip over in a caller's arithmetic.**/behind another
/*closes that comment, not this header, so one header'sverdict does not depend on what happens to follow it in the file.
throwIfDoxygenHeaderClosesEarlyraises when the header closes on a plain*/while its own terminator follows - a combination only reachable whensomething ended the header early.
removeHeader(macro leaves,through
CompileTree.addLeaf, which passesleaf.location),loadDependenciesFile(services, jobs, tests and plain files, whose headersstay in the compiled output) and
getDependenciesfor an included programread 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:
/*comment is not a doxygen header and is notchecked. That shape is what the
hasDoxygenHeaderstyle rule reports./*inside a header that the terminator closes first is header text. SASnever acts on it, so it stays accepted.
*/with no terminator of its own is notreported: nothing there says the header was meant to continue. That shape is
a different defect -
getListreturns an empty dependency list for it andthe macros silently do not ship - and it needs its own issue.
Two message shapes, because the cause differs:
A
/*/in header text - a glob such assrc/*/file.sas- ends the header inSAS 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:
Checks
npm run lint:fix).npm test) - 488 tests, 42 suites.sasjs-cliunit tests are passing (npm test).Migration
If
sasjs compilestarts failing withthe doxygen header is closed at line N, the file it names has a/*inside its doxygen header (or header textholding
/*/). SAS ends the header at that close marker, so the build wasalready 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.removeHeaderis public and now throws oninput 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.tsonly, withcoverageAnalysis: alland 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 therepo:
The six survivors, and why each one is not a missing spec:
28:7start === -1->false:startsWithcoerces the position to 0, andcontent with no non-whitespace character cannot open with
/**at index 0,so both forms return
null.30:40start + 2->start - 2: the two searches differ only for a closemarker at index
start + 1, which needs the file to open/*/. That is nota header, and no spec pins a meaning for it.
37:31nestedComment < close-><=: the two indexes point at a/and a*respectively, so they are never equal.38:17,38:27and81:5are thenullsentinel's branches:closeisnullonly when the file holds no close marker at all, in which case it alsoholds no
**/(a terminator contains one), andnestedCommentisnullinthe same state. The three guards are equivalent by construction and one of
them exists for the type system -
header.close === nullis what lets thecompiler 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. Thatpreference 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
getDependenciesbranch) makes its spec fail, so the wiring is covered andnot only the module.
Run against the real corpus, the same function accepts every doxygen header in
sasjs/core,sasjs/cli,sasjs/utilsandsasjs/adapter: 639 headerschecked, 1 raised, and that one is the deliberate bad fixture this PR adds for
getDependencies.Not in this PR
removeHeaderwithout a path forSASJsFileType.file, so thatone path reports line numbers without the file name. One-line follow-up in
sasjs/clionce this is released: passfilePath.@sasjs/lintrule for the same shape is the author-time gate and belongsin that repo; this PR is the compile-time one.