From 54d9938f07fbc287f126c38000a60b9174ea92ea Mon Sep 17 00:00:00 2001 From: Daniel D'Avella Date: Fri, 5 Apr 2024 12:04:05 -0400 Subject: [PATCH] Associate findings with changes + unfixed --- codetf.schema.json | 107 +++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 47 deletions(-) diff --git a/codetf.schema.json b/codetf.schema.json index 9180bfe..36d85f2 100644 --- a/codetf.schema.json +++ b/codetf.schema.json @@ -97,6 +97,11 @@ "description": "The changes for a given codemod", "items": { "$ref": "#/definitions/changeset" }, "minItems": 0 + }, + "unfixed": { + "type": "array", + "description": "A set of file paths for files that the tool failed to fix", + "items": { "$ref": "#/definitions/unfixedFinding" } } }, "required": ["codemod", "summary", "description", "changeset"] @@ -152,6 +157,29 @@ "required": ["path", "diff", "changes"] }, + "unfixed": { + "type": "object", + "properties": { + "path": { + "type": "string", + "description": "The path of the file (relative to the directory) that was not fixed" + }, + "lineNumber": { + "type": "integer", + "description": "The line number that was not fixed" + }, + "reason": { + "type": "string", + "description": "A human-readable description of the reason the file was not fixed" + }, + "finding": { + "$ref": "#/definitions/detector/finding", + "description": "The finding that was not fixed at this location" + } + }, + "required": ["path", "reason", "finding"] + }, + "change": { "type": "object", "properties": { @@ -177,6 +205,10 @@ "type": "array", "description": "The package actions that were needed to support changes to the file", "items": { "$ref": "#/definitions/packageAction" } + }, + "finding": { + "$ref": "#/definitions/detector/fixedFinding", + "description": "The finding that was fixed at this location" } }, "required": ["lineNumber", "diffSide"] @@ -209,19 +241,10 @@ "name": { "type": "string", "description": "Name of the tool that detected the issue" - }, - "rule": { - "$ref": "#/definitions/detector/rule", - "description": "The rule that detected the issue" - }, - "findings": { - "type": "array", - "items": { "$ref": "#/definitions/detector/finding" }, - "maxItems": 20 } }, "additionalProperties": true, - "required": ["name", "rule", "findings"] + "required": ["name"] }, "detector": { @@ -232,48 +255,38 @@ "type": "string", "description": "A unique identifier for the finding (e.g. 'guid' from SARIF)" }, - "fixed": { - "type": "boolean", - "description": "Whether the finding was fixed by the codemod" + "rule": { + "$ref": "#/definitions/detector/rule", + "description": "The rule that detected the issue" + } + }, + "additionalProperties": true, + "required": ["id", "rule", "path"] + }, + "fixedFinding": { + "$ref": "#/definitions/detector/finding", + "additionalProperties": true, + // TODO: can we do it this way?? + "required": ["id", "rule"] + }, + "unfixedFinding": { + "$ref": "#/definitions/detector/finding", + "properties": { + "path": { + "type": "string", + "description": "The path of the file (relative to the directory) that was not fixed" + }, + "lineNumber": { + "type": "integer", + "description": "The line number that was not fixed" }, "reason": { - "type": "array", - "items": { - "failure": { - "type": "object", - "properties": { - "description": { - "type": "string", - "description": "A human-readable description of the reason the fix failed at this location" - }, - "path": { - "type": "string", - "description": "Path of the file where the fix failed to apply" - }, - "line": { - "type": "integer", - "description": "(Optional) line number where the fix failed to apply" - }, - "snippet": { - "type": "string", - "description": "(Optional) snippet of code that we failed to fix" - } - }, - "required": ["description", "path"], - "additionalProperties": true - } - }, - "minItems": 1 + "type": "string", + "description": "A human-readable description of the reason the file was not fixed" } }, "additionalProperties": true, - "required": ["id", "fixed"], - "if": { - "properties": { - "fixed": { "boolean": false } - }, - "required": ["reason"] - } + "required": ["id", "rule", "path", "reason"] }, "rule": { "type": "object",