Repository navigation
Enforce OSL style with OSL's own lint rules - #76
Merged
Merged
Conversation
…nd reject directives that turn off OSL-COMMENT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves the API's OSL style checks onto OSL's own linter, now that OSL reads lint rules from
opal.json(osl/.go#51).What changes
CI pins OSL to
78deaec4. That's the previous pin5895982fplus the lint config feature, so the compiler is otherwise unchanged.opal.jsongains alintsection with these severities:OSL-COMMENTandOSL-UNTYPED-GLOBAL;OSL-OBJECT-PARAM(581) andOSL-LONG-FUNCTION(53).osl lsp check,osl testandosl compilefail on these errors.Comments: every comment in the OSL code is removed, 531 lines across 56 files. Where a comment explained a number, the number is now a named constant with the same value:
roturPaymentRequestLifetimeMsandpaymentRequestReuseMarginMs;unpaidPurchaseKeyLifetimeMsandpaidPurchaseKeyLifetimeMs;roturReportFilingGraceMs;roturRequestTimeoutSeconds;roturWebhookMaxClockSkewSeconds;zipCentralDirectoryHeader.The design reasoning in the longer comments is in the backend docs (Document the storage ledger, history, webhooks and other backend design notes docs#22).
Typed globals: every top-level variable has a declared type:
*cache.Cache,*db.DB,*s3.Clientand the matching scalar types in tests.Four caches stay
autobehind// osl-disable-next-line OSL-UNTYPED-GLOBAL: shared projects, bans, shadow bans and the development feed. These hold whole-collection snapshots that are read on ordinary requests. A typed*cache.Cachewalks every value it returns to convert records, which would add about 0.4 ms per 1,000 projects to every explore request. The other caches hold scalars or small per-user objects.scripts/check_conventions.py:.oslfiles, since the linter does that now;osl-disable-*directives that name no codes or that turn offOSL-COMMENT, so the linter's comment rule can't be switched off quietly.AGENTS.md describes how the checks are now split.
No runtime behaviour or
/v1response changes.Verification
Run with OSL
78deaec4:python3 scripts/check_conventions.py --base=origin/main: passes, and catches a planted em dash in.osl, a Go comment and each forbidden directive form.osl lsp check main.osl: passes, with warnings only.osl test: 60 passed, 0 failed.osl compile main.osl: builds for both this branch andmain.scripts/e2e_smoke.py <main binary> <branch binary>: 328 steps with no server errors, and every response is the same on both binaries ("responses match").10to10.0).An independent review found nothing that must be fixed. Both should-fix findings are dealt with here: the snapshot cache cost, and the reasoning that lived only in comments, which is now in the docs.
No visible surface: lint config, CI pin, comments and types only.
Deploying
Production should now be compiled with an OSL
78deaec4build instead ofosl-5895, so the deploy matches CI. The older build ignores thelintkey, so it would still work.