def do_rulecheck(module, rules, metrics) -> Tuple[int, int]: ec = 0 wc = 0 first = True for rule in rules: rule = rule(module, args) if verbosity.value > Verbosity.HIGH.value: printer.white("Checking rule " + rule.name) rule.check() # count errors if rule.hasErrors(): ec += rule.errorCount if rule.hasWarnings: wc += rule.warningCount() if args.nowarnings and not rule.hasErrors(): continue if rule.hasOutput(): if first: printer.green( "Checking footprint '{fp}':".format(fp=module.name)) first = False printer.yellow("Violating " + rule.name + " - " + rule.url, indentation=2) rule.processOutput(printer, verbosity, args.silent) elif rule.hasErrors(): if args.log: lib_name = os.path.basename(os.path.dirname( module.filename)).replace(".pretty", "") logError(args.log, rule.name, lib_name, module.name) if args.fix: if args.fixmore and rule.needsFixMore: rule.fixmore() rule.fix() rule.processOutput(printer, args.verbose, args.silent) rule.recheck() # No messages? if first: if not args.silent: printer.green( "Checking footprint '{fp}' - No errors".format(fp=module.name)) if ((args.fix or args.fixmore) and ec > 0) or args.rotate != 0: module.save() return (ec, wc)
def do_rulecheck(module, rules, metrics): ec = 0 wc = 0 no_warnings = True output = [] first = True for rule in rules: rule = rule(module,args) if verbosity > 2: printer.white("Checking rule " + rule.name) rule.check() # count errors if rule.hasErrors(): ec += rule.errorCount if rule.hasWarnings: wc += rule.warningCount() if args.nowarnings and not rule.hasErrors(): continue if rule.hasOutput(): if first: printer.green("Checking footprint '{fp}':".format(fp=module.name)) first = False printer.yellow("Violating " + rule.name, indentation=2) rule.processOutput(printer, args.verbose, args.silent) elif rule.hasErrors(): if args.log: logError(args.log, rule.name, lib_name, module.name) if args.fix: if args.fixmore and rule.needsFixMore: rule.fixmore() rule.fix() rule.processOutput(printer, args.verbose, args.silent) rule.recheck() # No messages? if first: if not args.silent: printer.green("Checking footprint '{fp}' - No errors".format(fp=module.name)) if ((args.fix or args.fixmore) and ec > 0) or args.rotate!=0: module.save() return (ec, wc)
def do_rulecheck(self, symbol) -> Tuple[int, int]: symbol_error_count = 0 symbol_warning_count = 0 first = True for rule in self.rules: rule.footprints_dir = self.footprints rule = rule(symbol) if self.verbosity.value > Verbosity.HIGH.value: self.printer.white("Checking rule " + rule.name) rule.check() if self.no_warnings and not rule.hasErrors(): continue if rule.hasOutput(): if first: self.printer.green("Checking symbol '{lib}:{sym}':".format( lib=symbol.libname, sym=symbol.name)) first = False self.printer.yellow("Violating " + rule.name + " - " + rule.url, indentation=2) rule.processOutput(self.printer, self.verbosity, self.silent) if rule.hasErrors(): if self.log: logError(self.log, rule.name, symbol.libname, symbol.name) # increment the number of violations symbol_error_count += rule.errorCount symbol_warning_count += rule.warningCount() # No messages? if first: if not self.silent: self.printer.green("Checking symbol '{lib}:{sym}':".format( lib=symbol.libname, sym=symbol.name)) # done checking the symbol # count errors and update metrics self.metrics.append("{l}.{p}.warnings {n}".format( l=symbol.libname, p=symbol.name, n=symbol_warning_count)) self.metrics.append("{l}.{p}.errors {n}".format(l=symbol.libname, p=symbol.name, n=symbol_error_count)) return (symbol_error_count, symbol_warning_count)
def do_rulecheck(symbol, rules, metrics): symbol_error_count = 0 symbol_warning_count = 0 first = True for rule in rules: rule.footprints_dir = args.footprints if args.footprints else None rule = rule(symbol) if verbosity > 2: printer.white("Checking rule " + rule.name) rule.check() if args.nowarnings and not rule.hasErrors(): continue if rule.hasOutput(): if first: printer.green( "Checking symbol '{sym}':".format(sym=symbol.name)) first = False printer.yellow("Violating " + rule.name, indentation=2) rule.processOutput(printer, args.verbose, args.silent) if rule.hasErrors(): if args.log: logError(args.log, rule.name, lib_name, symbol.name) # increment the number of violations symbol_error_count += rule.errorCount symbol_warning_count += rule.warningCount() # No messages? if first: if not args.silent: printer.green( "Checking symbol '{sym}' - No errors".format(sym=symbol.name)) # done checking the symbol # count errors and update metrics metrics.append('{l}.{p}.warnings {n}'.format(l=symbol.libname, p=symbol.name, n=symbol_warning_count)) metrics.append('{l}.{p}.errors {n}'.format(l=symbol.libname, p=symbol.name, n=symbol_error_count)) return (symbol_error_count, symbol_warning_count)
if rule.hasOutput(): if first: printer.green( "Checking symbol '{sym}':".format(sym=component.name)) first = False printer.yellow("Violating " + rule.name, indentation=2) rule.processOutput(printer, verbosity, args.silent) # Specifically check for errors if rule.hasErrors(): n_violations += rule.errorCount if args.log: logError(args.log, rule.name, lib_name, component.name) if args.fix: rule.fix() rule.processOutput(printer, verbosity, args.silent) rule.recheck() # No messages? if first: if not args.silent: printer.green("Checking symbol '{sym}' - No errors".format( sym=component.name)) # check the number of violations if n_violations > 0: exit_code += 1
first = False printer.yellow("Violating " + rule.name, indentation=2) rule.processOutput(printer, args.verbose, args.silent) if args.fixmore and rule.needsFixMore: if rule.hasErrors(): n_violations += rule.errorCount rule.fixmore() rule.fix() rule.processOutput(printer, args.verbose, args.silent) elif rule.hasErrors(): n_violations += rule.errorCount if args.log: logError(args.log, rule.name, lib_name, module.name) if args.fix: rule.fix() rule.processOutput(printer, args.verbose, args.silent) rule.recheck() # No messages? if first: if not args.silent: printer.green( "Checking footprint '{fp}' - No errors".format(fp=module.name)) # increment the number of violations if n_violations > 0: exit_code += 1
continue if rule.hasOutput(): if first: printer.green("Checking symbol '{sym}':".format(sym=component.name)) first = False printer.yellow("Violating " + rule.name, indentation=2) rule.processOutput(printer, verbosity, args.silent) # Specifically check for errors if rule.hasErrors(): n_violations += rule.errorCount if args.log: logError(args.log, rule.name, lib_name, component.name) if args.fix: rule.fix() rule.processOutput(printer, verbosity, args.silent) rule.recheck() # No messages? if first: if not args.silent: printer.green("Checking symbol '{sym}' - No errors".format(sym=component.name)) # check the number of violations if n_violations > 0: exit_code += 1 n_allviolations=n_allviolations+n_violations
if args.fixmore and rule.needsFixMore: if rule.hasErrors(): n_violations += rule.errorCount if rule.hasWarnings: n_violations += rule.warningCount() rule.fixmore() rule.fix() rule.processOutput(printer, args.verbose, args.silent) elif rule.hasErrors(): n_violations += rule.errorCount if args.fixmore and rule.hasWarnings: n_violations += rule.warningCount() if args.log: logError(args.log, rule.name, lib_name, module.name) if args.fix: rule.fix() rule.processOutput(printer, args.verbose, args.silent) rule.recheck() # No messages? if first: if not args.silent: printer.green("Checking footprint '{fp}' - No errors".format(fp=module.name)) # increment the number of violations if n_violations > 0: exit_code += 1