Skip to content

feat(lint): configurable QUAL004 entry-point and CUSTOM002 prefixes (mendixlabs/mxcli#1509) - #1531

Merged
ako merged 2 commits into
mainfrom
feature/1509-lint-configurable-prefixes
Oct 21, 2026
Merged

ako merged 2 commits into
mainfrom
feature/1509-lint-configurable-prefixes

Conversation

@ako

@ako ako commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Implements mendixlabs#1509 (#1391), approved by the maintainer. Rule options in lint-config.yaml fall back to today's lists. Calls from tests/*.test.mdl are not counted, by decision.

The problem

QUAL004 (orphaned_elements.star) and CUSTOM002 (example_microflow.star) hard-code their prefix lists. mxcli init rewrites the embedded .star files every time, so a project could not change them. And goValueToStarlark handled only scalars, so a YAML list under a rule's options reached the rule as None without any warning.

Change

  • Option values (mdl/linter/starlark.go)
    • goValueToStarlark now converts lists and string-keyed maps recursively, and returns an error for types it can't represent.
    • get_option records a warning and returns the default when a value can't be converted.
    • New get_list_option(key, default) reads a list of strings from a YAML list or from comma-separated text.
    • A malformed value (for example entry_point_prefixes: 42) warns, naming rules.<ID>.options.<key>, and the rule runs on its default.
  • The two rules
    • QUAL004 reads entry_point_prefixes, and CUSTOM002 reads valid_prefixes.
    • A configured list replaces the built-in list; if unset, the built-in list stays.
    • QUAL004's suggestion names the prefixes in force and points to the option.
  • Docs: a new section in docs-site/src/tools/starlark-rules.md, option warnings in mxcli-lint.md, the write-lint-rules skill, an example in the lint config init seeds, and a CHANGELOG "Added" entry.

Tests

  • starlark_options_test.go:
    • YAML list (flow and block style through the real LoadConfig);
    • nested values, comma string, unset default;
    • malformed values warn and fall back;
    • no warning leaks into the next run.
  • starlark_prefix_options_test.go: QUAL004 and CUSTOM002 with an unset control, a list, a string, a malformed value, and the message naming the configured prefixes.
  • Revert check:
    • Without list conversion, both list tests fail.
    • With the .star files restored from main, all option cases fail.
  • End to end: on a fixture copy with TEST_ and GET_ microflows, the configuration takes effect, and a value of 42 warns.

make build, make test and make lint pass.

For review

  • Replace, not extend: a configured list replaces the defaults rather than adding to them.
  • Where the warning shows: a config warning is reported as a RuleFailure, so it appears under "Rules That Could Not Run" although the rule ran on its default.

Generated by Claude Code

…ig.yaml (mendixlabs#1509)

QUAL004 (orphaned elements) hard-coded its entry-point prefixes and
CUSTOM002 (microflow prefix convention) its valid prefixes, and `mxcli init`
rewrites the shipped rule files, so a project with its own naming
convention could not keep an edit: the reporting project got 84 QUAL004 and
121 CUSTOM002 findings for TEST_/GET_/PRS_ microflows.

Both rules now read an option - rules.QUAL004.options.entry_point_prefixes
and rules.CUSTOM002.options.valid_prefixes - as a YAML list or
comma-separated text. A configured list replaces the built-in one; unset,
the built-in list applies as before.

Underneath, goValueToStarlark converted scalars only, so any YAML list or
map under a rule's options reached the rule as None, indistinguishable from
"unset". Lists and string-keyed maps now convert recursively. A new
get_list_option(key, default) builtin reads a list of strings in either
spelling. An option value a rule cannot use is recorded and reported after
the run as a warning naming rules.<ID>.options.<key> (RuleFailure, so it
stays out of the score) while the rule runs on its default.

QUAL004 still counts only callers in the model; a microflow called only
from tests/*.test.mdl is reported, and its prefix belongs in the option
(maintainer decision).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W3x8Fyvir8kLyPgJs1BDmF
Resolve the CHANGELOG conflict with #1532 (CONV020) by keeping both
"Added" entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W3x8Fyvir8kLyPgJs1BDmF
@ako
ako merged commit 2d25ffe into main Oct 21, 2026
33 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.

2 participants