Skip to content

Commit 36f852f

Browse files
committed
Compliant with PEP8
Made Update() essentially a No-op
1 parent 293a5cb commit 36f852f

File tree

3 files changed

+55
-39
lines changed

3 files changed

+55
-39
lines changed

nsiqcppstyle_checker.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ def t_ID(t):
258258
"__try": "IGNORE",
259259
"dllexport": "IGNORE",
260260
"final": "IGNORE",
261-
"override":"IGNORE",
262-
"noexcept":"IGNORE"
261+
"override": "IGNORE",
262+
"noexcept": "IGNORE"
263263
}
264264

265265

@@ -688,34 +688,34 @@ def GetPrevToken(self, skipWhiteSpace=False,
688688
return token
689689

690690
def GetPrevMatchingLT(self, keepCur=False):
691-
if keepCur :
691+
if keepCur:
692692
self.PushTokenIndex()
693693
gtStack = []
694-
if not self.GetCurToken().type in ["GT", "RSHIFT"] :
694+
if not self.GetCurToken().type in ["GT", "RSHIFT"]:
695695
raise RuntimeError(
696696
'Matching previous LT token should be examined when cur token is > or >>')
697697
# If >> token is found, append it twice
698-
if self.GetCurToken().type == "RSHIFT" :
698+
if self.GetCurToken().type == "RSHIFT":
699699
gtStack.append(self.GetCurToken())
700700
gtStack.append(self.GetCurToken())
701701
t = self._GetPrevMatchingLTToken(gtStack)
702-
if keepCur :
702+
if keepCur:
703703
self.PopTokenIndex()
704704
return t
705705

706706
def _GetPrevMatchingLTToken(self, tokenStack):
707-
while True :
707+
while True:
708708
prevToken = self._GetPrevToken()
709-
if prevToken is None :
709+
if prevToken is None:
710710
return None
711-
elif prevToken.type in ["GT"] :
711+
elif prevToken.type in ["GT"]:
712712
tokenStack.append(prevToken)
713-
elif prevToken.type in ["RSHIFT"] :
713+
elif prevToken.type in ["RSHIFT"]:
714714
tokenStack.append(prevToken)
715715
tokenStack.append(prevToken)
716-
elif prevToken.type in ["LT"] :
716+
elif prevToken.type in ["LT"]:
717717
tokenStack.pop()
718-
if len(tokenStack) == 0 :
718+
if len(tokenStack) == 0:
719719
return prevToken
720720

721721
def GetPrevMatchingToken(self, keepCur=False):

nsiqcppstyle_exe.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,11 @@ def ProcessFile(ruleManager, file, analyzedFiles):
320320

321321

322322
def Update():
323+
console.Out.Error("Development in progress. Please check manually")
324+
"""
323325
updateagent.agent.Update("http: //nsiqcppstyle.nsiq.nhncorp.com/update",
324326
version)
325-
326-
327-
csvResult = []
327+
"""
328328

329329

330330
def GetOutputPath(outputBasePath, outputPath):
@@ -347,7 +347,8 @@ def GetRealTargetPaths(args):
347347
targetPaths.append(realPath)
348348
# CheckPathPermission(realPath, "Target directory")
349349
if not os.path.exists(realPath):
350-
ShowMessageAndExit("Error!: Target directory %s is not exists" % eachTarget)
350+
ShowMessageAndExit(
351+
"Error!: Target directory %s is not exists" % eachTarget)
351352
return targetPaths
352353

353354
##########################################################################
@@ -477,7 +478,8 @@ def NormalizePath(self, eachFilter):
477478
return replacedpath.replace("\\", os.path.sep)
478479

479480
def CheckExist(self, includeOrExclude, eachFilter, startwith):
480-
return (self.filefilter.count([includeOrExclude, eachFilter, startwith]) == 1)
481+
return (self.filefilter.count(
482+
[includeOrExclude, eachFilter, startwith]) == 1)
481483

482484
def AddInclude(self, eachFilter):
483485
self.AddFilter(True, eachFilter)
@@ -538,7 +540,9 @@ def AddLangMap(self, langMapString, where):
538540
for eachExt in langExtList:
539541
extLangPair = eachExt.split(": ")
540542
if len(extLangPair) != 2:
541-
ShowMessageAndExit("Error!: The extension and language pair (%s) is incorrect in %s, please use LANGUAGENAME: EXTENSION style" % (langMapString, where))
543+
ShowMessageAndExit(
544+
"Error!: The extension and language pair (%s) is incorrect in %s, please use LANGUAGENAME: EXTENSION style" %
545+
(langMapString, where))
542546
lang, ext = extLangPair
543547
self.extLangMap.get(lang).add(ext)
544548

@@ -557,7 +561,9 @@ def GetCustomKeyValueMap(keyValuePair, where):
557561
for eachCustomKeyValue in customKeyValues:
558562
customKeyValuePair = eachCustomKeyValue.split(": ")
559563
if len(customKeyValuePair) != 2:
560-
ShowMessageAndExit("Error!: The var key and value pair (%s) is incorrect in %s, please use KEY: VALUE style" % (keyValuePair, where))
564+
ShowMessageAndExit(
565+
"Error!: The var key and value pair (%s) is incorrect in %s, please use KEY: VALUE style" %
566+
(keyValuePair, where))
561567
key, value = customKeyValuePair
562568
varMap[key] = value
563569
return varMap
@@ -609,7 +615,9 @@ def ShowRuleList():
609615

610616
def CheckPathPermission(path, folderrole):
611617
if not os.access(path, os.R_OK) and os.path.exists(path):
612-
ShowMessageAndExit("Error!: %s You should have read permission in %s." % (folderrole, path))
618+
ShowMessageAndExit(
619+
"Error!: %s You should have read permission in %s." %
620+
(folderrole, path))
613621
return True
614622

615623
##########################################################################

nsiqunittest/nsiqcppstyle_unittest.py

+27-19
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@
3030
from nsiqcppstyle_outputer import _consoleOutputer as console
3131
import nsiqcppstyle_state
3232

33+
3334
class unitTest(unittest.TestCase):
3435
def __testFunctionSpecifier(self, specifier):
35-
lexer = nsiqcppstyle_checker.CppLexerNavigator("a.cpp", "void FunctionName() " + specifier + ";")
36+
lexer = nsiqcppstyle_checker.CppLexerNavigator(
37+
"a.cpp", "void FunctionName() " + specifier + ";")
3638
# This step resolves comments and some token types like FUNCTION
3739
nsiqcppstyle_checker.ContructContextInfo(lexer)
38-
lexer.Reset();
40+
lexer.Reset()
3941

4042
assert(lexer.GetNextTokenSkipWhiteSpaceAndComment().type == 'VOID')
4143
assert(lexer.GetNextTokenSkipWhiteSpaceAndComment().type == 'FUNCTION')
@@ -47,7 +49,7 @@ def __testFunctionSpecifier(self, specifier):
4749
assert(specifierToken.value == specifier)
4850

4951
assert(lexer.GetNextTokenSkipWhiteSpaceAndComment().type == 'SEMI')
50-
assert(lexer.GetNextTokenSkipWhiteSpaceAndComment() == None)
52+
assert(lexer.GetNextTokenSkipWhiteSpaceAndComment() is None)
5153

5254
def testIgnoreFinalFunctionSpecifier(self):
5355
self.__testFunctionSpecifier("final")
@@ -59,60 +61,66 @@ def testIgnoreNoexceptFunctionSpecifier(self):
5961
self.__testFunctionSpecifier("noexcept")
6062

6163
def testGetPrevMatchingLT(self):
62-
lexer = nsiqcppstyle_checker.CppLexerNavigator("a.cpp", "std::set<int> m;")
64+
lexer = nsiqcppstyle_checker.CppLexerNavigator(
65+
"a.cpp", "std::set<int> m;")
6366
# This step resolves comments and some token types like FUNCTION
6467
nsiqcppstyle_checker.ContructContextInfo(lexer)
65-
lexer.Reset();
68+
lexer.Reset()
6669

6770
ltToken = lexer.GetNextTokenInType("LT")
68-
assert(ltToken != None and ltToken.type == "LT")
71+
assert(ltToken is not None and ltToken.type == "LT")
6972
gtToken = lexer.GetNextTokenInType("GT")
70-
assert(gtToken != None and gtToken.type == "GT")
73+
assert(gtToken is not None and gtToken.type == "GT")
7174

7275
matchingLtToken = lexer.GetPrevMatchingLT()
73-
assert(matchingLtToken != None and matchingLtToken.type == "LT")
76+
assert(matchingLtToken is not None and matchingLtToken.type == "LT")
7477
assert(matchingLtToken.column == ltToken.column)
7578

7679
def testGetPrevMatchingLTWithInnerOnes(self):
77-
lexer = nsiqcppstyle_checker.CppLexerNavigator("a.cpp", "std::map<std::set<int>, float> m;")
80+
lexer = nsiqcppstyle_checker.CppLexerNavigator(
81+
"a.cpp", "std::map<std::set<int>, float> m;")
7882
# This step resolves comments and some token types like FUNCTION
7983
nsiqcppstyle_checker.ContructContextInfo(lexer)
80-
lexer.Reset();
84+
lexer.Reset()
8185

8286
# Get the first < token
8387
ltToken = lexer.GetNextTokenInType("LT")
84-
assert(ltToken != None and ltToken.type == "LT" and ltToken.column == 9)
88+
assert(ltToken is not None and ltToken.type ==
89+
"LT" and ltToken.column == 9)
8590

8691
# Get the first > token
8792
gtToken = lexer.GetNextTokenInType("GT")
88-
assert(gtToken != None and gtToken.type == "GT")
93+
assert(gtToken is not None and gtToken.type == "GT")
8994
# Get the second > token
9095
prevGtTokenColumn = gtToken.column
9196
gtToken = lexer.GetNextTokenInType("GT")
92-
assert(gtToken != None and gtToken.type == "GT" and gtToken.column != prevGtTokenColumn)
97+
assert(gtToken is not None and gtToken.type ==
98+
"GT" and gtToken.column != prevGtTokenColumn)
9399

94100
# Expect the matching < token to be the first < token
95101
matchingLtToken = lexer.GetPrevMatchingLT()
96-
assert(matchingLtToken != None and matchingLtToken.type == "LT")
102+
assert(matchingLtToken is not None and matchingLtToken.type == "LT")
97103
assert(matchingLtToken.column == ltToken.column)
98104

99105
def testGetPrevMatchingLTWithInner(self):
100-
lexer = nsiqcppstyle_checker.CppLexerNavigator("a.cpp", "std::set<std::map<int, float>> m;")
106+
lexer = nsiqcppstyle_checker.CppLexerNavigator(
107+
"a.cpp", "std::set<std::map<int, float>> m;")
101108
# This step resolves comments and some token types like FUNCTION
102109
nsiqcppstyle_checker.ContructContextInfo(lexer)
103-
lexer.Reset();
110+
lexer.Reset()
104111

105112
# Get the first < token
106113
ltToken = lexer.GetNextTokenInType("LT")
107-
assert(ltToken != None and ltToken.type == "LT" and ltToken.column == 9)
114+
assert(ltToken is not None and ltToken.type ==
115+
"LT" and ltToken.column == 9)
108116

109117
# Get the >> token
110118
gtToken = lexer.GetNextTokenInType("RSHIFT")
111-
assert(gtToken != None and gtToken.type == "RSHIFT")
119+
assert(gtToken is not None and gtToken.type == "RSHIFT")
112120

113121
# Expect the matching < token to be the first < token
114122
matchingLtToken = lexer.GetPrevMatchingLT()
115-
assert(matchingLtToken != None and matchingLtToken.type == "LT")
123+
assert(matchingLtToken is not None and matchingLtToken.type == "LT")
116124
assert(matchingLtToken.column == ltToken.column)
117125

118126
def test2(self):

0 commit comments

Comments
 (0)