SarifIt - 静态分析结果互换格式构建器
轻量级[SARIF]构建器库,允许您的工具生成统一的代码质量报告.
特征
- 简单使用
- 创建 SARIF 对象的折叠器
- 与[SARIF 2.1.0]相配
使用量
定义新的代码质量分析工具
import * as sarif from "@dev-build-deploy/sarif-it";
const tool = new sarif.Tool("code-scanner")
.organization("dev-build-deploy")
.version("0.0.0")
.informationUri("https://github.com/dev-build-deploy/sarif-it#README.md");
const missingDocsRule = new sarif.Rule("MissingDocumentation")
.name("Missing Documentation")
.shortDescription("All repositories must contain a README.md containing basic instructions.")
.fullDescription({
text: "As documentation is important, we expect all repositories to contain at least a README.md file.",
markown: "As documentation is *important*, we expect **all** repositories to contain *at least* a `README.md` file."
})
.helpUri("https://github.com/dev-build-deploy/sarif-it#README.md");
tool.addRule(missingDocsRule);
创建代码质量分析报告
假设我们已经定义了代码质量分析工具(这里(三);
import * as sarif from "@dev-build-deploy/sarif-it";
const log = new sarif.Log()
.addRun(new sarif.Run(tool)); // NOTE: Example for creating a `tool` can be found in the previous chapter
const result = new sarif.Result("Missing Documentation")
.ruleId("MissingDocumentation")
.level("error")
.addLocation({
physicalLocation: {
artifactLocation: {
uri: "./README.md",
},
},
})
log.get("runs")[0].addResult(result);
捐款
有建议的话 sarif-it 可以改进, 或者想要报告一个错误, 打开一个问题! 我们很乐意所有的贡献.
更多,请检查 贡献指南。 。 。 .
许可证
- 麻省理工学院 2023 凯文·德·钟 <[email protected]>