Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h =================================================================== --- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h +++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h @@ -52,12 +52,14 @@ NamingStyle() = default; NamingStyle(llvm::Optional Case, const std::string &Prefix, - const std::string &Suffix) - : Case(Case), Prefix(Prefix), Suffix(Suffix) {} + const std::string &Suffix, size_t ShortSizeThreshold) + : Case(Case), Prefix(Prefix), Suffix(Suffix), + ShortSizeThreshold(ShortSizeThreshold) {} llvm::Optional Case; std::string Prefix; std::string Suffix; + size_t ShortSizeThreshold; }; struct FileStyle { Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp +++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp @@ -130,6 +130,9 @@ for (unsigned I = 0; I < SK_Count; ++I) { StyleString = StyleNames[I]; size_t StyleSize = StyleString.size(); + StyleString.append("ShortSizeThreshold"); + size_t ShortSizeThreshold = Options.get((StyleString).str(), 0U); + StyleString.resize(StyleSize); StyleString.append("Prefix"); std::string Prefix(Options.get(StyleString, "")); // Fast replacement of [Pre]fix -> [Suf]fix. @@ -141,9 +144,10 @@ auto CaseOptional = Options.getOptional(StyleString); - if (CaseOptional || !Prefix.empty() || !Postfix.empty()) + if (CaseOptional || !Prefix.empty() || !Postfix.empty() || + ShortSizeThreshold > 0) Styles[I].emplace(std::move(CaseOptional), std::move(Prefix), - std::move(Postfix)); + std::move(Postfix), ShortSizeThreshold); } bool IgnoreMainLike = Options.get("IgnoreMainLikeFunctions", false); return {std::move(Styles), IgnoreMainLike}; @@ -175,6 +179,9 @@ continue; StyleString = StyleNames[I]; size_t StyleSize = StyleString.size(); + StyleString.append("ShortSizeThreshold"); + Options.store(Opts, StyleString, Styles[I]->ShortSizeThreshold); + StyleString.resize(StyleSize); StyleString.append("Prefix"); Options.store(Opts, StyleString, Styles[I]->Prefix); // Fast replacement of [Pre]fix -> [Suf]fix. @@ -681,6 +688,9 @@ return None; const IdentifierNamingCheck::NamingStyle &Style = *NamingStyles[SK]; + if (Name.size() <= Style.ShortSizeThreshold) + return None; + if (matchesStyle(Name, Style)) return None; Index: clang-tools-extra/docs/ReleaseNotes.rst =================================================================== --- clang-tools-extra/docs/ReleaseNotes.rst +++ clang-tools-extra/docs/ReleaseNotes.rst @@ -149,6 +149,10 @@ Added support for specifying the style of scoped ``enum`` constants. If unspecified, will fall back to the style for regular ``enum`` constants. + Added an option `ShortSizeThreshold` per identifier type to suppress + identifier naming checks for names having a length less than or equal to this + setting. + - Removed `google-runtime-references` check because the rule it checks does not exist in the Google Style Guide anymore. Index: clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst =================================================================== --- clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst +++ clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst @@ -20,7 +20,8 @@ - ``aNy_CasE``. It also supports a fixed prefix and suffix that will be prepended or appended -to the identifiers, regardless of the casing. +to the identifiers, regardless of the casing. A threshold for the length of +the identifer may be specified to suppress the checks for short names. Many configuration options are available, in order to be able to create different rules for different kinds of identifiers. In general, the rules are @@ -35,60 +36,60 @@ The following options are describe below: - - :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix` + - :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`, :option:`AbstractClassShortSizeThreshold` - :option:`AggressiveDependentMemberLookup` - - :option:`ClassCase`, :option:`ClassPrefix`, :option:`ClassSuffix` - - :option:`ClassConstantCase`, :option:`ClassConstantPrefix`, :option:`ClassConstantSuffix` - - :option:`ClassMemberCase`, :option:`ClassMemberPrefix`, :option:`ClassMemberSuffix` - - :option:`ClassMethodCase`, :option:`ClassMethodPrefix`, :option:`ClassMethodSuffix` - - :option:`ConstantCase`, :option:`ConstantPrefix`, :option:`ConstantSuffix` - - :option:`ConstantMemberCase`, :option:`ConstantMemberPrefix`, :option:`ConstantMemberSuffix` - - :option:`ConstantParameterCase`, :option:`ConstantParameterPrefix`, :option:`ConstantParameterSuffix` - - :option:`ConstantPointerParameterCase`, :option:`ConstantPointerParameterPrefix`, :option:`ConstantPointerParameterSuffix` - - :option:`ConstexprFunctionCase`, :option:`ConstexprFunctionPrefix`, :option:`ConstexprFunctionSuffix` - - :option:`ConstexprMethodCase`, :option:`ConstexprMethodPrefix`, :option:`ConstexprMethodSuffix` - - :option:`ConstexprVariableCase`, :option:`ConstexprVariablePrefix`, :option:`ConstexprVariableSuffix` - - :option:`EnumCase`, :option:`EnumPrefix`, :option:`EnumSuffix` - - :option:`EnumConstantCase`, :option:`EnumConstantPrefix`, :option:`EnumConstantSuffix` - - :option:`FunctionCase`, :option:`FunctionPrefix`, :option:`FunctionSuffix` + - :option:`ClassCase`, :option:`ClassPrefix`, :option:`ClassSuffix`, :option:`ClassShortSizeThreshold` + - :option:`ClassConstantCase`, :option:`ClassConstantPrefix`, :option:`ClassConstantSuffix`, :option:`ClassConstantShortSizeThreshold` + - :option:`ClassMemberCase`, :option:`ClassMemberPrefix`, :option:`ClassMemberSuffix`, :option:`ClassMemberShortSizeThreshold` + - :option:`ClassMethodCase`, :option:`ClassMethodPrefix`, :option:`ClassMethodSuffix`, :option:`ClassMethodShortSizeThreshold` + - :option:`ConstantCase`, :option:`ConstantPrefix`, :option:`ConstantSuffix`, :option:`ConstantShortSizeThreshold` + - :option:`ConstantMemberCase`, :option:`ConstantMemberPrefix`, :option:`ConstantMemberSuffix`, :option:`ConstantMemberShortSizeThreshold` + - :option:`ConstantParameterCase`, :option:`ConstantParameterPrefix`, :option:`ConstantParameterSuffix`, :option:`ConstantParameterShortSizeThreshold` + - :option:`ConstantPointerParameterCase`, :option:`ConstantPointerParameterPrefix`, :option:`ConstantPointerParameterSuffix`, :option:`ConstantPointerParameterShortSizeThreshold` + - :option:`ConstexprFunctionCase`, :option:`ConstexprFunctionPrefix`, :option:`ConstexprFunctionSuffix`, :option:`ConstexprFunctionShortSizeThreshold` + - :option:`ConstexprMethodCase`, :option:`ConstexprMethodPrefix`, :option:`ConstexprMethodSuffix`, :option:`ConstexprMethodShortSizeThreshold` + - :option:`ConstexprVariableCase`, :option:`ConstexprVariablePrefix`, :option:`ConstexprVariableSuffix`, :option:`ConstexprVariableShortSizeThreshold` + - :option:`EnumCase`, :option:`EnumPrefix`, :option:`EnumSuffix`, :option:`EnumShortSizeThreshold` + - :option:`EnumConstantCase`, :option:`EnumConstantPrefix`, :option:`EnumConstantSuffix`, :option:`EnumConstantShortSizeThreshold` + - :option:`FunctionCase`, :option:`FunctionPrefix`, :option:`FunctionSuffix`, :option:`FunctionShortSizeThreshold` - :option:`GetConfigPerFile` - - :option:`GlobalConstantCase`, :option:`GlobalConstantPrefix`, :option:`GlobalConstantSuffix` - - :option:`GlobalConstantPointerCase`, :option:`GlobalConstantPointerPrefix`, :option:`GlobalConstantPointerSuffix` - - :option:`GlobalFunctionCase`, :option:`GlobalFunctionPrefix`, :option:`GlobalFunctionSuffix` - - :option:`GlobalPointerCase`, :option:`GlobalPointerPrefix`, :option:`GlobalPointerSuffix` - - :option:`GlobalVariableCase`, :option:`GlobalVariablePrefix`, :option:`GlobalVariableSuffix` + - :option:`GlobalConstantCase`, :option:`GlobalConstantPrefix`, :option:`GlobalConstantSuffix`, :option:`GlobalConstantShortSizeThreshold` + - :option:`GlobalConstantPointerCase`, :option:`GlobalConstantPointerPrefix`, :option:`GlobalConstantPointerSuffix`, :option:`GlobalConstantPointerShortSizeThreshold` + - :option:`GlobalFunctionCase`, :option:`GlobalFunctionPrefix`, :option:`GlobalFunctionSuffix`, :option:`GlobalFunctionShortSizeThreshold` + - :option:`GlobalPointerCase`, :option:`GlobalPointerPrefix`, :option:`GlobalPointerSuffix`, :option:`GlobalPointerShortSizeThreshold` + - :option:`GlobalVariableCase`, :option:`GlobalVariablePrefix`, :option:`GlobalVariableSuffix`, :option:`GlobalVariableShortSizeThreshold` - :option:`IgnoreMainLikeFunctions` - - :option:`InlineNamespaceCase`, :option:`InlineNamespacePrefix`, :option:`InlineNamespaceSuffix` - - :option:`LocalConstantCase`, :option:`LocalConstantPrefix`, :option:`LocalConstantSuffix` - - :option:`LocalConstantPointerCase`, :option:`LocalConstantPointerPrefix`, :option:`LocalConstantPointerSuffix` - - :option:`LocalPointerCase`, :option:`LocalPointerPrefix`, :option:`LocalPointerSuffix` - - :option:`LocalVariableCase`, :option:`LocalVariablePrefix`, :option:`LocalVariableSuffix` - - :option:`MacroDefinitionCase`, :option:`MacroDefinitionPrefix`, :option:`MacroDefinitionSuffix` - - :option:`MemberCase`, :option:`MemberPrefix`, :option:`MemberSuffix` - - :option:`MethodCase`, :option:`MethodPrefix`, :option:`MethodSuffix` - - :option:`NamespaceCase`, :option:`NamespacePrefix`, :option:`NamespaceSuffix` - - :option:`ParameterCase`, :option:`ParameterPrefix`, :option:`ParameterSuffix` - - :option:`ParameterPackCase`, :option:`ParameterPackPrefix`, :option:`ParameterPackSuffix` - - :option:`PointerParameterCase`, :option:`PointerParameterPrefix`, :option:`PointerParameterSuffix` - - :option:`PrivateMemberCase`, :option:`PrivateMemberPrefix`, :option:`PrivateMemberSuffix` - - :option:`PrivateMethodCase`, :option:`PrivateMethodPrefix`, :option:`PrivateMethodSuffix` - - :option:`ProtectedMemberCase`, :option:`ProtectedMemberPrefix`, :option:`ProtectedMemberSuffix` - - :option:`ProtectedMethodCase`, :option:`ProtectedMethodPrefix`, :option:`ProtectedMethodSuffix` - - :option:`PublicMemberCase`, :option:`PublicMemberPrefix`, :option:`PublicMemberSuffix` - - :option:`PublicMethodCase`, :option:`PublicMethodPrefix`, :option:`PublicMethodSuffix` - - :option:`ScopedEnumConstantCase`, :option:`ScopedEnumConstantPrefix`, :option:`ScopedEnumConstantSuffix` - - :option:`StaticConstantCase`, :option:`StaticConstantPrefix`, :option:`StaticConstantSuffix` - - :option:`StaticVariableCase`, :option:`StaticVariablePrefix`, :option:`StaticVariableSuffix` - - :option:`StructCase`, :option:`StructPrefix`, :option:`StructSuffix` - - :option:`TemplateParameterCase`, :option:`TemplateParameterPrefix`, :option:`TemplateParameterSuffix` - - :option:`TemplateTemplateParameterCase`, :option:`TemplateTemplateParameterPrefix`, :option:`TemplateTemplateParameterSuffix` - - :option:`TypeAliasCase`, :option:`TypeAliasPrefix`, :option:`TypeAliasSuffix` - - :option:`TypedefCase`, :option:`TypedefPrefix`, :option:`TypedefSuffix` - - :option:`TypeTemplateParameterCase`, :option:`TypeTemplateParameterPrefix`, :option:`TypeTemplateParameterSuffix` - - :option:`UnionCase`, :option:`UnionPrefix`, :option:`UnionSuffix` - - :option:`ValueTemplateParameterCase`, :option:`ValueTemplateParameterPrefix`, :option:`ValueTemplateParameterSuffix` - - :option:`VariableCase`, :option:`VariablePrefix`, :option:`VariableSuffix` - - :option:`VirtualMethodCase`, :option:`VirtualMethodPrefix`, :option:`VirtualMethodSuffix` + - :option:`InlineNamespaceCase`, :option:`InlineNamespacePrefix`, :option:`InlineNamespaceSuffix`, :option:`InlineNamespaceShortSizeThreshold` + - :option:`LocalConstantCase`, :option:`LocalConstantPrefix`, :option:`LocalConstantSuffix`, :option:`LocalConstantShortSizeThreshold` + - :option:`LocalConstantPointerCase`, :option:`LocalConstantPointerPrefix`, :option:`LocalConstantPointerSuffix`, :option:`LocalConstantPointerShortSizeThreshold` + - :option:`LocalPointerCase`, :option:`LocalPointerPrefix`, :option:`LocalPointerSuffix`, :option:`LocalPointerShortSizeThreshold` + - :option:`LocalVariableCase`, :option:`LocalVariablePrefix`, :option:`LocalVariableSuffix`, :option:`LocalVariableShortSizeThreshold` + - :option:`MacroDefinitionCase`, :option:`MacroDefinitionPrefix`, :option:`MacroDefinitionSuffix`, :option:`MacroDefinitionShortSizeThreshold` + - :option:`MemberCase`, :option:`MemberPrefix`, :option:`MemberSuffix`, :option:`MemberShortSizeThreshold` + - :option:`MethodCase`, :option:`MethodPrefix`, :option:`MethodSuffix`, :option:`MethodShortSizeThreshold` + - :option:`NamespaceCase`, :option:`NamespacePrefix`, :option:`NamespaceSuffix`, :option:`NamespaceShortSizeThreshold` + - :option:`ParameterCase`, :option:`ParameterPrefix`, :option:`ParameterSuffix`, :option:`ParameterShortSizeThreshold` + - :option:`ParameterPackCase`, :option:`ParameterPackPrefix`, :option:`ParameterPackSuffix`, :option:`ParameterPackShortSizeThreshold` + - :option:`PointerParameterCase`, :option:`PointerParameterPrefix`, :option:`PointerParameterSuffix`, :option:`PointerParameterShortSizeThreshold` + - :option:`PrivateMemberCase`, :option:`PrivateMemberPrefix`, :option:`PrivateMemberSuffix`, :option:`PrivateMemberShortSizeThreshold` + - :option:`PrivateMethodCase`, :option:`PrivateMethodPrefix`, :option:`PrivateMethodSuffix`, :option:`PrivateMethodShortSizeThreshold` + - :option:`ProtectedMemberCase`, :option:`ProtectedMemberPrefix`, :option:`ProtectedMemberSuffix`, :option:`ProtectedMemberShortSizeThreshold` + - :option:`ProtectedMethodCase`, :option:`ProtectedMethodPrefix`, :option:`ProtectedMethodSuffix`, :option:`ProtectedMethodShortSizeThreshold` + - :option:`PublicMemberCase`, :option:`PublicMemberPrefix`, :option:`PublicMemberSuffix`, :option:`PublicMemberShortSizeThreshold` + - :option:`PublicMethodCase`, :option:`PublicMethodPrefix`, :option:`PublicMethodSuffix`, :option:`PublicMethodShortSizeThreshold` + - :option:`ScopedEnumConstantCase`, :option:`ScopedEnumConstantPrefix`, :option:`ScopedEnumConstantSuffix`, :option:`ScopedEnumConstantShortSizeThreshold` + - :option:`StaticConstantCase`, :option:`StaticConstantPrefix`, :option:`StaticConstantSuffix`, :option:`StaticConstantShortSizeThreshold` + - :option:`StaticVariableCase`, :option:`StaticVariablePrefix`, :option:`StaticVariableSuffix`, :option:`StaticVariableShortSizeThreshold` + - :option:`StructCase`, :option:`StructPrefix`, :option:`StructSuffix`, :option:`StructShortSizeThreshold` + - :option:`TemplateParameterCase`, :option:`TemplateParameterPrefix`, :option:`TemplateParameterSuffix`, :option:`TemplateParameterShortSizeThreshold` + - :option:`TemplateTemplateParameterCase`, :option:`TemplateTemplateParameterPrefix`, :option:`TemplateTemplateParameterSuffix`, :option:`TemplateTemplateParameterShortSizeThreshold` + - :option:`TypeAliasCase`, :option:`TypeAliasPrefix`, :option:`TypeAliasSuffix`, :option:`TypeAliasShortSizeThreshold` + - :option:`TypedefCase`, :option:`TypedefPrefix`, :option:`TypedefSuffix`, :option:`TypedefShortSizeThreshold` + - :option:`TypeTemplateParameterCase`, :option:`TypeTemplateParameterPrefix`, :option:`TypeTemplateParameterSuffix`, :option:`TypeTemplateParameterShortSizeThreshold` + - :option:`UnionCase`, :option:`UnionPrefix`, :option:`UnionSuffix`, :option:`UnionShortSizeThreshold` + - :option:`ValueTemplateParameterCase`, :option:`ValueTemplateParameterPrefix`, :option:`ValueTemplateParameterSuffix`, :option:`ValueTemplateParameterShortSizeThreshold` + - :option:`VariableCase`, :option:`VariablePrefix`, :option:`VariableSuffix`, :option:`VariableShortSizeThreshold` + - :option:`VirtualMethodCase`, :option:`VirtualMethodPrefix`, :option:`VirtualMethodSuffix`, :option:`VirtualMethodShortSizeThreshold` .. option:: AbstractClassCase @@ -100,6 +101,11 @@ When defined, the check will ensure abstract class names will add the prefixed with the given value (regardless of casing). +.. option:: AbstractClassShortSizeThreshold + + Identifier naming checks won't be enforced for abstract class names having + a length less than or equal to this setting. + .. option:: AbstractClassSuffix When defined, the check will ensure abstract class names will add the @@ -199,6 +205,11 @@ When defined, the check will ensure class names will add the prefixed with the given value (regardless of casing). +.. option:: ClassShortSizeThreshold + + Identifier naming checks won't be enforced for class names having a length + less than or equal to this setting. + .. option:: ClassSuffix When defined, the check will ensure class names will add the @@ -242,6 +253,11 @@ When defined, the check will ensure class constant names will add the prefixed with the given value (regardless of casing). +.. option:: ClassConstantShortSizeThreshold + + Identifier naming checks won't be enforced for class constant names having + a length less than or equal to this setting. + .. option:: ClassConstantSuffix When defined, the check will ensure class constant names will add the @@ -283,6 +299,11 @@ When defined, the check will ensure class member names will add the prefixed with the given value (regardless of casing). +.. option:: ClassMemberShortSizeThreshold + + Identifier naming checks won't be enforced for class member names having a + length less than or equal to this setting. + .. option:: ClassMemberSuffix When defined, the check will ensure class member names will add the @@ -324,6 +345,11 @@ When defined, the check will ensure class method names will add the prefixed with the given value (regardless of casing). +.. option:: ClassMethodShortSizeThreshold + + Identifier naming checks won't be enforced for class method names having a + length less than or equal to this setting. + .. option:: ClassMethodSuffix When defined, the check will ensure class method names will add the @@ -365,6 +391,11 @@ When defined, the check will ensure constant names will add the prefixed with the given value (regardless of casing). +.. option:: ConstantShortSizeThreshold + + Identifier naming checks won't be enforced for constant names having a + length less than or equal to this setting. + .. option:: ConstantSuffix When defined, the check will ensure constant names will add the @@ -400,6 +431,11 @@ When defined, the check will ensure constant member names will add the prefixed with the given value (regardless of casing). +.. option:: ConstantMemberShortSizeThreshold + + Identifier naming checks won't be enforced for constant member names having + a length less than or equal to this setting. + .. option:: ConstantMemberSuffix When defined, the check will ensure constant member names will add the @@ -439,6 +475,11 @@ When defined, the check will ensure constant parameter names will add the prefixed with the given value (regardless of casing). +.. option:: ConstantParameterShortSizeThreshold + + Identifier naming checks won't be enforced for constant parameter names + having a length less than or equal to this setting. + .. option:: ConstantParameterSuffix When defined, the check will ensure constant parameter names will add the @@ -474,6 +515,11 @@ When defined, the check will ensure constant pointer parameter names will add the prefixed with the given value (regardless of casing). +.. option:: ConstantPointerParameterShortSizeThreshold + + Identifier naming checks won't be enforced for constant pointer parameter + names having a length less than or equal to this setting. + .. option:: ConstantPointerParameterSuffix When defined, the check will ensure constant pointer parameter names will add the @@ -509,6 +555,11 @@ When defined, the check will ensure constexpr function names will add the prefixed with the given value (regardless of casing). +.. option:: ConstexprFunctionShortSizeThreshold + + Identifier naming checks won't be enforced for constexpr function names + having a length less than or equal to this setting. + .. option:: ConstexprFunctionSuffix When defined, the check will ensure constexpr function names will add the @@ -544,6 +595,11 @@ When defined, the check will ensure constexpr method names will add the prefixed with the given value (regardless of casing). +.. option:: ConstexprMethodShortSizeThreshold + + Identifier naming checks won't be enforced for constexpr method names + having a length less than or equal to this setting. + .. option:: ConstexprMethodSuffix When defined, the check will ensure constexpr method names will add the @@ -585,6 +641,11 @@ When defined, the check will ensure constexpr variable names will add the prefixed with the given value (regardless of casing). +.. option:: ConstexprVariableShortSizeThreshold + + Identifier naming checks won't be enforced for constexpr variable names + having a length less than or equal to this setting. + .. option:: ConstexprVariableSuffix When defined, the check will ensure constexpr variable names will add the @@ -620,6 +681,11 @@ When defined, the check will ensure enumeration names will add the prefixed with the given value (regardless of casing). +.. option:: EnumConstantShortSizeThreshold + + Identifier naming checks won't be enforced for enumeration names having a + length less than or equal to this setting. + .. option:: EnumSuffix When defined, the check will ensure enumeration names will add the @@ -655,6 +721,11 @@ When defined, the check will ensure enumeration constant names will add the prefixed with the given value (regardless of casing). +.. option:: EnumConstantShortSizeThreshold + + Identifier naming checks won't be enforced for enumeration constant names + having a length less than or equal to this setting. + .. option:: EnumConstantSuffix When defined, the check will ensure enumeration constant names will add the @@ -690,6 +761,11 @@ When defined, the check will ensure function names will add the prefixed with the given value (regardless of casing). +.. option:: FunctionShortSizeThreshold + + Identifier naming checks won't be enforced for function names having a + length less than or equal to this setting. + .. option:: FunctionSuffix When defined, the check will ensure function names will add the @@ -732,6 +808,11 @@ When defined, the check will ensure global constant names will add the prefixed with the given value (regardless of casing). +.. option:: GlobalConstantShortSizeThreshold + + Identifier naming checks won't be enforced for global constant names having + a length less than or equal to this setting. + .. option:: GlobalConstantSuffix When defined, the check will ensure global constant names will add the @@ -767,6 +848,11 @@ When defined, the check will ensure global constant pointer names will add the prefixed with the given value (regardless of casing). +.. option:: GlobalConstantPointerShortSizeThreshold + + Identifier naming checks won't be enforced for global constant pointer + names having a length less than or equal to this setting. + .. option:: GlobalConstantPointerSuffix When defined, the check will ensure global constant pointer names will add the @@ -802,6 +888,11 @@ When defined, the check will ensure global function names will add the prefixed with the given value (regardless of casing). +.. option:: GlobalFunctionShortSizeThreshold + + Identifier naming checks won't be enforced for global function names having + a length less than or equal to this setting. + .. option:: GlobalFunctionSuffix When defined, the check will ensure global function names will add the @@ -837,6 +928,11 @@ When defined, the check will ensure global pointer names will add the prefixed with the given value (regardless of casing). +.. option:: GlobalPointerShortSizeThreshold + + Identifier naming checks won't be enforced for global pointer names having + a length less than or equal to this setting. + .. option:: GlobalPointerSuffix When defined, the check will ensure global pointer names will add the @@ -872,6 +968,11 @@ When defined, the check will ensure global variable names will add the prefixed with the given value (regardless of casing). +.. option:: GlobalVariableShortSizeThreshold + + Identifier naming checks won't be enforced for global variable names having + a length less than or equal to this setting. + .. option:: GlobalVariableSuffix When defined, the check will ensure global variable names will add the @@ -913,6 +1014,11 @@ When defined, the check will ensure inline namespaces names will add the prefixed with the given value (regardless of casing). +.. option:: InlineNamespaceShortSizeThreshold + + Identifier naming checks won't be enforced for inline namespaces names + having a length less than or equal to this setting. + .. option:: InlineNamespaceSuffix When defined, the check will ensure inline namespaces names will add the @@ -956,6 +1062,11 @@ When defined, the check will ensure local constant names will add the prefixed with the given value (regardless of casing). +.. option:: LocalConstantShortSizeThreshold + + Identifier naming checks won't be enforced for local constant names having + a length less than or equal to this setting. + .. option:: LocalConstantSuffix When defined, the check will ensure local constant names will add the @@ -991,6 +1102,11 @@ When defined, the check will ensure local constant pointer names will add the prefixed with the given value (regardless of casing). +.. option:: LocalConstantPointerShortSizeThreshold + + Identifier naming checks won't be enforced for local constant pointer names + having a length less than or equal to this setting. + .. option:: LocalConstantPointerSuffix When defined, the check will ensure local constant pointer names will add the @@ -1026,6 +1142,11 @@ When defined, the check will ensure local pointer names will add the prefixed with the given value (regardless of casing). +.. option:: LocalPointerShortSizeThreshold + + Identifier naming checks won't be enforced for local pointer names having a + length less than or equal to this setting. + .. option:: LocalPointerSuffix When defined, the check will ensure local pointer names will add the @@ -1061,6 +1182,11 @@ When defined, the check will ensure local variable names will add the prefixed with the given value (regardless of casing). +.. option:: LocalVariableShortSizeThreshold + + Identifier naming checks won't be enforced for local variable names having + a length less than or equal to this setting. + .. option:: LocalVariableSuffix When defined, the check will ensure local variable names will add the @@ -1096,6 +1222,11 @@ When defined, the check will ensure macro definitions will add the prefixed with the given value (regardless of casing). +.. option:: MacroDefinitionShortSizeThreshold + + Identifier naming checks won't be enforced for macro definitions having a + length less than or equal to this setting. + .. option:: MacroDefinitionSuffix When defined, the check will ensure macro definitions will add the @@ -1134,6 +1265,11 @@ When defined, the check will ensure member names will add the prefixed with the given value (regardless of casing). +.. option:: MemberShortSizeThreshold + + Identifier naming checks won't be enforced for member names having a length + less than or equal to this setting. + .. option:: MemberSuffix When defined, the check will ensure member names will add the @@ -1173,6 +1309,11 @@ When defined, the check will ensure method names will add the prefixed with the given value (regardless of casing). +.. option:: MethodShortSizeThreshold + + Identifier naming checks won't be enforced for method names having a length + less than or equal to this setting. + .. option:: MethodSuffix When defined, the check will ensure method names will add the @@ -1212,6 +1353,11 @@ When defined, the check will ensure namespace names will add the prefixed with the given value (regardless of casing). +.. option:: NamespaceShortSizeThreshold + + Identifier naming checks won't be enforced for namespace names having a + length less than or equal to this setting. + .. option:: NamespaceSuffix When defined, the check will ensure namespace names will add the @@ -1251,6 +1397,11 @@ When defined, the check will ensure parameter names will add the prefixed with the given value (regardless of casing). +.. option:: ParameterShortSizeThreshold + + Identifier naming checks won't be enforced for parameter names having a + length less than or equal to this setting. + .. option:: ParameterSuffix When defined, the check will ensure parameter names will add the @@ -1286,6 +1437,11 @@ When defined, the check will ensure parameter pack names will add the prefixed with the given value (regardless of casing). +.. option:: ParameterPackShortSizeThreshold + + Identifier naming checks won't be enforced for parameter pack names having + a length less than or equal to this setting. + .. option:: ParameterPackSuffix When defined, the check will ensure parameter pack names will add the @@ -1325,6 +1481,11 @@ When defined, the check will ensure pointer parameter names will add the prefixed with the given value (regardless of casing). +.. option:: PointerParameterShortSizeThreshold + + Identifier naming checks won't be enforced for pointer parameter names + having a length less than or equal to this setting. + .. option:: PointerParameterSuffix When defined, the check will ensure pointer parameter names will add the @@ -1360,6 +1521,11 @@ When defined, the check will ensure private member names will add the prefixed with the given value (regardless of casing). +.. option:: PrivateMemberShortSizeThreshold + + Identifier naming checks won't be enforced for private member names having + a length less than or equal to this setting. + .. option:: PrivateMemberSuffix When defined, the check will ensure private member names will add the @@ -1401,6 +1567,11 @@ When defined, the check will ensure private method names will add the prefixed with the given value (regardless of casing). +.. option:: PrivateMethodShortSizeThreshold + + Identifier naming checks won't be enforced for private method names having + a length less than or equal to this setting. + .. option:: PrivateMethodSuffix When defined, the check will ensure private method names will add the @@ -1442,6 +1613,11 @@ When defined, the check will ensure protected member names will add the prefixed with the given value (regardless of casing). +.. option:: ProtectedMemberShortSizeThreshold + + Identifier naming checks won't be enforced for protected member names + having a length less than or equal to this setting. + .. option:: ProtectedMemberSuffix When defined, the check will ensure protected member names will add the @@ -1475,17 +1651,22 @@ .. option:: ProtectedMethodCase - When defined, the check will ensure protect method names conform to the + When defined, the check will ensure protected method names conform to the selected casing. .. option:: ProtectedMethodPrefix - When defined, the check will ensure protect method names will add the + When defined, the check will ensure protected method names will add the prefixed with the given value (regardless of casing). +.. option:: ProtectedMethodShortSizeThreshold + + Identifier naming checks won't be enforced for protected method names + having a length less than or equal to this setting. + .. option:: ProtectedMethodSuffix - When defined, the check will ensure protect method names will add the + When defined, the check will ensure protected method names will add the suffix with the given value (regardless of casing). For example using values of: @@ -1524,6 +1705,11 @@ When defined, the check will ensure public member names will add the prefixed with the given value (regardless of casing). +.. option:: PublicMemberShortSizeThreshold + + Identifier naming checks won't be enforced for public member names having a + length less than or equal to this setting. + .. option:: PublicMemberSuffix When defined, the check will ensure public member names will add the @@ -1565,6 +1751,11 @@ When defined, the check will ensure public method names will add the prefixed with the given value (regardless of casing). +.. option:: PublicMethodShortSizeThreshold + + Identifier naming checks won't be enforced for public method names having a + length less than or equal to this setting. + .. option:: PublicMethodSuffix When defined, the check will ensure public method names will add the @@ -1606,6 +1797,11 @@ When defined, the check will ensure scoped enum constant names will add the prefixed with the given value (regardless of casing). +.. option:: ScopedEnumConstantShortSizeThreshold + + Identifier naming checks won't be enforced for scoped enum constant names + having a length less than or equal to this setting. + .. option:: ScopedEnumConstantSuffix When defined, the check will ensure scoped enum constant names will add the @@ -1641,6 +1837,11 @@ When defined, the check will ensure static constant names will add the prefixed with the given value (regardless of casing). +.. option:: StaticConstantShortSizeThreshold + + Identifier naming checks won't be enforced for static constant names having + a length less than or equal to this setting. + .. option:: StaticConstantSuffix When defined, the check will ensure static constant names will add the @@ -1676,6 +1877,11 @@ When defined, the check will ensure static variable names will add the prefixed with the given value (regardless of casing). +.. option:: StaticVariableShortSizeThreshold + + Identifier naming checks won't be enforced for static variable names having + a length less than or equal to this setting. + .. option:: StaticVariableSuffix When defined, the check will ensure static variable names will add the @@ -1711,6 +1917,11 @@ When defined, the check will ensure struct names will add the prefixed with the given value (regardless of casing). +.. option:: StructShortSizeThreshold + + Identifier naming checks won't be enforced for struct names having a length + less than or equal to this setting. + .. option:: StructSuffix When defined, the check will ensure struct names will add the @@ -1752,6 +1963,11 @@ When defined, the check will ensure template parameter names will add the prefixed with the given value (regardless of casing). +.. option:: TemplateParameterShortSizeThreshold + + Identifier naming checks won't be enforced for template parameter names + having a length less than or equal to this setting. + .. option:: TemplateParameterSuffix When defined, the check will ensure template parameter names will add the @@ -1787,6 +2003,11 @@ When defined, the check will ensure template template parameter names will add the prefixed with the given value (regardless of casing). +.. option:: TemplateTemplateParameterShortSizeThreshold + + Identifier naming checks won't be enforced for template template parameter + names having a length less than or equal to this setting. + .. option:: TemplateTemplateParameterSuffix When defined, the check will ensure template template parameter names will add the @@ -1824,6 +2045,11 @@ When defined, the check will ensure type alias names will add the prefixed with the given value (regardless of casing). +.. option:: TypeAliasShortSizeThreshold + + Identifier naming checks won't be enforced for type alias names having a + length less than or equal to this setting. + .. option:: TypeAliasSuffix When defined, the check will ensure type alias names will add the @@ -1859,6 +2085,11 @@ When defined, the check will ensure typedef names will add the prefixed with the given value (regardless of casing). +.. option:: TypedefShortSizeThreshold + + Identifier naming checks won't be enforced for typedef names having a + length less than or equal to this setting. + .. option:: TypedefSuffix When defined, the check will ensure typedef names will add the @@ -1894,6 +2125,11 @@ When defined, the check will ensure type template parameter names will add the prefixed with the given value (regardless of casing). +.. option:: TypeTemplateParameterShortSizeThreshold + + Identifier naming checks won't be enforced for type template names having a + length less than or equal to this setting. + .. option:: TypeTemplateParameterSuffix When defined, the check will ensure type template parameter names will add the @@ -1931,6 +2167,11 @@ When defined, the check will ensure union names will add the prefixed with the given value (regardless of casing). +.. option:: UnionShortSizeThreshold + + Identifier naming checks won't be enforced for union names having a length + less than or equal to this setting. + .. option:: UnionSuffix When defined, the check will ensure union names will add the @@ -1972,6 +2213,11 @@ When defined, the check will ensure value template parameter names will add the prefixed with the given value (regardless of casing). +.. option:: ValueTemplateParameterShortSizeThreshold + + Identifier naming checks won't be enforced for value template parameter + names having a length less than or equal to this setting. + .. option:: ValueTemplateParameterSuffix When defined, the check will ensure value template parameter names will add the @@ -2009,6 +2255,11 @@ When defined, the check will ensure variable names will add the prefixed with the given value (regardless of casing). +.. option:: VariableShortSizeThreshold + + Identifier naming checks won't be enforced for variable names having a + length less than or equal to this setting. + .. option:: VariableSuffix When defined, the check will ensure variable names will add the @@ -2044,6 +2295,11 @@ When defined, the check will ensure virtual method names will add the prefixed with the given value (regardless of casing). +.. option:: VirtualMethodShortSizeThreshold + + Identifier naming checks won't be enforced for virtual method names having + a length less than or equal to this setting. + .. option:: VirtualMethodSuffix When defined, the check will ensure virtual method names will add the Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-short-names.cpp =================================================================== --- /dev/null +++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-short-names.cpp @@ -0,0 +1,26 @@ +// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \ +// RUN: -config='{CheckOptions: [ \ +// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase}, \ +// RUN: {key: readability-identifier-naming.ClassCase, value: CamelCase}, \ +// RUN: {key: readability-identifier-naming.ParameterShortSizeThreshold, value: 2}, \ +// RUN: {key: readability-identifier-naming.ClassShortSizeThreshold, value: 3} \ +// RUN: ]}' + +int testFunc(int a, char **b); +int testFunc(int ab, char **ba); +int testFunc(int abc, char **cba); +// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'abc' +// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: invalid case style for parameter 'cba' +// CHECK-FIXES: {{^}}int testFunc(int Abc, char **Cba);{{$}} +int testFunc(int Abc, char **Cba); + +class fo { +}; + +class foo { +}; + +class fooo { + // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'fooo' + // CHECK-FIXES: {{^}}class Fooo {{{$}} +};