Skip to content

Commit 3ed5f39

Browse files
committed
Merged PR #10
Thanks @Farigh
1 parent 898d077 commit 3ed5f39

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

rules/RULE_3_3_A_start_function_name_with_is_or_has_when_return_bool.py

+28-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
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
44
in which functions return bool to indicate exceptions.
55
Please turn off this rule. If you think it's too overwhelming.
66
@@ -9,13 +9,13 @@
99
bool checkSth() { <== Violation. The function name should be isSth or hasSth.
1010
return false;
1111
}
12-
12+
1313
== Good ==
1414
1515
bool isSth() { <== OK.
1616
return true;
1717
}
18-
18+
1919
is isSth() { <== Don't care. it's not returnning bool.
2020
}
2121
"""
@@ -39,7 +39,7 @@ def RunRule(lexer, fullName, decl, contextStack, context) :
3939
"The function name(%s) should start with has or is when returinning bool" % fullName)
4040
break;
4141
k += 1
42-
42+
4343
ruleManager.AddFunctionNameRule(RunRule)
4444

4545

@@ -59,44 +59,44 @@ def RunRule(lexer, fullName, decl, contextStack, context) :
5959
class testRule(nct):
6060
def setUpRule(self):
6161
ruleManager.AddFunctionNameRule(RunRule)
62-
62+
6363
def test1(self):
64-
self.Analyze("test/thisFile.c",
64+
self.Analyze("test/thisFile.c",
6565
"""
6666
bool canHave() {
6767
}""")
68-
assert CheckErrorContent(__name__)
68+
assert CheckErrorContent(__name__)
6969
def test2(self):
70-
self.Analyze("test/thisFile.c",
70+
self.Analyze("test/thisFile.c",
7171
"""
7272
bool CTEST:canHave() {
7373
}""")
74-
assert CheckErrorContent(__name__)
74+
assert CheckErrorContent(__name__)
7575
def test3(self):
76-
self.Analyze("test/thisFile.c",
76+
self.Analyze("test/thisFile.c",
7777
"""
7878
extern bool CTEST:canHave() {
7979
}""")
80-
assert CheckErrorContent(__name__)
80+
assert CheckErrorContent(__name__)
8181
def test4(self):
82-
self.Analyze("test/thisFile.c",
82+
self.Analyze("test/thisFile.c",
8383
"""
8484
extern int CTEST:canHave() {
8585
}""")
86-
assert not CheckErrorContent(__name__)
86+
assert not CheckErrorContent(__name__)
8787
def test5(self):
88-
self.Analyze("test/thisFile.c",
88+
self.Analyze("test/thisFile.c",
8989
"""
9090
extern int CTEST:isIt() {
9191
}""")
92-
assert not CheckErrorContent(__name__)
92+
assert not CheckErrorContent(__name__)
9393
def test6(self):
94-
self.Analyze("test/thisFile.c",
94+
self.Analyze("test/thisFile.c",
9595
"""
9696
class K {
9797
extern bool CTEST:canHave();
9898
}""")
99-
assert CheckErrorContent(__name__)
99+
assert CheckErrorContent(__name__)
100100

101101
def test7(self):
102102
self.Analyze("test/thisFile.c", """
@@ -112,18 +112,22 @@ def test7(self):
112112
*/
113113
void AddGate(GATE gate){m_GateCont.push_back(gate); }
114114
""")
115-
assert not CheckErrorContent(__name__)
116-
115+
assert not CheckErrorContent(__name__)
116+
117117
def test8(self):
118-
self.Analyze("test/thisFile.c",
118+
self.Analyze("test/thisFile.c",
119119
"""
120120
boolean operator=();
121121
boolean KK::operator=();
122122
""")
123123
assert not CheckErrorContent(__name__)
124+
124125
def test9(self):
125126
self.Analyze("test/thisFile.c",
126127
"""
128+
/**
129+
* This tests for correct parsing of fn name and nested templates
130+
**/
127131
template<class ObjectTypePtr,
128132
typename = typename std::enable_if<std::is_pointer<ObjectTypePtr>::value>::type>
129133
bool canHave(ObjectTypePtr obj) {
@@ -134,9 +138,13 @@ def test9(self):
134138
bool canHave(ObjectTypeNotPtr obj) {
135139
}""")
136140
assert CheckErrorContent(__name__)
141+
137142
def test10(self):
138143
self.Analyze("test/thisFile.c",
139144
"""
145+
/**
146+
* This tests for correct parsing of fn name and nested templates
147+
**/
140148
template<class ObjectTypePtr,
141149
typename = typename std::enable_if<std::is_pointer<ObjectTypePtr>::value>::type>
142150
bool isIt(ObjectTypePtr obj) {

0 commit comments

Comments
 (0)