Miscellaneous-NoReferenceToPrivateDataMember¶
Do not return non-const references to private data members
Required inputs: IR
Example
class C
{
private:
std::string m_member;
public:
const std::string& member()
{
return m_member;
}
void member(const std::string& new_value)
{
assert(new_value.size() > 0);
m_member = new_value;
}
};
See Also
Rule Miscellaneous-NoPublicDataMembersPossible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
returning_nonconst_member_reference |
Return of reference to private non-const data member. |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
include_copies_of_pointer_fields¶
include_copies_of_pointer_fields : bool = False
inspect_only_const_methods¶
inspect_only_const_methods : bool = False
only_report_references¶
only_report_references : bool = False
smart_pointer_names¶
smart_pointer_names : set[bauhaus.analysis.config.QualifiedName] = {'std::shared_ptr', 'std::unique_ptr', 'std::weak_ptr'}