Skip to content

fix(lint): ARCH002 and ARCH003 compare entity_type to a value the linter never returns - #1165

Open
tgolembiewski wants to merge 3 commits into
mendixlabs:mainfrom
tgolembiewski:fix/lint-rules-entity-type-spelling
Open

tgolembiewski wants to merge 3 commits into
mendixlabs:mainfrom
tgolembiewski:fix/lint-rules-entity-type-spelling

Conversation

@tgolembiewski

Copy link
Copy Markdown
Contributor

Closes #1164

What

ARCH002 and ARCH003 skip every entity, so neither has ever reported anything on any project:

if entity.entity_type != "PERSISTENT":
    continue

The catalog stores PERSISTENT; LintContext.Entities normalizes the kind to Persistent before a Starlark rule reads it. The comparison is therefore true for every entity and each rule's body never runs — with no error, no output, and the rule still listed by --list-rules, which is indistinguishable from a clean project. The other ten bundled rules that filter on the kind already use "Persistent".

The write-lint-rules skill documented a third spelling, "persistent", in both its field table and its worked example; a rule written from that page has the same silent failure.

Measurements

before after
Blank project, one persistent entity with no unique attribute, --rules ARCH003 No issues found. 1 warning naming the entity
Generated app, five persistent entities, --rules ARCH003 0 findings 5 findings

Commits

  1. fix(lint) — the two rules, plus a test that loads the shipped rule files themselves against a one-entity fixture.
  2. docs(skill) — the field table and the example in write-lint-rules now say what the API returns.
  3. docs — CHANGELOG entry under [Unreleased] and one finding record.

Tests

TestShippedEntityRulesSeeAPersistentEntity loads .claude/lint-rules/entity_business_key.star and .claude/lint-rules/data_change_microflows.star — the files that ship — and asserts each reports the one persistent entity in the fixture. Reverting either fix in turn takes that rule's subtest to got 0 violations, want 1, so the test detects the defect it is here for rather than the code around it.

Validation

Mendix 11.12.1, MPR v2, macOS. The whole of push-test.yml run locally and green: make build, make test, check-tunnel-deps, make check-mdl, make check-skill-pack-js, make check-findings, make check-wiki-pages, check-skill-mdl.sh over .claude/skills/mendix and docs-site/src, make test-integration against mx 11.12.1, make lint-go, govulncheck (0 vulnerabilities in called code).

No MDL syntax changes and no behaviour change outside the two rules.

ARCH002 and ARCH003 guard with `entity.entity_type != "PERSISTENT"`.
The catalog stores PERSISTENT, but LintContext.Entities normalizes the
kind to Persistent (the CASE in its Entities query) before a Starlark
rule reads it, so the guard held for every entity and neither rule's
body ever ran. Nothing said so: no error, no output, and both still
appeared under `--list-rules`, which reads as a project with nothing to
report.

Measured on a generated app with five persistent entities, none of them
carrying a unique attribute: ARCH003 reported 0 findings before the
change and 5 after.

The test loads the two shipped rule files themselves against a
one-entity fixture, so a rule that goes back to the stored spelling
fails here rather than going quiet again. Reverting either fix in turn
takes that rule's subtest to "got 0 violations, want 1".
The field table and the worked example in write-lint-rules both used
"persistent", a third spelling that matches nothing. A rule written from
either reads as working and reports on no project at all, which is how
the two rules fixed in the previous commit were written.
@github-actions

Copy link
Copy Markdown

AI Code Review

What Looks Good

  • The PR correctly fixes the core issue: ARCH002 and ARCH003 were comparing entity.entity_type to "PERSISTENT" when the API normalizes it to "Persistent"
  • The fix is minimal and targeted - just changing the string comparison in two places
  • Comprehensive test added that loads the actual shipped rule files and verifies they detect the expected entity
  • Documentation updated to reflect the correct API return values ("Persistent", "NonPersistent", "View")
  • CHANGELOG entry clearly explains the problem and fix with measurements showing effectiveness
  • Finding properly recorded in .claude/skills/fix-issue/findings/cmd-mxcli.jsonl
  • All validation passes including local test runs and Mendix Studio Pro validation
  • Each commit has a single, clear purpose (fix, docs update, changelog/finding)

Recommendation

Approve the pull request. The fix is correct, well-tested, properly documented, and follows all project guidelines. The PR resolves the silent failure of two bundled lint rules without introducing any side effects.


Automated review via OpenRouter (Nemotron Super 120B) — workflow source

This branch has not been deployed

No deployments
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.

lint: ARCH002 and ARCH003 never report anything (entity_type compared to a spelling the linter does not return)

1 participant