def NotifyReviewEvent(self, request, context): print("got review request {}".format(request)) comments = [] # client connection to DataServe with create_channel(data_srv_addr) as channel: stub = pb.DataStub(channel) changes = stub.GetChanges( pb.ChangesRequest(head=request.commit_revision.head, base=request.commit_revision.base, want_contents=False, want_uast=True, exclude_vendored=True)) for change in changes: if not change.HasField("head"): continue print("analyzing '{}' in {}".format(change.head.path, change.head.language)) fns = list(filter_uast(change.head.uast, "//*[@roleFunction]")) text = "language: {}, functions: {}".format( change.head.language, len(fns)) comments.append( pb.Comment(file=change.head.path, line=0, text=text)) return pb.EventResponse(analyzer_version=version, comments=comments)
def notify_review_event(self, request, context): logger.debug("got review request %s", request) comments = [] # client connection to DataServe with create_channel(data_srv_addr, interceptors=[ LogUnaryClientInterceptor(log_fn), LogStreamClientInterceptor(log_fn), ]) as channel: stub = DataStub(channel) changes = stub.get_changes( context, pb.ChangesRequest(head=request.commit_revision.head, base=request.commit_revision.base, want_contents=False, want_uast=True, exclude_vendored=True, include_languages=langs)) for change in changes: if not change.HasField("head"): continue logger.debug("analyzing '%s' in %s", change.head.path, change.head.language) try: check_results = run_checks( list_checks(change.head.language.lower()), change.head.language.lower(), change.head.uast) except Exception as e: logger.exception( "Error during analyzing file '%s' in commit '%s': %s", change.head.path, request.commit_revision.head.hash, e) continue for check in check_results: for res in check_results[check]: comments.append( pb.Comment(file=change.head.path, line=(res.get("pos", {}) or {}).get("line", 0), text="{}: {}".format(check, res["msg"]))) logger.info("%d comments produced", len(comments)) return pb.EventResponse(analyzer_version=version, comments=comments)
def notify_review_event(self, request, context): print("got review request {}".format(request)) comments = [] # client connection to DataServe with create_channel(data_srv_addr, interceptors=[ LogUnaryClientInterceptor(log_fn), LogStreamClientInterceptor(log_fn), ]) as channel: stub = DataStub(channel) # Add some log fields that will be available to the data server # using `context.add_log_fields`. context.add_log_fields({ "some-string-key": "some-value", "some-int-key": 1, }) changes = stub.get_changes( context, pb.ChangesRequest(head=request.commit_revision.head, base=request.commit_revision.base, want_contents=False, want_uast=True, exclude_vendored=True)) for change in changes: if not change.HasField("head"): continue print("analyzing '{}' in {}".format(change.head.path, change.head.language)) fns = list(filter_uast(change.head.uast, "//*[@roleFunction]")) text = "language: {}, functions: {}".format( change.head.language, len(fns)) comments.append( pb.Comment(file=change.head.path, line=0, text=text)) return pb.EventResponse(analyzer_version=version, comments=comments)
def notify_push_event(self, request, context): return pb.EventResponse(analyzer_version=version)
def notify_push_event(self, request, context): return pb.EventResponse()
def NotifyReviewEvent(self, request, context): return pb.EventResponse(comments=[pb.Comment(text='review')])
def NotifyPushEvent(self, request, context): return pb.EventResponse(comments=[pb.Comment(text='push')])