[PATCH] D51575: [clang-tidy] Implement a clang-tidy check to verify Google Objective-C function naming conventions 📜

Ben Hamilton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 5 09:11:55 PDT 2018


benhamilton requested changes to this revision.
benhamilton added a comment.
This revision now requires changes to proceed.

Thanks for this! Let's consolidate this with the property name checker (either simplify the logic there and allow `arBiTRAryCapSAnYWHere` or apply the same registered acronym logic here).



================
Comment at: clang-tidy/google/FunctionNamingCheck.cpp:35
+  // non-standard capitalized character sequences including acronyms,
+  // initialisms, and prefixes of symbols (e.g., UIColorFromNSString). For this
+  // reason, the regex only verifies that the function name after the prefix
----------------
Any reason why this is different from the implementation in the property name checker? Either we should allow both of:

```
void ARBiTraRilyNameDFuncTioN();
// ...
@property (...) id arBItrArIlyNameD;
```

or we should require that acronyms in the middle of the name be registered/known acronyms for both properties and functions.

I believe this diff allows arbitrary capitalization for functions, but we disallowed that for property names, so I think we should be consistent.


================
Comment at: clang-tidy/google/FunctionNamingCheck.cpp:50
+
+void FunctionNamingCheck::registerMatchers(MatchFinder *Finder) {
+  // This check should only be applied to Objective-C sources.
----------------
Wizard wrote:
> Can we do some simple check to see if some easy fix can be provided just like `objc-property-declaration` check?
> Something like `static bool isPositive` to `static bool IsPositive` and `static bool is_upper_camel` to `IsUpperCamel`. Such check can help provide code fix for a lot of  very common mistake at a low cost (i.e. if the naming pattern cannot be simply recognized, just provide no fix).
+1, I think the two checks should be substantially similar.


================
Comment at: clang-tidy/google/FunctionNamingCheck.h:21
+
+/// Finds function names that do not conform to the recommendations of the
+/// Google Objective-C Style Guide. Function names should be in upper camel case
----------------
Worth mentioning this does not apply to Objective-C method names, nor Objective-C properties.



Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51575





More information about the cfe-commits mailing list