commit | c9b3edb0de0c4816eadfedd3ef3c9161093a8fc1 | [log] [tgz] |
---|---|---|
author | Oliver Newman <olivernewman@google.com> | Sat Sep 02 00:02:57 2023 +0000 |
committer | CQ Bot <fuchsia-internal-scoped@luci-project-accounts.iam.gserviceaccount.com> | Sat Sep 02 00:02:57 2023 +0000 |
tree | 9d31cb0312173cc3ffef686975a06f9671ae44f6 | |
parent | a809cc033723c140961848298875f404c3195cf0 [diff] |
[engine] Add ctx.io.tempfile method This will be useful most notably for integrating with formatters that don't have a dry-run mode. shac requires that formatter checks emit the formatted result as a finding rather than writing the result at runtime, so formatters that lack a dry run mode can now do: def foo_fmt(ctx): for path in ctx.scm.affected_files(): original = ctx.io.read_file(path) temp = ctx.io.tempfile(ctx.io.read_file(path)) ctx.os.exec(["foo", "fmt", temp]) new = ctx.io.read_file(temp) if new != original: ctx.emit.finding( filepath=path, replacements=[ctx.io.read_file(temp)], ) Change-Id: Ic6438a16a263f4250cb0c276fa988f89ac028101 Reviewed-on: https://fuchsia-review.googlesource.com/c/shac-project/shac/+/910595 Reviewed-by: Anthony Fandrianto <atyfto@google.com> Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com> Fuchsia-Auto-Submit: Oliver Newman <olivernewman@google.com>
Shac (Scalable Hermetic Analysis and Checks) is a unified and ergonomic tool and framework for writing and running static analysis checks.
Shac checks are written in Starlark.
go install go.fuchsia.dev/shac-project/shac@latest shac check shac doc shac.star | less
Planned features/changes, in descending order by priority:
shac.textproto
shac.star
files.shac
cache directory that checks can write toctx.scm
glob
arguments to ctx.scm.{all,affected}_files()
functions for easier filtering⚠ The source of truth is at https://fuchsia.googlesource.com/shac-project/shac.git and uses Gerrit for code review.
See CONTRIBUTING.md to submit changes.