Skip to content

refactor: address pending SonarCloud S3881/S3776 items in lexer and ReusableStringWriter - #679

Merged
stencil-harness[bot] merged 2 commits into
masterfrom
robot/issue-641
Nov 8, 2026
Merged

stencil-harness[bot] merged 2 commits into
masterfrom
robot/issue-641

Conversation

@stencil-harness

Copy link
Copy Markdown
Contributor

Partial progress on the SonarCloud remediation tracking issue (#641). No behavior or public API changes.

Changes

  • S3881 — Seal ReusableStringWriter. Its only constructor is private, so no subclass can exist outside the type and sealing does not break the API. Dispose(bool) still returns the instance to the pool instead of calling base.Dispose (a comment now explains why).
  • S3776 Tokenizer — Split Parse into smaller helpers without changing behavior: ParseExpressionToken, ReadExtraBraces (shared by {{{/{{{{ and }}}/}}}}), ReadExpressionOpening and ReadStaticCharacter (backslash escapes in static text). The order in which characters are read and peeked is unchanged.
  • S3776 LiteralParser — Moved escape handling and end-of-literal detection into AppendEscapeSequence and IsEndOfLiteral.

Verification

  • Full test suite passes (2207 tests).
  • New tests in HelperLiteralArgumentsAreParsed cover escaped and unescaped quotes, non-delimiter escapes, and number literals ending at }, ) and space. They pass on both the old and the new code.

Not addressed here

  • S2326 (IDescriptor<TOptions>): removing the parameter breaks the API and needs a major version.
  • S3776 in BlockHelperFunctionBinder.BindByRef / PartialBinder.VisitPartialExpression: left alone because of the ExpressionShortcuts scoping constraint described in SonarCloud quality/security remediation tracking #641.

🤖 Generated with Claude Code

Closes #641

stencil-harness Bot and others added 2 commits November 7, 2026 23:32
The only constructor is private, so no subclass can exist outside the
type; sealing is not an API break.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(Sonar S3776)

Behavior-preserving extraction of helper methods:
- Tokenizer: ParseExpressionToken, ReadExtraBraces, ReadExpressionOpening,
  ReadStaticCharacter
- LiteralParser: AppendEscapeSequence, IsEndOfLiteral

Adds HelperLiteralArgumentsAreParsed characterization tests (also pass
against the pre-refactor code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Nov 8, 2026

Copy link
Copy Markdown

@stencil-harness
stencil-harness Bot merged commit 1f6307f into master Nov 8, 2026
7 checks passed
@stencil-harness
stencil-harness Bot deleted the robot/issue-641 branch November 8, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SonarCloud quality/security remediation tracking

0 participants