Skip to content

Settings form: round-trip coverage, stop calling GitHub on every save, drop dead settings - #160

Merged
nuest merged 4 commits into
codecheckers:mainfrom
nuest:settings-form-cleanup
Aug 13, 2026
Merged

Settings form: round-trip coverage, stop calling GitHub on every save, drop dead settings#160
nuest merged 4 commits into
codecheckers:mainfrom
nuest:settings-form-cleanup

Conversation

@nuest

@nuest nuest commented Aug 13, 2026

Copy link
Copy Markdown
Member

Three changes to the plugin settings form, each found by the one before it.

Round-trip coverage (e2e)

A setting is wired up in three separate places — initData(), readInputData() and execute() — and omitting it from any one loses the value in silence: getData() returns null, updateSetting() writes the null, and the field is empty next time the form opens. Nothing fails and nothing logs.

The new spec derives its field list from what the form renders rather than hard-coding one, so a setting added without being wired up fails without anyone remembering to extend the test. It writes distinctive values before saving — saving unchanged proves little, since seven settings are empty in the test dataset and "empty survived" holds either way. Verified by removing badgeHeight from readUserVars: it fails naming the field.

Saving no longer calls GitHub every time

SettingsForm::execute() called validateRegisterFileExists() unconditionally, so every save — a badge height, a dashboard toggle — blocked on an unauthenticated GitHub request for register.csv, against a 60/hour per-IP limit. It now runs only when the organisation or repository actually changed. Verified by instrumenting the method: four saves with the register untouched make no request; changing the organisation still makes one.

Two dead settings removed

codecheckApiEndpoint and codecheckApiKey were handled in all three lifecycle methods and written on every save, but settings.tpl renders no field for either and nothing reads them. Added in db25e55 as scaffolding, never wired up.

Neither is repurposed for the one hardcoded CODECHECK endpoint (the venues list) — that deserves a name saying what it is, and there is no authenticated CODECHECK API for a key to belong to.

API routing coverage

ApiEndpoint and CodecheckRoleArray had no coverage. Tests pin down which route and method map to which handler and role set, and the recursive role flattening including the admin ⊂ edit ⊂ read nesting the handler builds.

ApiEndpoint is also made total: a method with no entries raised Undefined array key, and reading an unresolved endpoint threw Typed property … must not be accessed before initialization. That is a class-level fix, not a reachable one — OJS's own router answers routes and methods this table does not cover before the handler runs, verified against a running instance.


Stacked on #159. Suite: 131 PHPUnit (none skipped), 48 component, 13 e2e.

@nuest
nuest marked this pull request as ready for review August 13, 2026 09:21
@nuest
nuest merged commit d5c8aa0 into codecheckers:main Aug 13, 2026
3 checks passed
@nuest
nuest deleted the settings-form-cleanup branch August 26, 2026 19:19
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.

1 participant