Dead code: eighteen unreferenced definitions and an orphaned posting form, several of them traps for whoever finds them #401

Closed
opened 2026-10-01 10:46:25 +00:00 by tiagoagueda · 0 comments
Owner

Found on 2026-09-29 in a read-only review of postulo at 95348908d, searching every snapshot repository (postulo, the plugins, the extensions, postulo-mcp, postulo-templates and the wiki; source, tests, templates and static files) for each name.

Checked again on 2026-10-01 against main at 0a5cad587: still present. The code is now at documents/kinds.py:136-138 (authored_choices), resume/translatable.py:50-51 (may_translate), applications/agenda.py:163-165 (Event.local_end), documents/models.py:318-325 (CVItem.highlight_lines) and documents/models.py:195-197 (CV_THEMES), documents/rendering.py:100-112 (Entry.highlight_lines, read at :282 and :294; the entry put into the CV's language at :143-144, cv in the theme context at :228), core/mail.py:24-26 (CONVENTIONAL_PORTS), core/mail.py:32 (DEFAULT_MAIL_PORTS) and core/mail.py:43-66 (_mismatch), tests/test_width.py:64 and :69, and tests/e2e/test_accessibility.py:479 and :539; the other locations have not moved.

Each definition below is referenced nowhere but its own line (may_translate also in the list that re-exports it). Most are harmless leftovers. Five are worse than dead: three carry comments describing a job they no longer do, one is a second rule for an unanswered application that disagrees with the one every page uses, and one shares its name with the property CV themes are told to read but answers in the wrong language. A whole view also survives for a page nothing links to.

1. Unreferenced definitions

  • api/views.py:69 token_list_url
  • applications/analytics.py:622-629 has_enough_history
  • applications/quiet.py:150-155 quiet_by
  • applications/services.py:546 LATER_CHOICES
  • core/backup.py:574-578 as_dict
  • core/messages_tool.py:192-197 owner_of
  • documents/kinds.py:117-119 authored_choices (Kind.authored itself stays: the registry entries set it)
  • resume/translatable.py:50-51 may_translate: #248 moved it out of resume/translating.py, which now names it in its re-export list (resume/translating.py:54). Nothing calls it under either module.
  • core/models.py:475-481 PhoneNumber.forget_verification: PhoneNumber.save() (core/models.py:369) already clears verified_at and is_recovery when the number changes, so this has no caller and no job.
  • applications/agenda.py:147-149 Event.local_end, applications/endings.py:58-60 status_label, applications/models.py:895-897 Suggestion.is_matched, applications/reports.py:366-367 Tally.share_of: properties and methods whose names occur once in the whole corpus, templates included. (Event.is_span, beside local_end, is read by one test only, tests/test_calendar.py:90.)

2. Unreferenced, and misleading

  • applications/analytics.py:611-619 applications_needing_a_nudge: "Applications that were sent, never answered, and are getting old", decided by a fixed 14 days and APPLIED or ACKNOWLEDGED only. applications/quiet.py:11-12 says "Everything that shows or counts quiet applications uses the one predicate here, so the dashboard, the board, the table, the figures and the notifier all agree"; this is a second predicate beside it, which ignores the person's own threshold (threshold_for), the reminders already set and the interviews not yet held.
  • documents/models.py:278-285 CVItem.highlight_lines: the shipped themes read entry.highlight_lines on rendering.Entry (documents/rendering.py:126-138; templates/documents/themes/base_cv.html:121, base_portfolio.html:74; documents/rendering.py:308 and :320), and the highlight_lines in templates/resume/overview.html and preview.html is the career item's own (resume/models.py:60). Nothing reads the one on CVItem. The two bodies are the same code, but Entry.item is the entry already put into the CV's language (documents/rendering.py:169-170, #131), while CVItem.item is the master copy.
  • applications/tables.py:112-113 STATUSES: "Offered by the status filter above the table", but the filter context passes Status.choices itself (applications/views.py:122).
  • core/mail.py:21-23 CONVENTIONAL_PORTS: "Used only to explain a failure", but _mismatch (core/mail.py:53-76) hard-codes 465 and (587, 25). The port facts now exist three times: here, in DEFAULT_MAIL_PORTS (core/mail.py:42) and in _mismatch.
  • documents/models.py:155-157 CV_THEMES: "A portfolio leads with the work, so it gets the theme written for that", but both kinds map to "plain" and nothing reads it.

3. An orphaned page

  • jobs/views.py:893-906 PostingCreateView and jobs/urls.py:94 (jobs:posting_create, /jobs/postings/new/). #25 noted that it "is linked from no template"; the Listings page has since gained its own Add a listing, listings:create (jobs/listing_urls.py:9, ListingCreateView, jobs/listing_views.py:201-227), and jobs:posting_create is still reversed nowhere: no template, Python module, script, wiki page or sibling repository names it. Only tests/test_width.py:63 and tests/e2e/test_accessibility.py:476 and :536 visit the address.

  • The two views have already drifted. ListingCreateView uses PostingIntakeForm, finds or makes the company by name through get_or_create_company, and creates through applications.services.create_listing. PostingCreateView uses JobPostingForm, a company chosen from a list, a plain model save, and a ?company= pre-fill of its own (jobs/views.py:898-906) that passes the raw value to filter(pk=...), so a non-numeric value raises instead of being ignored.

  • Why it matters:

    • A future widget or plugin that finds applications_needing_a_nudge by name shows a list that disagrees with the Gone quiet widget, the board and the notifier.
    • The theme context carries cv as well as sections (documents/rendering.py:254), so a plugin theme that walks cv.items and reaches for cv_item.highlight_lines prints a French CV's highlights in the master language.
    • A maintainer who trusts one of the three comments changes the wrong thing (extends STATUSES expecting the filter to follow, edits CONVENTIONAL_PORTS expecting the mail errors to follow, reads CV_THEMES to learn a portfolio's default) and nothing changes.
    • Two creation paths for one record is where rules diverge unnoticed. A later change to how listings are created (defaults, events, capture binding) will be made in the service and the listing view, and the orphaned route will keep creating listings the old way for anyone with a bookmark. It has no users to justify the cost, and it takes a slot in the width and accessibility sweeps.
    • The rest is code to read, type-check and maintain for nothing.
  • Fix:

    • Delete every definition in sections 1 and 2, and take may_translate out of the re-export in resume/translating.py. If a list of applications to chase is wanted later, build it on ApplicationQuerySet.quiet() or quiet.quiet_applications. Entry.highlight_lines, the name Entry's docstring gives to themes, becomes the only one there is.
    • Have _mismatch read its ports from DEFAULT_MAIL_PORTS rather than keeping a third copy.
    • Delete PostingCreateView and its route, or turn postings/new/ into a redirect to listings:create (which takes no ?company=, so the parameter is dropped). Take /jobs/postings/new/ out of tests/test_width.py:63 and tests/e2e/test_accessibility.py:476 and :536; the listing form is already in both (tests/test_width.py:68, tests/e2e/test_accessibility.py:449), so add /listings/new/ only to the list at :536 if that list should keep a listing form. templates/jobs/posting_form.html stays, since PostingUpdateView uses it (jobs/views.py:886).

Done when

  • A search for each name in sections 1 and 2 finds nothing under src/ or tests/ (for highlight_lines, nothing on CVItem), and the suite passes with no other change; tests/test_career_languages.py and tests/test_document_themes.py in particular still pass.
  • A test in tests/test_listings.py (or beside the existing listing tests) asserts that reverse("jobs:posting_create") raises NoReverseMatch, or that /jobs/postings/new/ redirects to listings:create.
  • tests/test_width.py and tests/e2e/test_accessibility.py no longer name /jobs/postings/new/.
Found on 2026-09-29 in a read-only review of postulo at 95348908d, searching every snapshot repository (postulo, the plugins, the extensions, postulo-mcp, postulo-templates and the wiki; source, tests, templates and static files) for each name. Checked again on 2026-10-01 against `main` at `0a5cad587`: still present. The code is now at `documents/kinds.py:136-138` (`authored_choices`), `resume/translatable.py:50-51` (`may_translate`), `applications/agenda.py:163-165` (`Event.local_end`), `documents/models.py:318-325` (`CVItem.highlight_lines`) and `documents/models.py:195-197` (`CV_THEMES`), `documents/rendering.py:100-112` (`Entry.highlight_lines`, read at `:282` and `:294`; the entry put into the CV's language at `:143-144`, `cv` in the theme context at `:228`), `core/mail.py:24-26` (`CONVENTIONAL_PORTS`), `core/mail.py:32` (`DEFAULT_MAIL_PORTS`) and `core/mail.py:43-66` (`_mismatch`), `tests/test_width.py:64` and `:69`, and `tests/e2e/test_accessibility.py:479` and `:539`; the other locations have not moved. Each definition below is referenced nowhere but its own line (`may_translate` also in the list that re-exports it). Most are harmless leftovers. Five are worse than dead: three carry comments describing a job they no longer do, one is a second rule for an unanswered application that disagrees with the one every page uses, and one shares its name with the property CV themes are told to read but answers in the wrong language. A whole view also survives for a page nothing links to. ## 1. Unreferenced definitions - `api/views.py:69` `token_list_url` - `applications/analytics.py:622-629` `has_enough_history` - `applications/quiet.py:150-155` `quiet_by` - `applications/services.py:546` `LATER_CHOICES` - `core/backup.py:574-578` `as_dict` - `core/messages_tool.py:192-197` `owner_of` - `documents/kinds.py:117-119` `authored_choices` (`Kind.authored` itself stays: the registry entries set it) - `resume/translatable.py:50-51` `may_translate`: #248 moved it out of `resume/translating.py`, which now names it in its re-export list (`resume/translating.py:54`). Nothing calls it under either module. - `core/models.py:475-481` `PhoneNumber.forget_verification`: `PhoneNumber.save()` (`core/models.py:369`) already clears `verified_at` and `is_recovery` when the number changes, so this has no caller and no job. - `applications/agenda.py:147-149` `Event.local_end`, `applications/endings.py:58-60` `status_label`, `applications/models.py:895-897` `Suggestion.is_matched`, `applications/reports.py:366-367` `Tally.share_of`: properties and methods whose names occur once in the whole corpus, templates included. (`Event.is_span`, beside `local_end`, is read by one test only, `tests/test_calendar.py:90`.) ## 2. Unreferenced, and misleading - `applications/analytics.py:611-619` `applications_needing_a_nudge`: "Applications that were sent, never answered, and are getting old", decided by a fixed 14 days and `APPLIED` or `ACKNOWLEDGED` only. `applications/quiet.py:11-12` says "Everything that shows or counts quiet applications uses the one predicate here, so the dashboard, the board, the table, the figures and the notifier all agree"; this is a second predicate beside it, which ignores the person's own threshold (`threshold_for`), the reminders already set and the interviews not yet held. - `documents/models.py:278-285` `CVItem.highlight_lines`: the shipped themes read `entry.highlight_lines` on `rendering.Entry` (`documents/rendering.py:126-138`; `templates/documents/themes/base_cv.html:121`, `base_portfolio.html:74`; `documents/rendering.py:308` and `:320`), and the `highlight_lines` in `templates/resume/overview.html` and `preview.html` is the career item's own (`resume/models.py:60`). Nothing reads the one on `CVItem`. The two bodies are the same code, but `Entry.item` is the entry already put into the CV's language (`documents/rendering.py:169-170`, #131), while `CVItem.item` is the master copy. - `applications/tables.py:112-113` `STATUSES`: "Offered by the status filter above the table", but the filter context passes `Status.choices` itself (`applications/views.py:122`). - `core/mail.py:21-23` `CONVENTIONAL_PORTS`: "Used only to explain a failure", but `_mismatch` (`core/mail.py:53-76`) hard-codes 465 and `(587, 25)`. The port facts now exist three times: here, in `DEFAULT_MAIL_PORTS` (`core/mail.py:42`) and in `_mismatch`. - `documents/models.py:155-157` `CV_THEMES`: "A portfolio leads with the work, so it gets the theme written for that", but both kinds map to `"plain"` and nothing reads it. ## 3. An orphaned page - `jobs/views.py:893-906` `PostingCreateView` and `jobs/urls.py:94` (`jobs:posting_create`, `/jobs/postings/new/`). #25 noted that it "is linked from no template"; the Listings page has since gained its own *Add a listing*, `listings:create` (`jobs/listing_urls.py:9`, `ListingCreateView`, `jobs/listing_views.py:201-227`), and `jobs:posting_create` is still reversed nowhere: no template, Python module, script, wiki page or sibling repository names it. Only `tests/test_width.py:63` and `tests/e2e/test_accessibility.py:476` and `:536` visit the address. - The two views have already drifted. `ListingCreateView` uses `PostingIntakeForm`, finds or makes the company by name through `get_or_create_company`, and creates through `applications.services.create_listing`. `PostingCreateView` uses `JobPostingForm`, a company chosen from a list, a plain model save, and a `?company=` pre-fill of its own (`jobs/views.py:898-906`) that passes the raw value to `filter(pk=...)`, so a non-numeric value raises instead of being ignored. - **Why it matters:** - A future widget or plugin that finds `applications_needing_a_nudge` by name shows a list that disagrees with the *Gone quiet* widget, the board and the notifier. - The theme context carries `cv` as well as `sections` (`documents/rendering.py:254`), so a plugin theme that walks `cv.items` and reaches for `cv_item.highlight_lines` prints a French CV's highlights in the master language. - A maintainer who trusts one of the three comments changes the wrong thing (extends `STATUSES` expecting the filter to follow, edits `CONVENTIONAL_PORTS` expecting the mail errors to follow, reads `CV_THEMES` to learn a portfolio's default) and nothing changes. - Two creation paths for one record is where rules diverge unnoticed. A later change to how listings are created (defaults, events, capture binding) will be made in the service and the listing view, and the orphaned route will keep creating listings the old way for anyone with a bookmark. It has no users to justify the cost, and it takes a slot in the width and accessibility sweeps. - The rest is code to read, type-check and maintain for nothing. - **Fix:** - Delete every definition in sections 1 and 2, and take `may_translate` out of the re-export in `resume/translating.py`. If a list of applications to chase is wanted later, build it on `ApplicationQuerySet.quiet()` or `quiet.quiet_applications`. `Entry.highlight_lines`, the name `Entry`'s docstring gives to themes, becomes the only one there is. - Have `_mismatch` read its ports from `DEFAULT_MAIL_PORTS` rather than keeping a third copy. - Delete `PostingCreateView` and its route, or turn `postings/new/` into a redirect to `listings:create` (which takes no `?company=`, so the parameter is dropped). Take `/jobs/postings/new/` out of `tests/test_width.py:63` and `tests/e2e/test_accessibility.py:476` and `:536`; the listing form is already in both (`tests/test_width.py:68`, `tests/e2e/test_accessibility.py:449`), so add `/listings/new/` only to the list at `:536` if that list should keep a listing form. `templates/jobs/posting_form.html` stays, since `PostingUpdateView` uses it (`jobs/views.py:886`). ## Done when - A search for each name in sections 1 and 2 finds nothing under `src/` or `tests/` (for `highlight_lines`, nothing on `CVItem`), and the suite passes with no other change; `tests/test_career_languages.py` and `tests/test_document_themes.py` in particular still pass. - A test in `tests/test_listings.py` (or beside the existing listing tests) asserts that `reverse("jobs:posting_create")` raises `NoReverseMatch`, or that `/jobs/postings/new/` redirects to `listings:create`. - `tests/test_width.py` and `tests/e2e/test_accessibility.py` no longer name `/jobs/postings/new/`.
tiagoagueda added this to the 0.6.0 milestone 2026-10-01 10:46:25 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Postulo/postulo#401
No description provided.