Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
stats.add_metric("analysis.issues.publishable", nb_publishable)
# Publish reports about these issues
with stats.timer("runtime.reports"):
for reporter in self.reporters.values():
reporter.publish(issues, revision, task_failures)
self.index(
revision, state="done", issues=nb_issues, issues_publishable=nb_publishable
)
# Publish final HarborMaster state
self.update_status(
revision,
BuildState.Fail if nb_publishable > 0 or task_failures else BuildState.Pass,
)
)
stats.add_metric("analysis.issues.publishable", nb_publishable)
# Publish reports about these issues
with stats.timer("runtime.reports"):
for reporter in self.reporters.values():
reporter.publish(issues, revision, task_failures)
self.index(
revision, state="done", issues=nb_issues, issues_publishable=nb_publishable
)
# Publish final HarborMaster state
self.update_status(
revision,
BuildState.Fail if nb_publishable > 0 or task_failures else BuildState.Pass,
)
w.ingest_autoland(revision)
else:
w.run(revision)
except Exception as e:
# Log errors to papertrail
logger.error("Static analysis failure", revision=revision, error=e)
# Index analysis state
extras = {}
if isinstance(e, AnalysisException):
extras["error_code"] = e.code
extras["error_message"] = str(e)
w.index(revision, state="error", **extras)
# Update Harbormaster status
w.update_status(revision, state=BuildState.Fail)
# Then raise to mark task as erroneous
raise
return 0
w.ingest_autoland(revision)
else:
w.run(revision)
except Exception as e:
# Log errors to papertrail
logger.error("Static analysis failure", revision=revision, error=e)
# Index analysis state
extras = {}
if isinstance(e, AnalysisException):
extras["error_code"] = e.code
extras["error_message"] = str(e)
w.index(revision, state="error", **extras)
# Update Harbormaster status
w.update_status(revision, state=BuildState.Fail)
# Then raise to mark task as erroneous
raise
return 0
mode, build, extras = payload
logger.debug("Publishing a Phabricator build update", mode=mode, build=build)
if mode == "fail:general":
failure = UnitResult(
namespace="code-review",
name="general",
result=UnitResultState.Broken,
details="WARNING: An error occurred in the code review bot.\n\n```{}```".format(
extras["message"]
),
format="remarkup",
duration=extras.get("duration", 0),
)
self.api.update_build_target(
build.target_phid, BuildState.Fail, unit=[failure]
)
elif mode == "fail:mercurial":
failure = UnitResult(
namespace="code-review",
name="mercurial",
result=UnitResultState.Fail,
details="WARNING: The code review bot failed to apply your patch.\n\n```{}```".format(
extras["message"]
),
format="remarkup",
duration=extras.get("duration", 0),
)
self.api.update_build_target(
build.target_phid, BuildState.Fail, unit=[failure]
)
build.target_phid, BuildState.Fail, unit=[failure]
)
elif mode == "fail:mercurial":
failure = UnitResult(
namespace="code-review",
name="mercurial",
result=UnitResultState.Fail,
details="WARNING: The code review bot failed to apply your patch.\n\n```{}```".format(
extras["message"]
),
format="remarkup",
duration=extras.get("duration", 0),
)
self.api.update_build_target(
build.target_phid, BuildState.Fail, unit=[failure]
)
elif mode == "test_result":
result = UnitResult(
namespace="code-review",
name=extras["name"],
result=extras["result"],
details=extras["details"],
)
self.api.update_build_target(
build.target_phid, BuildState.Work, unit=[result]
)
elif mode == "success":
self.api.create_harbormaster_uri(
build.target_phid,