Skip to content

002_0003 - AvioidInheritanceFromAdministrationAccount

Inherit from Administration.Account

Inherit from system.user instead or adapt Administration.Account so it fits your needs.

Metadata

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

Description

There is no need to inherit from administration.account. Administration.account may simply be extended, this is not a system module. Avoid unnecessary inheritance as this has a negative effect on performance.

Remediation

Inherit from system.user instead or adapt Administration.Account so it fits your needs.

Test cases

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


# Test data
entity_negative = {
    "Name": "Entity1",
    "MaybeGeneralization": {
        "Type": "DomainModels$Generalization",
        "Generalization": "System.FileDocument"
    }
}

entity_positive = {
    "Name": "Entity2",
    "MaybeGeneralization": {
        "Type": "DomainModels$Generalization",
        "Generalization": "Administration.Account"
    }
}


entities_mixed = [entity_negative, entity_positive]


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

test_entity_negative if {
    allow with input as {"Entities": [entity_negative]}
}

test_entity_positive if {
    not allow with input as {"Entities": [entity_positive]}
}

test_entities_mixed if {
    not allow with input as {"Entities": entities_mixed}
}