Skip to content

002_0001 - NumberOfEntities

No more than 15 persistent entities within one domain model

Split domain model into multiple modules.

Metadata

authors:
- Xiwen Cheng <x@cinaq.com>
category: Maintainability
input: '*/DomainModels$DomainModel.yaml'
rulename: NumberOfEntities
rulenumber: '002_0001'
scope: package
severity: MEDIUM

Description

The bigger the domain models, the harder they will be to maintain. It adds complexity to your security model as well. The smaller the modules, the easier to reuse.

Remediation

Split domain model into multiple modules.

Test cases

package app.mendix.domain_model.number_of_entities
import rego.v1


# Test data
entity_attr_0 = {
    "Name": "Entity1",
}


twenty := numbers.range(1, 20)
entities_20 = [ 
    { "Name": entity_attr_0.Name }  | n := twenty[_]
]


# Test cases
test_no_entities if {
    allow with input as {"Entities": null}
}

test_1_entity if {
    allow with input as {"Entities": [entity_attr_0]}
}

test_2_entities if {
    allow with input as {"Entities": [entity_attr_0, entity_attr_0]}
}

test_20_entities if {
    not allow with input as {"Entities": entities_20}
}