github.com/mistwind/reviewdog@v0.0.0-20230322024206-9cfa11856d58/proto/rdf/reviewdog.proto (about) 1 // Reviewdog Diagnostic Format 2 // 3 // Reviewdog Diagnostic Format defines generic machine readable message 4 // structures which represents a result of diagnostic tool such as a compiler 5 // or a linter. 6 // 7 // The idea behind the Reviewdog Diagnostic Format is to standardize 8 // the protocol for how diagnostic tools (e.g. compilers, linters, etc..) and 9 // development tools (e.g. editors, reviewdog, etc..) communicate. 10 // 11 // Wire formats of Reviewdog Diagnostic Format. 12 // - rdjsonl: JSON Lines (http://jsonlines.org/) of the `Diagnostic` message. 13 // - rdjson: JSON format of the `DiagnosticResult` message. 14 15 syntax = "proto3"; 16 package reviewdog.rdf; 17 18 option go_package = "github.com/mistwind/reviewdog/proto/rdf"; 19 20 // Result of diagnostic tool such as a compiler or a linter. 21 // It's intended to be used as top-level structured format which represents a 22 // whole result of a diagnostic tool. 23 message DiagnosticResult { 24 repeated Diagnostic diagnostics = 1; 25 26 // The source of diagnostics, e.g. 'typescript' or 'super lint'. 27 // Optional. 28 Source source = 2; 29 30 // This diagnostics' overall severity. 31 // Optional. 32 Severity severity = 3; 33 } 34 35 // Represents a diagnostic, such as a compiler error or warning. 36 // It's intended to be used as structured format which represents a 37 // diagnostic and can be used as stream of input/output such as jsonl. 38 // This message should be self-contained to report a diagnostic. 39 message Diagnostic { 40 // The diagnostic's message. 41 string message = 1; 42 43 // Location at which this diagnostic message applies. 44 Location location = 2; 45 46 // This diagnostic's severity. 47 // Optional. 48 Severity severity = 3; 49 50 // The source of this diagnostic, e.g. 'typescript' or 'super lint'. 51 // Optional. 52 Source source = 4; 53 54 // This diagnostic's rule code. 55 // Optional. 56 Code code = 5; 57 58 // Suggested fixes to resolve this diagnostic. 59 // Optional. 60 repeated Suggestion suggestions = 6; 61 62 // Experimental: If this diagnostic is converted from other formats, 63 // original_output represents the original output which corresponds to this 64 // diagnostic. 65 // Optional. 66 string original_output = 7; 67 } 68 69 enum Severity { 70 UNKNOWN_SEVERITY = 0; 71 ERROR = 1; 72 WARNING = 2; 73 INFO = 3; 74 } 75 76 message Location { 77 // File path. It could be either absolute path or relative path. 78 string path = 2; 79 80 // Range in the file path. 81 // Optional. 82 Range range = 3; 83 } 84 85 // A range in a text document expressed as start and end positions. 86 87 // The end position is *exclusive*. It might be a bit unnatural for you or for 88 // some diagnostic tools to use exclusive range, but it's necessary to represent 89 // zero-width range especially when using it in Suggestion context to support 90 // code insertion. 91 // Example: "14" in "haya14busa" 92 // start: { line: 1, column: 5 } 93 // end: { line: 1, column: 7 } # <= Exclusive 94 // 95 // |h|a|y|a|1|4|b|u|s|a| 96 // 1 2 3 4 5 6 7 8 9 0 1 97 // ^---^ 98 // haya14busa 99 // ^^ 100 // 101 // If you want to specify a range that 102 // contains a line including the line ending character(s), then use an end 103 // position denoting the start of the next line. 104 // Example: 105 // start: { line: 5, column: 23 } 106 // end: { line: 6, column: 1 } 107 // 108 // If both start and end position omit column value, it's 109 // handled as linewise and the range includes end position (line) as well. 110 // Example: 111 // start: { line: 5 } 112 // end: { line: 6 } 113 // The above example represents range start from line 5 to the end of line 6 114 // including EOL. 115 // 116 // Examples for line range: 117 // Text example. <line>|<line content>(line breaking) 118 // 1|abc\r\n 119 // 2|def\r\n 120 // 3|ghi\r\n 121 // 122 // start: { line: 2 } 123 // => "abc" 124 // 125 // start: { line: 2 } 126 // end: { line: 2 } 127 // => "abc" 128 // 129 // start: { line: 2 } 130 // end: { line: 3 } 131 // => "abc\r\ndef" 132 // 133 // start: { line: 2 } 134 // end: { line: 3, column: 1 } 135 // => "abc\r\n" 136 137 // start: { line: 2, column: 1 } 138 // end: { line: 2, column: 4 } 139 // => "abc" (without line-break) 140 message Range { 141 // Required. 142 Position start = 1; 143 144 // end can be omitted. Then the range is handled as zero-length (start == end). 145 // Optional. 146 Position end = 2; 147 } 148 149 message Position { 150 // Line number, starting at 1. 151 // Optional. 152 int32 line = 1; 153 154 // Column number, starting at 1 (byte count in UTF-8). 155 // Example: 'a𐐀b' 156 // The column of a: 1 157 // The column of 𐐀: 2 158 // The column of b: 6 since 𐐀 is represented with 4 bytes in UTF-8. 159 // Optional. 160 int32 column = 2; 161 } 162 163 // Suggestion represents a suggested text manipulation to resolve a diagnostic 164 // problem. 165 // 166 // Insert example ('hayabusa' -> 'haya15busa'): 167 // range { 168 // start { 169 // line: 1 170 // column: 5 171 // } 172 // end { 173 // line: 1 174 // column: 5 175 // } 176 // } 177 // text: 15 178 // |h|a|y|a|b|u|s|a| 179 // 1 2 3 4 5 6 7 8 9 180 // ^--- insert '15' 181 // 182 // Update example ('haya15busa' -> 'haya14busa'): 183 // range { 184 // start { 185 // line: 1 186 // column: 5 187 // } 188 // end { 189 // line: 1 190 // column: 7 191 // } 192 // } 193 // text: 14 194 // |h|a|y|a|1|5|b|u|s|a| 195 // 1 2 3 4 5 6 7 8 9 0 1 196 // ^---^ replace with '14' 197 message Suggestion { 198 // Range at which this suggestion applies. 199 // To insert text into a document create a range where start == end. 200 Range range = 1; 201 202 // A suggested text which replace the range. 203 // For delete operations use an empty string. 204 string text = 2; 205 } 206 207 message Source { 208 // A human-readable string describing the source of diagnostics, e.g. 209 // 'typescript' or 'super lint'. 210 string name = 1; 211 // URL to this source. 212 // Optional. 213 string url = 2; 214 } 215 216 message Code { 217 // This rule's code/identifier. 218 string value = 1; 219 220 // A URL to open with more information about this rule code. 221 // Optional. 222 string url = 2; 223 }