xref: /llvm-project/clang-tools-extra/test/clang-tidy/checkers/objc/property-declaration.m (revision 89a1d03e2b379e325daa5249411e414bbd995b5e)
1*89a1d03eSRichard// RUN: %check_clang_tidy %s objc-property-declaration %t
2*89a1d03eSRichard@class CIColor;
3*89a1d03eSRichard@class NSArray;
4*89a1d03eSRichard@class NSData;
5*89a1d03eSRichard@class NSString;
6*89a1d03eSRichard@class UIViewController;
7*89a1d03eSRichard
8*89a1d03eSRichardtypedef void *CGColorRef;
9*89a1d03eSRichard
10*89a1d03eSRichard@interface Foo
11*89a1d03eSRichard@property(assign, nonatomic) int NotCamelCase;
12*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'NotCamelCase' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
13*89a1d03eSRichard// CHECK-FIXES: @property(assign, nonatomic) int notCamelCase;
14*89a1d03eSRichard@property(assign, nonatomic) int camelCase;
15*89a1d03eSRichard@property(strong, nonatomic) NSString *URLString;
16*89a1d03eSRichard@property(strong, nonatomic) NSString *bundleID;
17*89a1d03eSRichard@property(strong, nonatomic) NSData *RGBABytes;
18*89a1d03eSRichard@property(strong, nonatomic) UIViewController *notificationsVC;
19*89a1d03eSRichard@property(strong, nonatomic) NSString *URL_string;
20*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
21*89a1d03eSRichard@property(strong, nonatomic) NSString *supportURLsCamelCase;
22*89a1d03eSRichard@property(strong, nonatomic) NSString *supportURLCamelCase;
23*89a1d03eSRichard@property(strong, nonatomic) NSString *VCsPluralToAdd;
24*89a1d03eSRichard@property(assign, nonatomic) int centerX;
25*89a1d03eSRichard@property(assign, nonatomic) int enable2GBackgroundFetch;
26*89a1d03eSRichard@property(assign, nonatomic) int shouldUseCFPreferences;
27*89a1d03eSRichard@property(assign, nonatomic) int enableGLAcceleration;
28*89a1d03eSRichard@property(assign, nonatomic) int ID;
29*89a1d03eSRichard@property(assign, nonatomic) int hasADog;
30*89a1d03eSRichard@property(nonatomic, readonly) CGColorRef CGColor;
31*89a1d03eSRichard@property(nonatomic, readonly) CIColor *CIColor;
32*89a1d03eSRichard@property(nonatomic, copy) NSArray *IDs;
33*89a1d03eSRichard@end
34*89a1d03eSRichard
35*89a1d03eSRichard@interface Foo (Bar)
36*89a1d03eSRichard@property(assign, nonatomic) int abc_NotCamelCase;
37*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'abc_NotCamelCase' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
38*89a1d03eSRichard@property(assign, nonatomic) int abCD_camelCase;
39*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'abCD_camelCase' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
40*89a1d03eSRichard// CHECK-FIXES: @property(assign, nonatomic) int abcd_camelCase;
41*89a1d03eSRichard@property(assign, nonatomic) int abCD_NotCamelCase;
42*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'abCD_NotCamelCase' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
43*89a1d03eSRichard// CHECK-FIXES: @property(assign, nonatomic) int abcd_notCamelCase;
44*89a1d03eSRichard@property(assign, nonatomic) int wrongFormat_;
45*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'wrongFormat_' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
46*89a1d03eSRichard@property(strong, nonatomic) NSString *URLStr;
47*89a1d03eSRichard@property(assign, nonatomic) int abc_camelCase;
48*89a1d03eSRichard@property(strong, nonatomic) NSString *abc_URL;
49*89a1d03eSRichard@property(strong, nonatomic) NSString *opac2_sourceComponent;
50*89a1d03eSRichard@end
51*89a1d03eSRichard
52*89a1d03eSRichard@interface Foo ()
53*89a1d03eSRichard@property(assign, nonatomic) int abc_inClassExtension;
54*89a1d03eSRichard// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'abc_inClassExtension' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
55*89a1d03eSRichard@end