Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py

changeset 4506
57666e501a42
parent 4444
4867c8189b62
child 4541
e8ddd9d76414
equal deleted inserted replaced
4505:3b437ae320bd 4506:57666e501a42
10 import sys 10 import sys
11 import multiprocessing 11 import multiprocessing
12 12
13 import pep8 13 import pep8
14 from NamingStyleChecker import NamingStyleChecker 14 from NamingStyleChecker import NamingStyleChecker
15 from McCabeChecker import McCabeChecker
16 15
17 # register the name checker 16 # register the name checker
18 pep8.register_check(NamingStyleChecker, NamingStyleChecker.Codes) 17 pep8.register_check(NamingStyleChecker, NamingStyleChecker.Codes)
19 18
20 from DocStyleChecker import DocStyleChecker 19 from DocStyleChecker import DocStyleChecker
20 from MiscellaneousChecker import MiscellaneousChecker
21 from McCabeChecker import McCabeChecker
21 22
22 23
23 def initService(): 24 def initService():
24 """ 25 """
25 Initialize the service and return the entry point. 26 Initialize the service and return the entry point.
187 @return tuple of stats (dict) and results (tuple for each found violation 188 @return tuple of stats (dict) and results (tuple for each found violation
188 of style (tuple of lineno (int), position (int), text (str), ignored 189 of style (tuple of lineno (int), position (int), text (str), ignored
189 (bool), fixed (bool), autofixing (bool), fixedMsg (str))) 190 (bool), fixed (bool), autofixing (bool), fixedMsg (str)))
190 """ 191 """
191 (excludeMessages, includeMessages, repeatMessages, fixCodes, noFixCodes, 192 (excludeMessages, includeMessages, repeatMessages, fixCodes, noFixCodes,
192 fixIssues, maxLineLength, hangClosing, docType, maxComplexity, errors, 193 fixIssues, maxLineLength, hangClosing, docType, maxComplexity,
193 eol, encoding, backup) = args 194 miscellaneousArgs, errors, eol, encoding, backup) = args
194 195
195 stats = {} 196 stats = {}
196 197
197 if fixIssues: 198 if fixIssues:
198 from CodeStyleFixer import CodeStyleFixer 199 from CodeStyleFixer import CodeStyleFixer
240 source, filename, select, ignore, [], repeatMessages, 241 source, filename, select, ignore, [], repeatMessages,
241 maxLineLength=maxLineLength, docType=docType) 242 maxLineLength=maxLineLength, docType=docType)
242 docStyleChecker.run() 243 docStyleChecker.run()
243 stats.update(docStyleChecker.counters) 244 stats.update(docStyleChecker.counters)
244 errors += docStyleChecker.errors 245 errors += docStyleChecker.errors
246
247 # miscellaneous additional checks
248 miscellaneousChecker = MiscellaneousChecker(
249 source, filename, select, ignore, [], repeatMessages,
250 miscellaneousArgs)
251 miscellaneousChecker.run()
252 stats.update(miscellaneousChecker.counters)
253 errors += miscellaneousChecker.errors
245 254
246 # check code complexity iaw. McCabe 255 # check code complexity iaw. McCabe
247 mccabeChecker = McCabeChecker( 256 mccabeChecker = McCabeChecker(
248 source, filename, select, ignore, maxComplexity) 257 source, filename, select, ignore, maxComplexity)
249 mccabeChecker.run() 258 mccabeChecker.run()

eric ide

mercurial