Skip to content

fix(texttemplate): satisfy linter rules - #185

Merged
moshloop merged 1 commit into
mainfrom
fix-texttemplate-lint
Nov 13, 2026
Merged

moshloop merged 1 commit into
mainfrom
fix-texttemplate-lint

Conversation

@moshloop

@moshloop moshloop commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Documentation
    • Clarified that lint-only updates in the upstream sync do not change application behavior.
  • Bug Fixes
    • Improved cleanup in example programs when errors occur, and made file-writing helpers handle close errors more reliably.
    • No changes to template behavior or public functionality.

…and refresh conformance cases

The fork brought upstream text/template code under this repo's golangci-lint rules, which failed main with 14 findings. Rename sentinel errors to errFoo, use camelCase test names, return error last, collapse an else-if, check an ignored Parse error, and use log.Panic in examples so deferred cleanup runs. Each change is tagged gomplate: lint and does not change behaviour.

Regenerate conformance.json, which was stale after GO_TEMPLATE.md gained the values provider examples.

Claude-Session-Id: 9cbaec31-655b-4670-a331-adddc1c8c5d2
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

This change updates template example error handling and file cleanup, renames internal range-control sentinels, adjusts tests, and clarifies that upstream lint-only changes do not affect behavior.

Changes

Template package maintenance

Layer / File(s) Summary
Example file cleanup and error handling
texttemplate/examplefiles_test.go
createTestDir closes files before handling errors. Examples use log.Panic or log.Panicf for failures and clarify that panic-based handling allows deferred directory cleanup to run.
Template execution and test maintenance
texttemplate/exec.go, texttemplate/exec_test.go, texttemplate/funcs.go, texttemplate/README.md
Range-control sentinels are renamed without changing their values or handling. Tests update fixture signatures and identifiers, and fail immediately if parsing the explicit call template returns an error. The README distinguishes lint-only upstream changes from behavior changes.

Suggested reviewers: hairyhenderson

Change: Refactor

Merge Risk: Minimal · up to c1301

This change only satisfies lint rules and adjusts examples and tests. It does not change runtime behavior, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix(texttemplate): satisfy linter rules" matches the main change. The raw summary and objectives show lint-driven fixes in texttemplate: renamed sentinel errors (walkBreak/walkContinue to e…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(texttemplate): satisfy linter rules" matches the main change. The raw summary and objectives show lint-driven fixes in texttemplate: renamed sentinel errors (walkBreak/walkContinue to errWalkBreak/errWalkContinue), test renames, return-order changes in a test fixture, a Parse error check, log.Panic in examples, and a simplified call branch. The title names the purpose and scope without listing files. It uses a conventional-commit prefix, which is consistent with the commit history described in the objectives.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0e548086-f376-4a1c-bfbb-1a7bd8a4d2f5
Commits

Reviewing files that changed from the base of the PR and between af2c9bc and c1301f7.

Files ignored due to path filters: 1

  • web/packages/lang/src/generated/conformance.json is excluded by !**/generated/**
Files selected for processing: 5

  • texttemplate/README.md
  • texttemplate/examplefiles_test.go
  • texttemplate/exec.go
  • texttemplate/exec_test.go
  • texttemplate/funcs.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Benchstat

Base: af2c9bc8268bbc883f346e3347cbff6ae9459580
Head: c1301f7a966cd61823c9b41988fed5fb5cc2521b

1 improvement(s)
Benchmark Metric Base Head Change p-value
Serialize_NoNativeTypes/items=1000/native_values=false-4 sec/op 1.38 ms/op 1.36 ms/op -1.44% 0.011
Full benchstat output
goos: linux
goarch: amd64
cpu: AMD EPYC 7763 64-Core Processor                
                                                                         │ bench-base.txt │           bench-head.txt            │
                                                                         │     sec/op     │    sec/op     vs base               │
CELEnvExtendCustomFunction-4                                                  85.03µ ± 1%   84.77µ ±  1%       ~ (p=0.631 n=10)
CELProgramEvaluation/expression=scalar/optimized=false-4                      190.1n ± 0%   190.2n ±  2%       ~ (p=0.753 n=10)
CELProgramEvaluation/expression=scalar/optimized=true-4                       190.1n ± 1%   189.8n ±  1%       ~ (p=0.868 n=10)
CELProgramEvaluation/expression=list_optional_regex/optimized=false-4         4.744µ ± 4%   4.725µ ±  1%       ~ (p=0.516 n=10)
CELProgramEvaluation/expression=list_optional_regex/optimized=true-4          1.765µ ± 1%   1.755µ ±  1%       ~ (p=0.148 n=10)
CELProgramEvaluation/expression=comprehension/optimized=false-4               6.426µ ± 1%   6.472µ ±  4%       ~ (p=0.128 n=10)
CELProgramEvaluation/expression=comprehension/optimized=true-4                6.205µ ± 0%   6.221µ ± 12%       ~ (p=0.425 n=10)
RunExpressionNativeInput/input=map-4                                          3.081µ ± 0%   3.094µ ±  3%       ~ (p=0.100 n=10)
RunExpressionNativeInput/input=native_struct-4                                3.033µ ± 1%   3.045µ ±  1%       ~ (p=0.210 n=10)
RunExpressionContext/cache=hit/environment=small-4                            1.808µ ± 1%   1.815µ ±  1%       ~ (p=0.470 n=10)
RunExpressionContext/cache=hit/environment=large-4                            1.946µ ± 2%   1.957µ ±  2%       ~ (p=0.424 n=10)
RunExpressionContextCompile/cache=miss/environment=small-4                    343.8µ ± 1%   345.7µ ±  1%       ~ (p=0.481 n=10)
RunExpressionContextCompile/cache=miss/environment=large-4                    344.5µ ± 1%   342.8µ ±  1%       ~ (p=0.631 n=10)
CELEnvExtend/variables=1/functions=0-4                                        6.609µ ± 2%   6.606µ ±  1%       ~ (p=0.912 n=10)
CELEnvExtend/variables=10/functions=0-4                                       8.416µ ± 3%   8.386µ ±  2%       ~ (p=0.247 n=10)
CELEnvExtend/variables=100/functions=0-4                                      24.56µ ± 1%   24.54µ ±  1%       ~ (p=0.579 n=10)
RunExpressionContextFunctions/celFunctions/cache=hit/environment=large-4      4.342µ ± 3%   4.309µ ±  1%       ~ (p=0.315 n=10)
RunExpressionContextFunctions/functions/cache=hit/environment=large-4         4.332µ ± 4%   4.289µ ±  1%       ~ (p=0.404 n=10)
Serialize/items=10/native_values=true-4                                       44.39µ ± 3%   44.27µ ±  1%       ~ (p=0.393 n=10)
Serialize/items=100/native_values=true-4                                      356.3µ ± 1%   353.4µ ±  0%       ~ (p=0.123 n=10)
Serialize/items=1000/native_values=true-4                                     3.516m ± 2%   3.528m ±  1%       ~ (p=0.631 n=10)
Serialize/items=10000/native_values=true-4                                    38.19m ± 2%   38.43m ±  3%       ~ (p=0.315 n=10)
Serialize_NoNativeTypes/items=100/native_values=false-4                       147.1µ ± 1%   146.5µ ±  2%       ~ (p=0.165 n=10)
Serialize_NoNativeTypes/items=1000/native_values=false-4                      1.385m ± 3%   1.365m ±  2%  -1.44% (p=0.011 n=10)
Serialize_NoNativeTypes/items=10000/native_values=false-4                     14.08m ± 2%   14.19m ±  2%       ~ (p=0.436 n=10)
RunTemplate_LargeEnv/items=10-4                                               5.109µ ± 3%   5.110µ ±  3%       ~ (p=1.000 n=10)
RunTemplate_LargeEnv/items=1000-4                                             5.121µ ± 2%   5.086µ ±  2%       ~ (p=0.912 n=10)
RunTemplate_LargeEnv/items=10000-4                                            5.056µ ± 1%   5.026µ ±  0%       ~ (p=0.343 n=10)
geomean                                                                       22.60µ        22.58µ        -0.12%

                                                                         │ bench-base.txt │            bench-head.txt             │
                                                                         │      B/op      │     B/op      vs base                 │
CELEnvExtendCustomFunction-4                                                 46.31Ki ± 0%   46.31Ki ± 0%       ~ (p=1.000 n=10) ¹
CELProgramEvaluation/expression=scalar/optimized=false-4                       96.00 ± 0%     96.00 ± 0%       ~ (p=1.000 n=10) ¹
CELProgramEvaluation/expression=scalar/optimized=true-4                        96.00 ± 0%     96.00 ± 0%       ~ (p=1.000 n=10) ¹
CELProgramEvaluation/expression=list_optional_regex/optimized=false-4        4.241Ki ± 0%   4.241Ki ± 0%       ~ (p=0.547 n=10)
CELProgramEvaluation/expression=list_optional_regex/optimized=true-4         1.148Ki ± 0%   1.148Ki ± 0%       ~ (p=0.319 n=10)
CELProgramEvaluation/expression=comprehension/optimized=false-4              3.063Ki ± 0%   3.063Ki ± 0%       ~ (p=1.000 n=10) ¹
CELProgramEvaluation/expression=comprehension/optimized=true-4               2.798Ki ± 0%   2.798Ki ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionNativeInput/input=map-4                                         1.375Ki ± 0%   1.375Ki ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionNativeInput/input=native_struct-4                               1.250Ki ± 0%   1.250Ki ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionContext/cache=hit/environment=small-4                             840.0 ± 0%     840.0 ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionContext/cache=hit/environment=large-4                             936.0 ± 0%     936.0 ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionContextCompile/cache=miss/environment=small-4                   219.2Ki ± 0%   219.1Ki ± 0%       ~ (p=0.110 n=10)
RunExpressionContextCompile/cache=miss/environment=large-4                   219.5Ki ± 0%   219.4Ki ± 0%       ~ (p=0.184 n=10)
CELEnvExtend/variables=1/functions=0-4                                       4.477Ki ± 0%   4.477Ki ± 0%       ~ (p=1.000 n=10) ¹
CELEnvExtend/variables=10/functions=0-4                                      6.157Ki ± 0%   6.157Ki ± 0%       ~ (p=0.650 n=10)
CELEnvExtend/variables=100/functions=0-4                                     23.63Ki ± 0%   23.63Ki ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionContextFunctions/celFunctions/cache=hit/environment=large-4     2.297Ki ± 0%   2.297Ki ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionContextFunctions/functions/cache=hit/environment=large-4        2.359Ki ± 0%   2.359Ki ± 0%       ~ (p=1.000 n=10) ¹
Serialize/items=10/native_values=true-4                                      34.39Ki ± 0%   34.39Ki ± 0%       ~ (p=0.656 n=10)
Serialize/items=100/native_values=true-4                                     304.6Ki ± 0%   304.6Ki ± 0%       ~ (p=1.000 n=10) ¹
Serialize/items=1000/native_values=true-4                                    2.946Mi ± 0%   2.946Mi ± 0%       ~ (p=0.907 n=10)
Serialize/items=10000/native_values=true-4                                   29.45Mi ± 0%   29.45Mi ± 0%       ~ (p=0.262 n=10)
Serialize_NoNativeTypes/items=100/native_values=false-4                      104.0Ki ± 0%   104.0Ki ± 0%       ~ (p=1.000 n=10) ¹
Serialize_NoNativeTypes/items=1000/native_values=false-4                     1.007Mi ± 0%   1.007Mi ± 0%       ~ (p=1.000 n=10)
Serialize_NoNativeTypes/items=10000/native_values=false-4                    10.07Mi ± 0%   10.07Mi ± 0%       ~ (p=0.895 n=10)
RunTemplate_LargeEnv/items=10-4                                              5.273Ki ± 0%   5.273Ki ± 0%       ~ (p=1.000 n=10) ¹
RunTemplate_LargeEnv/items=1000-4                                            5.273Ki ± 0%   5.273Ki ± 0%       ~ (p=1.000 n=10) ¹
RunTemplate_LargeEnv/items=10000-4                                           5.273Ki ± 0%   5.273Ki ± 0%       ~ (p=1.000 n=10) ¹
geomean                                                                      14.79Ki        14.79Ki       -0.00%
¹ all samples are equal

                                                                         │ bench-base.txt │            bench-head.txt            │
                                                                         │   allocs/op    │  allocs/op   vs base                 │
CELEnvExtendCustomFunction-4                                                   112.0 ± 0%    112.0 ± 0%       ~ (p=1.000 n=10) ¹
CELProgramEvaluation/expression=scalar/optimized=false-4                       3.000 ± 0%    3.000 ± 0%       ~ (p=1.000 n=10) ¹
CELProgramEvaluation/expression=scalar/optimized=true-4                        3.000 ± 0%    3.000 ± 0%       ~ (p=1.000 n=10) ¹
CELProgramEvaluation/expression=list_optional_regex/optimized=false-4          79.00 ± 0%    79.00 ± 0%       ~ (p=1.000 n=10) ¹
CELProgramEvaluation/expression=list_optional_regex/optimized=true-4           30.00 ± 0%    30.00 ± 0%       ~ (p=1.000 n=10) ¹
CELProgramEvaluation/expression=comprehension/optimized=false-4                91.00 ± 0%    91.00 ± 0%       ~ (p=1.000 n=10) ¹
CELProgramEvaluation/expression=comprehension/optimized=true-4                 87.00 ± 0%    87.00 ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionNativeInput/input=map-4                                           36.00 ± 0%    36.00 ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionNativeInput/input=native_struct-4                                 29.00 ± 0%    29.00 ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionContext/cache=hit/environment=small-4                             20.00 ± 0%    20.00 ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionContext/cache=hit/environment=large-4                             23.00 ± 0%    23.00 ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionContextCompile/cache=miss/environment=small-4                    2.363k ± 0%   2.363k ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionContextCompile/cache=miss/environment=large-4                    2.368k ± 0%   2.368k ± 0%       ~ (p=1.000 n=10) ¹
CELEnvExtend/variables=1/functions=0-4                                         72.00 ± 0%    72.00 ± 0%       ~ (p=1.000 n=10) ¹
CELEnvExtend/variables=10/functions=0-4                                        91.00 ± 0%    91.00 ± 0%       ~ (p=1.000 n=10) ¹
CELEnvExtend/variables=100/functions=0-4                                       193.0 ± 0%    193.0 ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionContextFunctions/celFunctions/cache=hit/environment=large-4       44.00 ± 0%    44.00 ± 0%       ~ (p=1.000 n=10) ¹
RunExpressionContextFunctions/functions/cache=hit/environment=large-4          48.00 ± 0%    48.00 ± 0%       ~ (p=1.000 n=10) ¹
Serialize/items=10/native_values=true-4                                        424.0 ± 0%    424.0 ± 0%       ~ (p=1.000 n=10) ¹
Serialize/items=100/native_values=true-4                                      3.844k ± 0%   3.844k ± 0%       ~ (p=1.000 n=10) ¹
Serialize/items=1000/native_values=true-4                                     39.53k ± 0%   39.53k ± 0%       ~ (p=1.000 n=10) ¹
Serialize/items=10000/native_values=true-4                                    399.5k ± 0%   399.5k ± 0%       ~ (p=1.000 n=10) ¹
Serialize_NoNativeTypes/items=100/native_values=false-4                       1.721k ± 0%   1.721k ± 0%       ~ (p=1.000 n=10) ¹
Serialize_NoNativeTypes/items=1000/native_values=false-4                      17.77k ± 0%   17.77k ± 0%       ~ (p=1.000 n=10) ¹
Serialize_NoNativeTypes/items=10000/native_values=false-4                     179.8k ± 0%   179.8k ± 0%       ~ (p=1.000 n=10) ¹
RunTemplate_LargeEnv/items=10-4                                                39.00 ± 0%    39.00 ± 0%       ~ (p=1.000 n=10) ¹
RunTemplate_LargeEnv/items=1000-4                                              39.00 ± 0%    39.00 ± 0%       ~ (p=1.000 n=10) ¹
RunTemplate_LargeEnv/items=10000-4                                             39.00 ± 0%    39.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean                                                                        228.6         228.6       +0.00%
¹ all samples are equal

@moshloop
moshloop merged commit a1fe080 into main Nov 13, 2026
13 checks passed
@moshloop
moshloop deleted the fix-texttemplate-lint branch November 13, 2026 06:28
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.

1 participant