Skip to content

fix(a11y): label filter controls and clear the page-file SonarCloud findings - #928

Merged
TheWitness merged 11 commits into
Cacti:developfrom
somethingwithproof:fix/sonar-issues
Dec 4, 2026
Merged

TheWitness merged 11 commits into
Cacti:developfrom
somethingwithproof:fix/sonar-issues

Conversation

@somethingwithproof

@somethingwithproof somethingwithproof commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Problem

SonarCloud reports unlabeled filter controls, layout tables read as data tables, a deprecated <center> element and a core stub with the wrong signature. Details in the linked issue.

Fix

  • Filter controls on the threshold, template, notification list and queue pages get a <label for>; the filter and template-add tables are marked role='presentation'.
  • The empty Thresholds row is centered with a class in place of <center>.
  • The get_daysfromtime test stub takes the same parameters as core.
  • tests/bin/patch-coverage.php maps a coverage entry to the longest matching tracked file, so notify_queue.php is no longer counted as includes/notify_queue.php.

No behaviour change: markup attributes and test code only.

Duplicated filter rows

SonarCloud counted the new <label> lines as duplicated new code, because they sit inside filter rows that were already copied across thold.php, thold_graph.php, notify_lists.php and notify_queue.php. The repeated cells (Search, Rows, Refresh, Site, Status) are now printed by five small helpers in includes/display.php. Ids, names, classes, option order, selected state, msgids and escaping are unchanged: tests/Unit/FilterFormGoldenTest.php records each list page's filter form in three request states (30 cases) from the code before the change and requires byte-identical output after it. The fixtures use a .golden extension so they are compared as text, not analysed as web pages. locales/po/cacti.pot changes only in source locations and entry order; no msgid or msgstr changes.

Verification

  • Pest on PHP 8.3: 769 passed, 1 skipped.
  • New tests: FilterFormMarkupTest (every filter control has a label, layout tables are marked) and CoreStubSignatureTest.
  • Changed-line coverage 100%.
  • Not verified: the SonarCloud result itself, which only the PR analysis shows. No screen-reader test was run.

Out of scope

The $$a findings in includes/notify_queue.php (notification step of #906) and four false positives listed in the issue.

Fixes #927

patch-coverage.php matched a Clover path to the first changed file whose
name it ended with, so a change to the top-level notify_queue.php was
measured against the coverage of includes/notify_queue.php. Match each
Clover path to the longest tracked PHP file it ends with instead.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Tie each filter caption to its control with <label for> on the Thresholds,
Threshold Status, Threshold Templates, Notification Lists and Notification
Queue pages, and on the graph selector of the threshold editor. Mark the
filter tables as layout tables (role=presentation) so screen readers do not
announce them as data tables without headers.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The Add Threshold Template rows that setup.php adds to the device and device
template edit pages wrap a caption and a dropdown in a table. Mark those
tables as layout tables (role=presentation) so screen readers do not announce
them as data tables without headers.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The empty-list row on the Thresholds page used the <center> element, which
HTML5 dropped. Use the theme's center class on the cell instead.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The unit bootstrap stubbed get_daysfromtime() with one parameter while the
core function takes five and notify_queue.php passes four. Declare the core
parameter list on the stub.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…ntrol

The lists() filter row was marked as layout but its Search and Lists
controls had no label. The markup test only looked for one label per id
in a file, so a repeated id hid the gap; it now counts them.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…h matching

The label check never matched text inputs because a word boundary cannot
follow a closing quote, so the search labels were untested. Also pin the
centred empty-list cell and exercise tests/bin/patch-coverage.php against
a throw-away repository with same-named top-level and nested files.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
…ates from a file

The recorded forms are compared byte for byte, not served, so they now use
a .golden extension; as .html they were analysed as web pages and counted
as duplicated code. The cut templates run from a temporary file instead of
eval.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@sonarqubecloud

sonarqubecloud Bot commented Dec 4, 2026

Copy link
Copy Markdown

@TheWitness TheWitness left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. No element ids or request variable names changed, so applyFilter()/clearFilter() still work. Every new label points to an id in its own form, and the shared helpers print the same ids, with each page's escaping kept. The get_daysfromtime stub now matches core 1.2.32, and the patch-coverage change only makes path matching stricter. The suite passes merged with current develop (796 tests).

@TheWitness
TheWitness merged commit 5098d2e into Cacti:develop Dec 4, 2026
8 checks passed
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 this pull request may close these issues.

Resolve the open SonarCloud findings on the page files

2 participants