1
1
"""
2
2
Start the function name with 'is' or 'has' when returning bool.
3
- This rule might be violated a lot because there are a lot of cases
3
+ This rule might be violated a lot because there are a lot of cases
4
4
in which functions return bool to indicate exceptions.
5
5
Please turn off this rule. If you think it's too overwhelming.
6
6
9
9
bool checkSth() { <== Violation. The function name should be isSth or hasSth.
10
10
return false;
11
11
}
12
-
12
+
13
13
== Good ==
14
14
15
15
bool isSth() { <== OK.
16
16
return true;
17
17
}
18
-
18
+
19
19
is isSth() { <== Don't care. it's not returnning bool.
20
20
}
21
21
"""
@@ -39,7 +39,7 @@ def RunRule(lexer, fullName, decl, contextStack, context) :
39
39
"The function name(%s) should start with has or is when returinning bool" % fullName )
40
40
break ;
41
41
k += 1
42
-
42
+
43
43
ruleManager .AddFunctionNameRule (RunRule )
44
44
45
45
@@ -59,44 +59,44 @@ def RunRule(lexer, fullName, decl, contextStack, context) :
59
59
class testRule (nct ):
60
60
def setUpRule (self ):
61
61
ruleManager .AddFunctionNameRule (RunRule )
62
-
62
+
63
63
def test1 (self ):
64
- self .Analyze ("test/thisFile.c" ,
64
+ self .Analyze ("test/thisFile.c" ,
65
65
"""
66
66
bool canHave() {
67
67
}""" )
68
- assert CheckErrorContent (__name__ )
68
+ assert CheckErrorContent (__name__ )
69
69
def test2 (self ):
70
- self .Analyze ("test/thisFile.c" ,
70
+ self .Analyze ("test/thisFile.c" ,
71
71
"""
72
72
bool CTEST:canHave() {
73
73
}""" )
74
- assert CheckErrorContent (__name__ )
74
+ assert CheckErrorContent (__name__ )
75
75
def test3 (self ):
76
- self .Analyze ("test/thisFile.c" ,
76
+ self .Analyze ("test/thisFile.c" ,
77
77
"""
78
78
extern bool CTEST:canHave() {
79
79
}""" )
80
- assert CheckErrorContent (__name__ )
80
+ assert CheckErrorContent (__name__ )
81
81
def test4 (self ):
82
- self .Analyze ("test/thisFile.c" ,
82
+ self .Analyze ("test/thisFile.c" ,
83
83
"""
84
84
extern int CTEST:canHave() {
85
85
}""" )
86
- assert not CheckErrorContent (__name__ )
86
+ assert not CheckErrorContent (__name__ )
87
87
def test5 (self ):
88
- self .Analyze ("test/thisFile.c" ,
88
+ self .Analyze ("test/thisFile.c" ,
89
89
"""
90
90
extern int CTEST:isIt() {
91
91
}""" )
92
- assert not CheckErrorContent (__name__ )
92
+ assert not CheckErrorContent (__name__ )
93
93
def test6 (self ):
94
- self .Analyze ("test/thisFile.c" ,
94
+ self .Analyze ("test/thisFile.c" ,
95
95
"""
96
96
class K {
97
97
extern bool CTEST:canHave();
98
98
}""" )
99
- assert CheckErrorContent (__name__ )
99
+ assert CheckErrorContent (__name__ )
100
100
101
101
def test7 (self ):
102
102
self .Analyze ("test/thisFile.c" , """
@@ -112,18 +112,22 @@ def test7(self):
112
112
*/
113
113
void AddGate(GATE gate){m_GateCont.push_back(gate); }
114
114
""" )
115
- assert not CheckErrorContent (__name__ )
116
-
115
+ assert not CheckErrorContent (__name__ )
116
+
117
117
def test8 (self ):
118
- self .Analyze ("test/thisFile.c" ,
118
+ self .Analyze ("test/thisFile.c" ,
119
119
"""
120
120
boolean operator=();
121
121
boolean KK::operator=();
122
122
""" )
123
123
assert not CheckErrorContent (__name__ )
124
+
124
125
def test9 (self ):
125
126
self .Analyze ("test/thisFile.c" ,
126
127
"""
128
+ /**
129
+ * This tests for correct parsing of fn name and nested templates
130
+ **/
127
131
template<class ObjectTypePtr,
128
132
typename = typename std::enable_if<std::is_pointer<ObjectTypePtr>::value>::type>
129
133
bool canHave(ObjectTypePtr obj) {
@@ -134,9 +138,13 @@ def test9(self):
134
138
bool canHave(ObjectTypeNotPtr obj) {
135
139
}""" )
136
140
assert CheckErrorContent (__name__ )
141
+
137
142
def test10 (self ):
138
143
self .Analyze ("test/thisFile.c" ,
139
144
"""
145
+ /**
146
+ * This tests for correct parsing of fn name and nested templates
147
+ **/
140
148
template<class ObjectTypePtr,
141
149
typename = typename std::enable_if<std::is_pointer<ObjectTypePtr>::value>::type>
142
150
bool isIt(ObjectTypePtr obj) {
0 commit comments