checkStructFieldNames

Checks whether any structure field names contain the name of the struct. For example: sensor.SensorWeight. This is a case insensitive check. This check checks fields that are defined in the following manner: test.TestLength = 10;. Additionally, field names defined using the struct() function liketest = struct('TestLength', 10);are also checked.

Limitations

Dynamically assigned field names are not checked by this check because the field names cannot be collected. Therefore, structures defined as follows will not result in violating this check:

fieldNames     = {'my_field', 'my_2nd_field'};
myStruct       = struct(fieldNames{1}, [], fieldNames{2}, []);

str            = 'TEST';
myStruct.(str) = [];

An additional limitation related to this check is given in section Considerations and Known Limitations.

Exemption tag: %@ok<SFNAM>