def check(path, options): if not os.path.isdir(path): sys.stderr.write('%s is not a valid folder.\n' % path) return 1 path = norm_folder(path) print('Checking for disabled unit tests in %s...\n' % path) visitor = TestCheckVisitor() checkedFiles, checkedFolders = metadata.visit(path, visitor) rootLen = len(path) if visitor.improperSummary: print(visitor.improperSummary) shouldNag = xmail.hasDest(options) or xmail.hasHostInfo(options) for dt in visitor.disabledTests: txt = '%s(%d): Warning: disabled unit test.\n' % (dt.path[rootLen:], dt.lineNum) txt += ' ' + str(dt).replace('\n', '\n ') print(txt + '\n') if visitor.improperSummary: txt += '\n\nIn addition, %d unit tests appear to be disabled but improperly documented.\n' % visitor.improperCount txt += 'Please consider fixing these as well:\n\n' txt += visitor.improperSummary if shouldNag: nag(dt, txt, options) print( 'Checked %d files in %d folders.\n Found %d correctly disabled tests.\n Found %d tests that seem to be disabled but not documented.' % (checkedFiles, checkedFolders, len( visitor.disabledTests), visitor.improperCount))
def check(path, warn=True): if not os.path.isdir(path): sys.stderr.write('%s is not a valid folder.\n' % path) return 1 path = norm_folder(path) print('Checking copyright correctness in %s...\n' % path) visitor = CopyrightCheckVisitor(warn) checkedFiles, checkedFolders = metadata.visit(path, visitor) print('Checked %d files in %d folders; found %d errors.' % (checkedFiles, checkedFolders, visitor.badCount)) return visitor.badCount, visitor.categorizedFiles
def check(folder, warn=True): if not os.path.isdir(folder): sys.stderr.write('%s is not a valid folder.\n' % folder) return 1 fc = FolderChecker(warn) checkedFiles, checkedFolders = metadata.visit(folder, DoNothingVisitor(), fc) if(fc.rtn): return 0 else: return 1
def check(path, warn=True): if not os.path.isdir(path): sys.stderr.write('%s is not a valid folder.\n' % path) return 1 path = norm_folder(path) print('Checking svn:keywords in %s...\n' % path) visitor = KeywordCheckVisitor(warn) checkedFiles, checkedFolders = metadata.visit(path, visitor) print('Checked %d files in %d folders; found %d errors.' % (checkedFiles, checkedFolders, len(visitor.badFiles))) return visitor.badFiles
def check(path, warn=True): if not os.path.isdir(path): sys.stderr.write('%s is not a valid folder.\n' % path) return 1 path = norm_folder(path) print('Checking pep8 compliance in %s...\n' % path) visitor = KeywordCheckVisitor(warn) checkedFiles, checkedFolders = metadata.visit(path, visitor) print('Checked %d files in %d folders; found %d errors.' % ( checkedFiles, checkedFolders, len(visitor.badFiles))) return visitor.badFiles
def check(folder, warn=True): if not os.path.isdir(folder): sys.stderr.write('%s is not a valid folder.\n' % folder) return 1 fc = FolderChecker(warn) checkedFiles, checkedFolders = metadata.visit(folder, DoNothingVisitor(), fc) if (fc.rtn): return 0 else: return 1
def analyze(path, prebuilt, options): if not os.path.isdir(path): sys.stderr.write('%s is not a valid folder.\n' % path) return 1 path = norm_folder(path) stats = StatsHolder(path) print('\nCompiling stats for %s...' % metadata.get_friendly_name_for_path(path)) visitor = StatsVisitor(stats) recurser = StatsRecurser(stats) visitedFiles, visitedFolders = metadata.visit(path, visitor, recurser, excludePrograms=True)#, debug=True) report = generateReport(stats) print(report) if xmail.hasDest(options): xmail.sendmail(report, subject='code stats for %s' % metadata.get_friendly_name_for_path(path), sender='Code Stat Scanner <*****@*****.**>', options=options)
def __init__(self, root, testing=False): self._svnInfo = None self.trans = {} self.src = {} self.byLocale = {} self.pathsByComponent = {} self.possibleMisses = {} self.formatErrors = {} root = ioutil.norm_folder(root) self.conf = metadata.Conf(root, report=False) if type(root) == _STR_TYPE: root = unicode(root, "utf-8") self.root = root if not testing: fileCount, folderCount = metadata.visit(self.root, visitor=self, recurser=self, report=False) self._connect()
def test_visit(self): class Visitor: def __init__(self): self.visited = [] def visit(self, folder, item, relativePath): #print('visited %s' % item) self.visited.append(item) visitor = Visitor() path = os.path.join(MY_DATA_DIR, 'visit_test') visitedFiles, visitedFolders = metadata.visit(path, visitor, report=False) self.assertEqual(6, visitedFiles) self.assertEqual(3, visitedFolders) self.assertTrue('x.txt' in visitor.visited) self.assertTrue('c.txt' in visitor.visited) self.assertFalse('d.txt' in visitor.visited)
def check(path, warn=True): if not os.path.isdir(path): sys.stderr.write('%s is not a valid folder.\n' % path) return 1 path = norm_seps(os.path.abspath(path), trailing=True) print('Checking for active console code in %s...\n' % path) visitor = JsDebugCheckVisitor(warn) checkedFiles, checkedFolders = metadata.visit(path, visitor) if visitor.badCount > 0: for key in visitor.categorizedFiles.keys(): badFile = os.path.join(path, key) f = file(badFile).readlines() print badFile for line in visitor.categorizedFiles[key]: print ('%s - %s' % (line, f[line-1])) print('Checked %d files in %d folders; found %d errors.' % (checkedFiles, checkedFolders, visitor.badCount)) return visitor.badCount, visitor.categorizedFiles
def __init__(self, root, testing=False): self._svnInfo = None self.trans = {} self.src = {} self.byLocale = {} self.pathsByComponent = {} self.possibleMisses = {} self.formatErrors = {} root = ioutil.norm_folder(root) self.conf = metadata.Conf(root, report=False) if type(root) == _STR_TYPE: root = unicode(root, 'utf-8') self.root = root if not testing: fileCount, folderCount = metadata.visit(self.root, visitor=self, recurser=self, report=False) self._connect()
def analyze(path, prebuilt, options): if not os.path.isdir(path): sys.stderr.write('%s is not a valid folder.\n' % path) return 1 path = norm_folder(path) stats = StatsHolder(path) print('\nCompiling stats for %s...' % metadata.get_friendly_name_for_path(path)) visitor = StatsVisitor(stats) recurser = StatsRecurser(stats) visitedFiles, visitedFolders = metadata.visit( path, visitor, recurser, excludePrograms=True) #, debug=True) report = generateReport(stats) print(report) if xmail.hasDest(options): xmail.sendmail(report, subject='code stats for %s' % metadata.get_friendly_name_for_path(path), sender='Code Stat Scanner <*****@*****.**>', options=options)
def check(path, options): if not os.path.isdir(path): sys.stderr.write('%s is not a valid folder.\n' % path) return 1 path = norm_folder(path) print('Checking for disabled unit tests in %s...\n' % path) visitor = TestCheckVisitor() checkedFiles, checkedFolders = metadata.visit(path, visitor) rootLen = len(path) if visitor.improperSummary: print(visitor.improperSummary) shouldNag = xmail.hasDest(options) or xmail.hasHostInfo(options) for dt in visitor.disabledTests: txt = '%s(%d): Warning: disabled unit test.\n' % (dt.path[rootLen:], dt.lineNum) txt += ' ' + str(dt).replace('\n', '\n ') print(txt + '\n') if visitor.improperSummary: txt += '\n\nIn addition, %d unit tests appear to be disabled but improperly documented.\n' % visitor.improperCount txt += 'Please consider fixing these as well:\n\n' txt += visitor.improperSummary if shouldNag: nag(dt, txt, options) print('Checked %d files in %d folders.\n Found %d correctly disabled tests.\n Found %d tests that seem to be disabled but not documented.' % (checkedFiles, checkedFolders, len(visitor.disabledTests), visitor.improperCount))