def diag_report(cls, diag): trace, cond, always_true = diag return (DiagnosticPosition.from_node(cond), "'{}' is always {}".format(format_text_for_output(cond.text), "true" if always_true else "false"), TestAlwaysTrue if always_true else TestAlwaysFalse, cls.HIGH)
def diag_report(cls, diag): fst_line = diag[0].sloc_range.start.line return ( DiagnosticPosition.from_node(diag[1]), "test duplicated with line {}".format(fst_line), TestAlwaysFalse, cls.HIGH )
def diag_report(cls, diag): op, fst_val, snd_val = diag return ( DiagnosticPosition.from_node(op), "expression always true: '{}' /= {} or {}".format( op.text, fst_val.text, snd_val.text ), TestAlwaysTrue, cls.HIGH )
def diag_report(cls, block): if len(block.nodes) > 0: start_line = block.start_node().sloc_range.start.line end_line = block.end_node().sloc_range.end.line if start_line == end_line: message = "unreachable code" else: message = "unreachable code (until line {})".format(end_line) return (DiagnosticPosition.from_node(block.start_node()), message, KindDeadCode, cls.HIGH)
def diag_report(cls, diag): trace, purpose, precise = diag if precise: frmt = "{} failure" else: frmt = "(potential) {} failure" return (DiagnosticPosition.from_node(purpose.orig_call), frmt.format(purpose.contract_name), KindContractCheck, cls.gravity(precise))
def diag_report(cls, diag): fst_line = diag[0].sloc_range.start.line return ( DiagnosticPosition.from_node(diag[1]), "'{}' duplicated with line {}".format( format_text_for_output(diag[0].text), fst_line ), SameOperands, cls.HIGH )
def diag_report(cls, diag): trace, derefed, precise = diag if ('orig_node' in derefed.data and derefed.data.orig_node is not None): if precise: frmt = "null dereference of '{}'" else: frmt = "(potential) null dereference of '{}'" return (DiagnosticPosition.from_node(derefed.data.orig_node), frmt.format( format_text_for_output(derefed.data.orig_node.text)), AccessCheck, cls.gravity(precise))
def diag_report(cls, diag): trace, purpose, precise = diag if ('orig_node' in purpose.accessed_expr.data and purpose.accessed_expr.data.orig_node is not None): if precise: frmt = "invalid field '{}'" else: frmt = "(potential) invalid field '{}'" return (DiagnosticPosition.from_node( purpose.accessed_expr.data.orig_node), frmt.format(purpose.field_name, purpose.discr_name), DiscriminantCheck, cls.gravity(precise))
def diag_report(cls, diag): return (DiagnosticPosition.from_node(diag), "operands of '{}' are identical".format(diag.f_op.text), KindSameOperands, cls.HIGH)
def diag_report(cls, diag): fst_line = diag[0].sloc_range.start.line return (DiagnosticPosition.from_node(diag[1]), 'code duplicated with line {}'.format(fst_line) + diag[2], CodeDuplicated, cls.HIGH)