Repository navigation
fix(rules): length does not measure a list-literal table - #398
Merged
Merged
Conversation
A def whose body is one `[..]` list of data and nothing else is a table, as a `match` of one-statement arms is since #381: a generated list of records, such as ezhttp's src/entities.bend `table` (the HTML Standard's 2231 named character references, 2234 lines). Its length is how many rows there are, and the one edit that silenced `length` was to cut the list in two at some line, which helps no reader. Data is numbers, strings, chars, commas, capitalized and dotted names and `[..]` and `{..}` groups of them. A plain lowercase name (a variable or a call's head), an operator, a keyword, a `(..)` group, a token after the list's `]` or a line under it makes the def no table, and it is measured as before. laws/SizeReportsOversizedDefs.bend: `table_takes_data_list`, `table_list_needs_data`, `table_list_holds_nothing_under`, `table_list_is_whole_statement`, `data_reads_token`, `data_reads_group` and `data_rejects_statement` are new; the prose names the new table. `length_skips_table` and `length_measures_other_def` hold as stated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
length(S010) no longer measures a def whose body is one[..]list of data and nothing else. #381 exempted a table written as amatch; this is the same table written as a list:Data is numbers, strings, chars, commas, capitalized and dotted names (a constructor's, or a def named and not called) and
[..]and{..}groups of them.Why
ezhttp's
src/entities.bendtableis the HTML Standard's 2231 named character references, generated, 2234 lines.lengthreported it as an error, and the only edit that silenced it was cutting the list into arbitrary chunks. That has no step to move into a helper and fails the honest-fix testsrc/README.mdsets for a rule, exactly as #381 found formatchtables.What is still measured
A plain lowercase name anywhere in the list (a variable, or a call's head such as
f(x)), an operator (so-1anda + b), a keyword, a(..)group, a token after the]([..] ++ more), or a line under the statement makes the def no table, and it is measured as before. A second statement in the body still makes any def no table.arityanddepthare unchanged.Checked on a sample file: a 53-line list of
R{"n", 1, 0}rows is not reported; the same list withf(i)in each row, and the same list followed by++ [], are.Laws
laws/SizeReportsOversizedDefs.bend, prose extended to name the list-of-data table; two law-side definitions,literal(the token kinds data holds) andbracket([or{), state the data set independently of the code.table_takes_data_list: one statement holding a[list of data, nothing under it, is a tabletable_list_needs_data: a list holding what is not data (a call, a match) is no tabletable_list_holds_nothing_under: a list with a line under it is no tabletable_list_is_whole_statement: a list with a token after its](no:) is no tabledata_reads_token: a token is data exactly when its kind isliteral, and what follows is datadata_reads_group: a group is data exactly when it opens with[or{and holds and is followed by datadata_rejects_statement: a statement among the elements is no datalength_skips_table,length_measures_other_defandsize_countshold as stated, since they are stated overtableand the measure. No new trusted assumption. Still not proved, as before: that no comment or string changes a finding of these rules.Behavior change
Yes:
lengthreports fewer defs (generated data lists). A project with a# noqa: S010on such a list will seenoqa(S005) report it as silencing nothing.Checks
bend PROOF.bend --check-only(bend 2.0.40):ALL PROOFS CHECKnix flake check -L: passes (proofs 2/2 PROOF.bend ok, lint 0 errors / 32 warnings as on main, fmt, lsp)src/entities.bend:clean; bolt 1.65.0 (dfb06d0) reportsS010: Def table is 2234 lines long🤖 Generated with Claude Code