Repository navigation
Conversation
…t comments The scaladoc on each test model only told what the model and the test name already say, so it goes. The suite sits in the package elsewhere because the inline given expands there as in an application: a suite inside io.eezo gets qualified access that an application never has. A test now fails when the suite moves into io.eezo. JSON that is not an object is Unfit for a record and not Malformed. This was decided against the four test rule of the ticket, which called such a body Malformed. The reasons: [1,2] and 42 are JSON, the Serde seam puts JSON that does not fit the model in Unfit, and the accepted spike gave the same answer. Malformed would also refuse a payload that is a list or a number, which a Serde of such a type reads. The list case is now a test of its own. The lenient number readers are a decision of ADR 0011; the test that pins them now names all three cases it covers. Two new tests pin what the private scaladoc of the adapter said: a complaint the model raises carries its JSON path and not the parser's byte offset, and upickle alone reads a JSON null into a String as null and into an Int as 0, the behaviour NoNulls refuses.
Only the public API keeps scaladoc: idReadWriter and serde. The reasons the private scaladoc carried now live where a check can find them. ADR 0011 records how the adapter reads a body: two passes over the bytes, so the pass that failed tells Malformed from Unfit; no ujson.Value tree, so a large Long stays exact and a deep body costs no thread stack; the decided fields put in while the body streams past; upickle's own lenient number readers, because strict readers would need an upickle Api of eezo's whose ReadWriter is a type apart from the author's. ADR 0006 already says that the status of a failure is the decision of http, so the adapter answers an Either and throws nothing of eezo's. The tests of UpickleAdapterSuite pin the rules: the decided names, the escapes and repeats, the null refusal at its path, the Option that keeps its null, the reason with its JSON path and no byte offset. One decision stays in this message. adapt is the one place where the inline given hands off to compiled code. So UpickleSerde is compiled once and not copied into each call site, and it stays out of the public API: an application writes serde, never adapt.
SerdeRouteSuite boots a server and does not call the handler, because the status of a refusal is decided at the boundary and the content type of a JSON body where the response is written. Neither shows on the value a handler returns. The suite sits in io.eezo.json.upickle so that the adapter's given is in scope without an import and Route.handwritten, which is private to eezo, builds the routes; the compiler pins both. The helper that reads what the adapter says about a body is now adapterReason. In DerivedApiSuite, the line that said a row a program creates is the row the page shows is now a test with that name. The guard that names the caller from the X-User header is now the value callerFromUserHeader, and the note store with one row of grace's is ownedNotes. The scaladoc on the models and the suite told what their names and the test names say.
… adapter rests on LibraryConstraintsSuite holds one test for each third party constraint that ADR 0011 names. The test of upickle's null reading moves there. Two new tests in UpickleAdapterSuite pin the scope rule that the scaladoc of serde tells a user: the imported serde wins over a Serde in the model's companion, and a Serde in a nearer scope wins over the import. The test of the suite's package goes. Three tests already assert compile errors that name elsewhere.Plain and elsewhere.Opaque, so they go red when the suite moves to another package.
…s the design The scaladoc of serde told why only a case class is derived and why the given is inline. That text is design, so it moves to ADR 0011. The scaladoc keeps what a user needs: which instance wins, how far derivation goes, where the compiler names a missing instance, and how an application's own Serde wins. ADR 0011 now also records the inline given and adapt, the rejected option that calls JSON that is not an object Malformed, and the tests of LibraryConstraintsSuite. Its title and file name say both decisions.
… scaladoc states it The scaladoc of serde says that a Serde the application gives for one model wins at any level. The test checks a given at the package level and one in the test. The array test has a name with no clause of reason.
…bump can make red Deleted: the Mirror and ClassTag test, the List and Option Mirror test, the nesting test and the escape test. The suite has its own models. The offset test no longer asserts the full message text.
The show page must contain the name and the cents of the created row. The guard value is currentUserFromHeader, the word of CONTEXT.md.
…o passes Each record has one decision, its rejected options and its consequences. The NOTE paragraphs and the lists of test names are gone.
Branch refactor/no-comment-core holds 0012 to 0016, so bin/adr-next gives 0017.
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.
Why
The maintainer decided that a comment is allowed in one place only: scaladoc on a member of the public API, in main code, and that scaladoc tells a user how to use the member. Every other comment is refused, and that includes every comment in a test source, scaladoc on a private member, and history or design rationale in public scaladoc. The reason that a comment carried moves to a test whose name states it or to an ADR, and a constraint of a third party becomes a test that pins the behaviour of that third party.
This pull request applies the decision to
modules/upickle. It is one of three pilot modules.What
Comments refused by the rule, counted with a syntactic lint rule that is not in the build yet (one finding for each line comment line, one for each scaladoc):
The public scaladoc of
idReadWriterstays as it was. The public scaladoc ofserdekeeps its usage text and loses its design rationale. Its last sentence is corrected: aSerdethat the application gives for one model wins over the import at any level, not only at a nearer level. No module has a protected member, so no scaladoc of that kind was in scope.Behaviour and public API do not change. The changes are: deleted comments, two ADRs, a suite
LibraryConstraintsSuitewith 4 tests that pin the behaviour of upickle and ujson, 3 new tests and 2 tests split out of others in the module's suites, one renamed test, and new names in tests. The module suite has 42 tests, 33 before.ADRs
serdebuilds theSerdefrom aupickle.default.ReadWriter, and derives one only for a case class. Rejected: derive each type with aMirror; a given that is not inline; strict numbers through anApiof eezo's own.Serdereads a body in two passes over its bytes, and builds noujson.Value. Rejected: edit a parsed tree; one pass that sorts exceptions;Malformedfor JSON that is not an object.Both record decisions taken on issue #309 (and #328 for the decided fields). 0012 to 0016 are taken by
refactor/no-comment-core, sobin/adr-nextgave 0017. Neither ADR names a test or a private member.Where each reason went
"Red under X" names a revert check of the next table: the production line was broken, the module suite was run, the named test went red, and the line was restored.
UpickleSerde.scala,serde(public)ListandOptionare sums of the standard library too ... an error about::orSome"UpickleSerde.scala,serde(public)UpickleSerde.scala,serde(public)MirrorandClassTagderivation needs resolves for an abstractA"ReadWriter, theMirrorand theClassTag, and option 2. Red under M3: the suite does not compile; the first error is in "a model with no ReadWriter is derived, with its fields named as declared"UpickleSerde.scala,serde(public)Serdein a model's companion"UpickleSerde.scala,serde(public)Serdefor one model also wins when the import ofserdeis nearer. The scaladoc now says "by a given or an import at any level". Test "a Serde the application gives for one model wins over the imported serde, at any level" (no eezo line makes it red)UpickleSerde.scala,adaptUpickleSerde.scala,UpickleSerdeEitherand throws nothing of eezo's: the HTTP status a failure earns ishttp's decision, and an adapter that threw would make it twice"request.as[A]answers theEitherby throwing)UpickleSerde.scala,UpickleSerdeIntor aLongthe way upickle's own readers make it ... Strict readers would need an upickleApiof eezo's"UpickleSerde.scala,parsedSerdeRouteSuiteUpickleSerde.scala,parsedStackOverflowError)UpickleSerde.scala,fittedujson.Valuein between, because that tree holds every number as aDouble...StackOverflowError"UpickleSerde.scala,fittedNoNullsbecause upickle takes a JSONnullfor the model and for any of its fields"UpickleSerde.scala,tracedUpickleSerde.scala,tracedUpickleSerde.scala,DecidedUpickleSerde.scala,DecidedUpickleSerde.scala,DecidedUpickleSerde.scala,Decidedownerandidwith escapes, so it goes red if ujson stops undoing escapes. No eezo lineUpickleSerde.scala,DecidedUpickleSerde.scala,NoNullsUpickleSerde.scala,NoNullsnullfor aString, a key or a decimal ... boxednullthat unboxes to0"Stringand anInt). Red under R2 for a key and aBigDecimal: the null field testUpickleSerde.scala,NoNullsnulllater as a 500 rather than the client hearing a 422 now"UpickleSerde.scala,NoNullsnulla meaning of its own, as anOption... keeps it ... at its own path"UpickleAdapterSuite.scala, suiteio.eezoon purpose. The given is inline and expands here ..."UpickleAdapterSuite.scala, suiteSerde"UpickleAdapterSuite.scala, line commentUpickleAdapterSuite.scala, line commentSerdeRouteSuite.scala, suiteRoute.handwrittenoutsideio.eezo, but the compiler is not a testSerdeRouteSuite.scala, suiteSerdeRouteSuite.scala,problemhttp's own suites read one with"SerdeRouteSuite.scala,reasonadapterReason, and the 400 and 422 tests compare the detail with it. Red under R9 for the 400 testsDerivedApiSuite.scala,Productderives Apiasks for comes from that import alone"DerivedApiSuite.scala, line commentDerivedApiSuite.scala,notesX-Userheader the way a guard's token arm names it"currentUserFromHeaderand the functionownedNotes. The comparison with a guard's token arm is deleted13 more scaladocs restated the code or a test name and are deleted: 9 test models in
UpickleAdapterSuite(Renamed,Plain,Order,Opaque,Holder,Tally,Line,Entry,Note),BasketinSerdeRouteSuite, andClerk,Noteand the suite scaladoc inDerivedApiSuite, with the first paragraphs of the two suite scaladocs ofUpickleAdapterSuiteandSerdeRouteSuite. ForTally, the domain example ("a 64 bit id or an amount in cents") is lost.Revert checks
Each check breaks one line, runs
bin/fast 'upickle/test'and restores the line. A test stays in this pull request only if a check of eezo code makes it red, or if it pins a behaviour of a third party that eezo depends on and that a version bump can change.traced:abort.cluetoabort.getMessagefittedreads throughmodel, notNoNulls(model)fittedreads throughujson.read, so through aujson.Valueserde:Mirror.ProductOftoMirror.OfNoNullsloses itsvisitArrayDecidedskips a decided name the first time onlydeserialize(body)isfittedalone, with noparsedtracedanswers the complaint without the pathDecided.visitEndputs no decided value inDecidedrefuses a top level array itselfNoNullsrefuses everynull, also one the model reads asNoneserde: the last case iscompiletime.errorand not a summon ofReadWriter[A]serdeis a given that is not inline, withusing rw: ReadWriter[A]adaptis publicfittedthrowsIllegalArgumentExceptionin place ofUnfitdeserialize(body)answersMalformedfor a body that starts with[Decidedskips every name of the bodyadaptisprivate[eezo]UpickleAdapterSuitemoves to packageio.eezo.insideelsewhereDerivedApiSuite.scalagets a secondgiven api.Serde[Product]at the package levelEach test this pull request adds or renames
serdescaladoc on the given search of the Scala compiler, so a compiler that ranks givens otherwise makes it redserdescaladoc with a given at the package level and one in the test. The given ranking of Scala 3 changed in 3.7, so a bump can make it rednullitself, and thenNoNullscan goupickle.defaultinstance is foundApiof eezo's own sees the author's instance, and then option 3 of ADR 0011 opens againujson.Value, not a visitor; the same change of ujson makes "a decided name the body repeats, or spells with an escape, is skipped every time" redReasons deleted with no home
These reasons fit neither a test nor an ADR, so they are deleted. The owner decides if they need a home, for example a section of the coding standards on how a suite is built.
UpickleSerde.scala, scaladoc of the privateadapt: "The one place the inline given hands off to compiled code, so the class behind it is compiled once rather than copied into every call site, and stays out of the public API: an application writesserde, never this." A reason about a private member. M6 and T3a: nothing goes red.UpickleSerde.scala, scaladoc of the privateNoNulls, the part not pinned: "Without it, the handler would meet thenulllater as a 500 rather than the client hearing a 422 now." The refusal itself is pinned (R2).UpickleAdapterSuite.scala, suite scaladoc: "In a package outsideio.eezoon purpose. The given is inline and expands here, in the application's code, so whatever it reaches for has to be reachable from here at compile time and still be there at run time; a suite insideio.eezowould be let through by qualified access an application never has." A reason about how the suite is built. T3a and a probe that made the inline body call aprivate[eezo]member ofcorewere both green in packageelsewhere, so no check found the danger it names. T3b goes red only on the package name in three strings.UpickleAdapterSuite.scala, suite scaladoc: "No server is booted: the adapter knows nothing of HTTP, so its answers are read straight off theSerde." A reason about how the suite is built. The acceptance criteria of issue api.Serde and eezo-upickle: a model crosses the wire as JSON in the dev's library #309 also say "its tests need no server".SerdeRouteSuite.scala, suite scaladoc: "Inside the adapter's package, so its given is in scope here as it is after the import in an application, and so the routes can be built the way the generated table builds them." A reason about how the suite is built. The compiler refusesRoute.handwrittenoutsideio.eezo.SerdeRouteSuite.scala, suite scaladoc: "Booted rather than called, because the status of a refusal is decided at the boundary and the content type of a JSON body where the response is written, and neither shows on the value a handler returns." A reason about how the suite is built.SerdeRouteSuite.scala, scaladoc ofproblem: "The problem a refusal carries, read with the parserhttp's own suites read one with." A reason about how the suite is built: the parser that checks the problem is not the library under test.Workarounds found
NoNullsinUpickleSerde.scala. Its scaladoc justified it by a behaviour of upickle:upickle.defaultreads a JSONnullinto aStringasnulland into anIntas0. Kept, because upickle has no setting that refusesnull. The test "upickle alone reads a JSON null into a String field as null and into an Int field as 0" pins the upickle behaviour, so it goes red if a later upickle refusesnullitself andNoNullscan go.Files to split
None. No file in the module had a section marker.
How to review
serdeas a user of the given. It must say how to use it and nothing about why it is built so.How it was tested
All runs on JDK 25.0.2.
bin/fast 'upickle/test': Passed: Total 42, Failed 0 (33 before this change).local.trusthooks:nocomment:0.1.0-ab947017159c, on main and test sources ofupickle: 7 and 28 findings before, 0 and 0 after.bin/fast 'upickle/scalafmtCheckAll': clean.bin/prose-checkon every changed file, on the commit messages and on this body: no offender.bin/gate: GATE GREEN (format, prose, compile, test, plugin, examples, site).🤖 Generated with Claude Code