Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check element order programmatically and presubmit #3677

Closed
tkoeppe opened this issue Feb 14, 2020 · 11 comments · Fixed by #4620
Closed

Check element order programmatically and presubmit #3677

tkoeppe opened this issue Feb 14, 2020 · 11 comments · Fixed by #4620

Comments

@tkoeppe
Copy link
Contributor

tkoeppe commented Feb 14, 2020

The specification elements (Remarks":, "Preconditions:, etc.) should appear in a specific, fixed order; we could try and check that this is the case programmatically and run this check as part of the presubmit checks.

jwakely added a commit to jwakely/draft that referenced this issue Feb 14, 2020
@jwakely
Copy link
Member

jwakely commented Feb 14, 2020

My script found the following (at commit b8e16d5):

algorithms.tex:9945: \expects after \effects
containers.tex:848: \expects after \effects
containers.tex:855: \effects after \ensures
containers.tex:894: \expects after \effects
containers.tex:901: \expects after \effects
containers.tex:908: \expects after \effects
containers.tex:928: \expects after \effects
containers.tex:1103: \expects after \effects
containers.tex:1113: \expects after \effects
containers.tex:1125: \expects after \effects
containers.tex:1136: \expects after \effects
containers.tex:1147: \expects after \effects
containers.tex:1159: \expects after \effects
containers.tex:1171: \expects after \effects
containers.tex:1180: \expects after \effects
containers.tex:3773: \expects after \effects
containers.tex:3795: \expects after \effects
iostreams.tex:2208: \effects after \ensures
iostreams.tex:2318: \effects after \ensures
iostreams.tex:3961: \expects after \effects
iostreams.tex:10799: \ensures after \throws
lib-intro.tex:595: \constraints after \expects
lib-intro.tex:607: \mandates after \expects
lib-intro.tex:2193: \effects after \ensures
lib-intro.tex:3001: \expects after \throws
numerics.tex:1414: \expects after \throws
strings.tex:2282: \effects after \throws
strings.tex:2423: \effects after \throws
strings.tex:2449: \effects after \throws
strings.tex:2477: \effects after \throws
strings.tex:2505: \effects after \throws
strings.tex:2612: \effects after \throws
strings.tex:2652: \effects after \throws
strings.tex:3007: \effects after \throws
strings.tex:4484: \expects after \throws
strings.tex:4488: \effects after \throws
strings.tex:4514: \effects after \throws
support.tex:2229: \expects after \effects
support.tex:2241: \expects after \effects
support.tex:2246: \expects after \effects
support.tex:2322: \expects after \effects
support.tex:2334: \expects after \effects
support.tex:2339: \expects after \effects
support.tex:2482: \expects after \effects
support.tex:2494: \expects after \effects
support.tex:2499: \expects after \effects
support.tex:2555: \expects after \effects
support.tex:2567: \expects after \effects
support.tex:2572: \expects after \effects
support.tex:2646: \expects after \effects
support.tex:2669: \expects after \effects
threads.tex:6612: \ensures after \throws
time.tex:9531: \constraints after \expects
time.tex:9568: \constraints after \expects
utilities.tex:5842: \effects after \throws
utilities.tex:6034: \effects after \throws
utilities.tex:6073: \effects after \throws
utilities.tex:6129: \effects after \throws

I haven't checked them yet but the lib-intro.tex ones are probably false positives (I think those occurrences are where we specify the elements).

@jensmaurer
Copy link
Member

The commit-id link to your script is wrong. Please fix.

@jwakely
Copy link
Member

jwakely commented Feb 22, 2020

It's not a link to the script, it's the revision I tested using the script.

The script itself is in the commit referenced above: jwakely@523fe59

@jensmaurer
Copy link
Member

Ah, sorry for the confusion. (It seems the script source code doesn't scale; its size is O(n^2/2) or so where n is the number of specification elements.)

@jensmaurer
Copy link
Member

This script scales better:

#!/usr/bin/awk -f

BEGIN {
    items = "constraints  mandates  expects  effects  synchronization  ensures  returns  throws  complexity  remarks"
    linematch = "^[\\\\](" items ")"
    gsub(/  /, "|", linematch)
    items = " " items
    # print linematch
}

/^.begin{itemdescr}/ {
    elements = ""
    startline = FNR
}

/^.end{itemdescr}/ {
    if (length(elements) > 0) {
	regex = substr(elements, 2)
	gsub(/ /, " .* ", regex)
	if (items !~ regex) {
	    printf "%s:%d-%d: bad element ordering: %s\n", FILENAME, startline, FNR, elements
	}
    }
}

match ($0, linematch) > 0 {
    elements = elements " " substr($0, 2)
}

and delivers more output:

algorithms.tex:3158-3192: bad element ordering:  mandates expects expects effects returns remarks
algorithms.tex:3201-3234: bad element ordering:  mandates expects expects effects returns remarks
algorithms.tex:3827-3866: bad element ordering:  mandates expects remarks returns complexity
algorithms.tex:5037-5083: bad element ordering:  expects effects returns remarks complexity
algorithms.tex:6143-6202: bad element ordering:  mandates expects expects effects returns complexity
algorithms.tex:7948-7968: bad element ordering:  expects returns remarks complexity
algorithms.tex:7987-8012: bad element ordering:  expects returns remarks complexity
algorithms.tex:8026-8046: bad element ordering:  expects returns remarks complexity
algorithms.tex:8065-8090: bad element ordering:  expects returns remarks complexity
algorithms.tex:8106-8126: bad element ordering:  expects returns remarks complexity
algorithms.tex:8146-8174: bad element ordering:  expects returns remarks complexity
algorithms.tex:9939-9951: bad element ordering:  effects expects throws
containers.tex:3766-3779: bad element ordering:  effects expects complexity
containers.tex:3786-3801: bad element ordering:  effects expects complexity
containers.tex:3920-3949: bad element ordering:  effects remarks complexity
containers.tex:3959-3982: bad element ordering:  effects complexity throws
containers.tex:4256-4270: bad element ordering:  returns effects remarks
containers.tex:4640-4665: bad element ordering:  effects returns throws remarks complexity
containers.tex:4703-4729: bad element ordering:  expects effects remarks complexity
containers.tex:4737-4751: bad element ordering:  effects remarks complexity
containers.tex:5124-5138: bad element ordering:  remarks complexity
containers.tex:5322-5349: bad element ordering:  effects returns throws remarks complexity
containers.tex:5396-5431: bad element ordering:  expects effects remarks complexity
containers.tex:5455-5473: bad element ordering:  effects remarks complexity
containers.tex:5774-5820: bad element ordering:  expects effects complexity throws remarks
containers.tex:5961-5991: bad element ordering:  remarks complexity
containers.tex:6000-6017: bad element ordering:  effects complexity throws
iostreams.tex:1325-1377: bad element ordering:  returns effects
iostreams.tex:2197-2216: bad element ordering:  ensures effects
iostreams.tex:2312-2321: bad element ordering:  ensures effects
iostreams.tex:3701-3792: bad element ordering:  remarks returns effects
iostreams.tex:3834-3896: bad element ordering:  remarks ensures returns
iostreams.tex:3930-4030: bad element ordering:  effects remarks expects returns
iostreams.tex:5185-5218: bad element ordering:  effects remarks returns
iostreams.tex:7801-7817: bad element ordering:  returns ensures
iostreams.tex:7995-8050: bad element ordering:  effects remarks returns
iostreams.tex:9532-9574: bad element ordering:  effects returns ensures
iostreams.tex:9806-9864: bad element ordering:  effects remarks returns
iostreams.tex:10781-10802: bad element ordering:  effects remarks throws ensures
iostreams.tex:10854-10885: bad element ordering:  effects returns ensures remarks
iostreams.tex:10914-10953: bad element ordering:  effects returns ensures remarks
iostreams.tex:13282-13364: bad element ordering:  returns effects
iostreams.tex:15782-15806: bad element ordering:  returns remarks throws
iostreams.tex:16271-16299: bad element ordering:  expects remarks effects throws
iostreams.tex:16709-16737: bad element ordering:  effects returns remarks throws
iostreams.tex:16787-16822: bad element ordering:  returns effects ensures remarks throws
locales.tex:787-820: bad element ordering:  effects remarks returns
locales.tex:829-858: bad element ordering:  effects remarks returns
locales.tex:1976-2088: bad element ordering:  expects effects remarks returns
locales.tex:3854-3898: bad element ordering:  expects effects remarks returns
locales.tex:4377-4466: bad element ordering:  effects remarks returns
numerics.tex:4099-4114: bad element ordering:  remarks throws
numerics.tex:4455-4490: bad element ordering:  complexity effects returns throws
ranges.tex:2951-2968: bad element ordering:  remarks effects
regex.tex:1162-1182: bad element ordering:  effects returns ensures
regex.tex:1599-1619: bad element ordering:  returns effects ensures throws
strings.tex:1722-1732: bad element ordering:  throws returns
strings.tex:2268-2290: bad element ordering:  expects throws effects returns
strings.tex:2415-2432: bad element ordering:  throws effects returns
strings.tex:2439-2459: bad element ordering:  expects throws effects returns
strings.tex:2466-2488: bad element ordering:  expects throws effects returns
strings.tex:2495-2507: bad element ordering:  expects throws effects
strings.tex:2597-2623: bad element ordering:  expects throws effects returns
strings.tex:2641-2663: bad element ordering:  throws effects returns
strings.tex:2999-3014: bad element ordering:  throws effects returns
strings.tex:4359-4367: bad element ordering:  throws returns
strings.tex:4475-4498: bad element ordering:  throws expects effects returns complexity
strings.tex:4505-4520: bad element ordering:  throws effects returns
strings.tex:4527-4549: bad element ordering:  effects complexity returns
support.tex:2205-2299: bad element ordering:  effects expects expects expects remarks
support.tex:2307-2352: bad element ordering:  effects expects expects expects
support.tex:2458-2532: bad element ordering:  effects expects expects expects
support.tex:2540-2585: bad element ordering:  effects expects expects expects
support.tex:2640-2656: bad element ordering:  effects expects remarks
support.tex:2663-2679: bad element ordering:  effects expects remarks
support.tex:3546-3560: bad element ordering:  effects remarks returns
support.tex:3585-3603: bad element ordering:  remarks effects
support.tex:5017-5028: bad element ordering:  returns ensures
threads.tex:928-960: bad element ordering:  constraints expects effects remarks throws
threads.tex:3299-3330: bad element ordering:  expects effects returns ensures throws
threads.tex:3338-3369: bad element ordering:  expects effects returns ensures throws
threads.tex:3377-3406: bad element ordering:  expects effects returns ensures throws
threads.tex:3452-3460: bad element ordering:  returns ensures
threads.tex:3784-3810: bad element ordering:  effects returns ensures throws
threads.tex:3818-3845: bad element ordering:  effects returns ensures throws
threads.tex:3853-3877: bad element ordering:  effects returns ensures throws
threads.tex:3923-3931: bad element ordering:  returns ensures
threads.tex:4364-4402: bad element ordering:  expects effects remarks ensures throws
threads.tex:4410-4446: bad element ordering:  expects effects remarks ensures throws
threads.tex:4455-4508: bad element ordering:  expects effects remarks ensures returns throws
threads.tex:4517-4559: bad element ordering:  expects effects returns remarks ensures throws
threads.tex:4569-4614: bad element ordering:  expects effects remarks ensures throws
threads.tex:4624-4675: bad element ordering:  expects effects remarks ensures throws
threads.tex:4807-4833: bad element ordering:  effects remarks ensures throws
threads.tex:4857-4900: bad element ordering:  effects remarks ensures returns throws
threads.tex:4908-4938: bad element ordering:  effects returns remarks ensures throws
threads.tex:4998-5034: bad element ordering:  effects ensures remarks throws
threads.tex:5042-5087: bad element ordering:  effects ensures remarks throws
threads.tex:6561-6569: bad element ordering:  returns ensures
threads.tex:6578-6614: bad element ordering:  effects returns throws ensures
time.tex:8573-8599: bad element ordering:  expects effects returns ensures throws
time.tex:9525-9542: bad element ordering:  expects constraints effects
time.tex:9562-9579: bad element ordering:  expects constraints effects
utilities.tex:173-199: bad element ordering:  remarks effects
utilities.tex:207-221: bad element ordering:  remarks effects
utilities.tex:379-387: bad element ordering:  remarks remarks
utilities.tex:677-691: bad element ordering:  effects remarks returns
utilities.tex:698-712: bad element ordering:  effects remarks returns
utilities.tex:719-741: bad element ordering:  effects remarks remarks returns
utilities.tex:748-763: bad element ordering:  effects remarks returns
utilities.tex:1445-1459: bad element ordering:  effects remarks returns
utilities.tex:1466-1490: bad element ordering:  effects remarks remarks returns
utilities.tex:1497-1512: bad element ordering:  effects remarks returns
utilities.tex:1519-1534: bad element ordering:  effects remarks returns
utilities.tex:1542-1559: bad element ordering:  effects remarks returns
utilities.tex:1567-1585: bad element ordering:  effects remarks returns
utilities.tex:1594-1618: bad element ordering:  effects remarks throws
utilities.tex:1704-1748: bad element ordering:  remarks returns
utilities.tex:2020-2041: bad element ordering:  returns effects
utilities.tex:2104-2119: bad element ordering:  remarks effects
utilities.tex:2564-2576: bad element ordering:  effects returns ensures
utilities.tex:2583-2622: bad element ordering:  effects returns ensures remarks
utilities.tex:2629-2676: bad element ordering:  effects returns ensures remarks
utilities.tex:2683-2704: bad element ordering:  effects returns ensures remarks
utilities.tex:2711-2765: bad element ordering:  effects returns ensures remarks
utilities.tex:2772-2827: bad element ordering:  effects returns ensures remarks
utilities.tex:4144-4186: bad element ordering:  effects returns ensures remarks
utilities.tex:5190-5212: bad element ordering:  effects remarks throws
utilities.tex:5318-5330: bad element ordering:  effects returns ensures
utilities.tex:5338-5364: bad element ordering:  effects returns remarks throws
utilities.tex:5832-5874: bad element ordering:  throws effects
utilities.tex:6026-6042: bad element ordering:  throws effects returns
utilities.tex:6065-6080: bad element ordering:  throws effects returns
utilities.tex:6121-6136: bad element ordering:  throws effects returns
utilities.tex:6143-6156: bad element ordering:  throws returns
utilities.tex:6163-6176: bad element ordering:  throws returns
utilities.tex:6247-6261: bad element ordering:  throws returns
utilities.tex:7035-7048: bad element ordering:  remarks returns
utilities.tex:7955-7971: bad element ordering:  returns remarks throws
utilities.tex:9143-9189: bad element ordering:  effects remarks ensures remarks
utilities.tex:9236-9272: bad element ordering:  remarks effects ensures
utilities.tex:9303-9329: bad element ordering:  constraints effects returns ensures
utilities.tex:9336-9364: bad element ordering:  remarks effects returns ensures
utilities.tex:9751-9760: bad element ordering:  remarks returns
utilities.tex:9767-9776: bad element ordering:  remarks returns
utilities.tex:9838-9847: bad element ordering:  remarks effects
utilities.tex:10379-10394: bad element ordering:  remarks effects ensures
utilities.tex:10402-10416: bad element ordering:  remarks effects ensures
utilities.tex:10451-10465: bad element ordering:  remarks effects
utilities.tex:10685-10705: bad element ordering:  returns remarks throws
utilities.tex:10800-10924: bad element ordering:  effects returns ensures throws remarks
utilities.tex:11480-11496: bad element ordering:  remarks effects ensures
utilities.tex:11504-11518: bad element ordering:  remarks effects ensures
utilities.tex:11543-11556: bad element ordering:  effects remarks returns
utilities.tex:12721-12740: bad element ordering:  returns effects throws
utilities.tex:12934-12957: bad element ordering:  returns effects throws
utilities.tex:13841-13861: bad element ordering:  remarks effects
utilities.tex:15615-15651: bad element ordering:  remarks ensures throws

@AlisdairM
Copy link
Contributor

I was about to file an issue on generally inconsistent ordering of constraints, mandates, and preconditions (expects) in the current draft, that probably arose after applying a number of papers for Prague, but figured I should defer to this ticket? Probably worth running that script again to see if the problem is getting worse. Do we have any plans to resolve the reported orderings?

@jensmaurer
Copy link
Member

I'm willing to post a pull request that fixes the orderings here, at least those that can be fixed by simple reordering.
@jwakely , would you be willing to review on fairly short notice?

@jwakely
Copy link
Member

jwakely commented Jul 3, 2020

I have limited net access this weekend, but after that yes

@jensmaurer
Copy link
Member

Thanks; I just want to avoid repeated merge conflicts.

@jensmaurer
Copy link
Member

Remaining cases:

iostreams.tex:3703-3794: bad element ordering:  returns remarks effects
iostreams.tex:3836-3898: bad element ordering:  remarks returns ensures
iostreams.tex:3932-4032: bad element ordering:  effects remarks expects returns
locales.tex:1976-2088: bad element ordering:  expects effects remarks returns
numerics.tex:4427-4477: bad element ordering:  complexity effects returns throws
regex.tex:1600-1620: bad element ordering:  returns effects ensures throws
utilities.tex:1940-1985: bad element ordering:  expects remarks returns
utilities.tex:4631-4664: bad element ordering:  mandates constraints effects ensures returns throws remarks
utilities.tex:4672-4705: bad element ordering:  mandates constraints effects ensures returns throws remarks
utilities.tex:9807-9851: bad element ordering:  mandates constraints expects effects ensures throws

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Jul 23, 2020
@jensmaurer jensmaurer removed their assignment Jan 3, 2021
@jensmaurer
Copy link
Member

Editorial meeting: Allow for a comment marker on \begin{itemdescr} such as "% CHECK: noordering" to disable the check. Then, activate the script.

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label May 28, 2021
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 a pull request may close this issue.

4 participants