[PATCH] D51832: [clang-tidy/checks] Update objc-property-declaration check to allow arbitrary acronyms and initialisms 🔧

Stephane Moore via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 1 17:50:14 PDT 2018


stephanemoore added a comment.

I believe that it should be safe to remove the `Acronyms` and `IncludeDefaultAcronyms` options but if it's alright with you, I would prefer to separate that into a followup change.



================
Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:28-31
 // For StandardProperty the naming style is 'lowerCamelCase'.
 // For CategoryProperty especially in categories of system class,
 // to avoid naming conflict, the suggested naming style is
 // 'abc_lowerCamelCase' (adding lowercase prefix followed by '_').
----------------
benhamilton wrote:
> These comments are no longer accurate.
I think the comments are still more or less accurate? I think we have just changed the level of enforcement that we are applying.

We allow aRbITRaRyCapS now but that's based on the concession that it's fundamentally hard to identify appropriate lowerCamelCase with high precision (i.e., it is hard to reject "aRbITRaRyCapS" as a representation of "a rb IT ra ry cap S" without human judgment). I added a note that acronyms and initialisms are capitalized regardless of style though.

❧

Sidenote:
A spark of curiosity led to me realizing that the previous approach would also have allowed aRbITRaRyCapS if all letters of the alphabet were to be whitelisted as acronyms. The previous check already included several letters in the default special acronyms and provided special treatment for "A" and "I" in the matching regex. I can't say for certain that every letter of the alphabet would have ended up being whitelisted but I audited the letters of the alphabet and I think I managed to construct a list of terms that could conceivably have been used in code and might have led to the whitelisting of each individual letter of the alphabet (attached below¹).

[1] List of Letters in English Alphabet and Terms Containing Them in Isolation
* A: https://en.wikipedia.org/wiki/A_value
* B: https://en.wikipedia.org/wiki/B_vitamins
* C: https://en.wikipedia.org/wiki/C_major
* D: https://en.wikipedia.org/wiki/D_major
* E: https://en.wikipedia.org/wiki/E_major
* F: https://en.wikipedia.org/wiki/F-number
* G: https://en.wikipedia.org/wiki/G_major
* H: https://en.wikipedia.org/wiki/H-index
* I: https://en.wikipedia.org/wiki/I_band_(NATO)
* J: https://en.wikipedia.org/wiki/J_operator
* K: https://en.wikipedia.org/wiki/Vitamin_K
* L: https://en.wikipedia.org/wiki/L-notation
* M: https://en.wikipedia.org/wiki/M_postcode_area
* N: https://en.wikipedia.org/wiki/N_ray
* O: https://en.wikipedia.org/wiki/Big_O_notation
* P: https://en.wikipedia.org/wiki/Extrinsic_semiconductor#P-type_semiconductors
* Q: https://en.wikipedia.org/wiki/Q_Score
* R: https://en.wikipedia.org/wiki/R-value_(insulation)
* S: https://en.wikipedia.org/wiki/S_postcode_area
* T: https://en.wikipedia.org/wiki/F-number#T-stop
* U: https://en.wikipedia.org/wiki/U_language
* V: https://en.wikipedia.org/wiki/V_band
* W: https://en.wikipedia.org/wiki/W_and_Z_bosons
* X: https://en.wikipedia.org/wiki/X-ray
* Y: https://en.wikipedia.org/wiki/Y_chromosome
* Z: https://en.wikipedia.org/wiki/Z-buffering




Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D51832





More information about the cfe-commits mailing list