aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-protocol/src/main/protobuf/scanner_report.proto
blob: dda0893f219311ce9294f14f4f75341e67614f4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
// SonarQube, open source software quality management tool.
// Copyright (C) 2008-2016 SonarSource
// mailto:contact AT sonarsource DOT com
//
// SonarQube is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// SonarQube is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.


// IMPORTANT
// This is beta version of specification. It will evolve during next
// releases and is not forward-compatible yet.

syntax = "proto3";

import "constants.proto";

option java_package = "org.sonar.scanner.protocol.output";
option optimize_for = SPEED;

message Metadata {
  int64 analysis_date = 1;
  reserved 2; // organization drop
  // TODO should we keep this project_key here or not ? Because it's a duplication of Component.key
  string project_key = 3;

  reserved 4; // deprecated_branch (legacy branches feature)

  int32 root_component_ref = 5;
  bool cross_project_duplication_activated = 6;
  map<string, QProfile> qprofiles_per_language = 7;
  map<string, Plugin> plugins_by_key = 8;

  string branch_name = 9;
  BranchType branch_type = 10;
  string reference_branch_name = 11;

  string relative_path_from_scm_root = 12;
  string scm_revision_id = 13;

  string pull_request_key = 14;
  map<string, string> modules_project_relative_path_by_key = 15;

  string projectVersion = 16;
  string buildString = 17;

  string target_branch_name = 18;

  reserved 19; // forkDate (no longer used)

  map<string, int32> not_analyzed_files_by_language = 20;

  string new_code_reference_branch = 21;

  message QProfile {
    string key = 1;
    string name = 2;
    string language = 3;
    int64 rulesUpdatedAt = 4;
  }

  message Plugin {
    string key = 1;
    int64 updatedAt = 2;
  }

  enum BranchType {
    UNSET = 0;
    BRANCH = 1;
    PULL_REQUEST = 2;
  }
}

message ContextProperty {
  string key = 1;
  string value = 2;
}

message ActiveRule {
  string rule_repository = 1;
  string rule_key = 2;
  Severity severity = 3;
  map<string,string> params_by_key = 4;
  int64 createdAt = 5;
  int64 updatedAt = 6;
  string q_profile_key = 7;
}

message ComponentLink {
  ComponentLinkType type = 1;
  string href = 2;

  enum ComponentLinkType {
    UNSET = 0;
    HOME = 1;
    SCM = 2;
    // SCM_DEV is no more set since 7.1. See SONAR-10299
    IGNORED_SCM_DEV = 3;
    ISSUE = 4;
    CI = 5;
  }
}

message Component {
  int32 ref = 1;

  string name = 3;
  ComponentType type = 4;
  bool is_test = 5;
  string language = 6;
  repeated int32 child_ref = 7 [packed = true];
  repeated ComponentLink link = 8;
  // Only available on PROJECT and MODULE types
  // TODO rename this property -> moduleKey ?
  string key = 10;
  // Only available on FILE type, should always be at least 1
  int32 lines = 11;
  // Only available on PROJECT and MODULE types
  string description = 12;
  FileStatus status = 13;

  // Path relative to project base directory
  string project_relative_path = 14;

  enum ComponentType {
    UNSET = 0;
    PROJECT = 1;
    MODULE = 2 [deprecated=true];
    DIRECTORY = 3 [deprecated=true];
    FILE = 4;
  }

  enum FileStatus {
    UNAVAILABLE = 0;
    SAME = 1;
    CHANGED = 2;
    ADDED = 3;
  }
}

message Measure {
  string metric_key = 1;
  oneof value {
    BoolValue boolean_value = 2;
    IntValue int_value = 3;
    LongValue long_value = 4;
    DoubleValue double_value = 5;
    StringValue string_value = 6;
  }

  message BoolValue {
    bool value = 1;
    string data = 2;
  }

  message IntValue {
    int32 value = 1;
    string data = 2;
  }

  message LongValue {
    int64 value = 1;
    string data = 2;
  }

  message DoubleValue {
    double value = 1;
    string data = 2;
  }

  message StringValue {
    string value = 1;
  }
}

message Issue {
  string rule_repository = 1;
  string rule_key = 2;
  // Only when issue component is a file. Can also be empty for a file if this is an issue global to the file.
  string msg = 3;
  Severity severity = 4;
  double gap = 5;
  // Only when issue component is a file. Can also be empty for a file if this is an issue global to the file.
  // Will be identical to the first location of the first flow
  TextRange text_range = 6;
  repeated Flow flow = 7;
  bool quickFixAvailable = 8;
}

message ExternalIssue {
  string engine_id = 1;
  string rule_id = 2;
  string msg = 3;
  Severity severity = 4;
  int64 effort = 5;
  TextRange text_range = 6;
  repeated Flow flow = 7;
  IssueType type = 8;
}

message AdHocRule {
    string engine_id = 1;
    string rule_id = 2;
    string name = 3;
    string description = 4;
    Severity severity = 5;
    IssueType type = 6;
}

enum IssueType {
  UNSET = 0;
  CODE_SMELL = 1;
  BUG = 2;
  VULNERABILITY = 3;
  SECURITY_HOTSPOT = 4;
}

message IssueLocation {
  int32 component_ref = 1;
  // Only when component is a file. Can be empty for a file if this is an issue global to the file.
  TextRange text_range = 2;
  string msg = 3;
}

message Flow {
  repeated IssueLocation location = 1;
}

message Changesets {
  int32 component_ref = 1;
  // If set to true then it means changeset attribute is empty and compute engine should copy data from previous analysis
  bool copy_from_previous = 2;
  repeated Changeset changeset = 3;
  // if changesetIndexByLine[5] = 2 then it means that changeset[2] is the last one on line 6
  repeated int32 changesetIndexByLine = 4 [packed = true];

  message Changeset {
    string revision = 1;
    string author = 2;
    int64 date = 3;
  }
}

message Duplicate {
  // Will be 0 when duplicate is in the same file
  int32 other_file_ref = 1;
  // Only start_line and end_line are provided since we dont support "precise" duplication location.
  TextRange range = 2;
}

message Duplication {
  // Origin position in current file. Only start_line and end_line are provided since we dont support "precise" duplication location.
  TextRange origin_position = 1;
  repeated Duplicate duplicate = 2;
}

// Used for cross project duplication
message CpdTextBlock {
  string hash = 1;
  int32 start_line = 2;
  int32 end_line = 3;
  int32 start_token_index = 4;
  int32 end_token_index = 5;
}

// Lines start at 1 and line offsets start at 0
message TextRange {
  int32 start_line = 1;
  // End line (inclusive)
  int32 end_line = 2;
  int32 start_offset = 3;
  int32 end_offset = 4;
}

message LineSgnificantCode {
  int32 line = 1;
  int32 start_offset = 2;
  int32 end_offset = 3;
}

message ChangedLines {
  repeated int32 line = 1;
}

message Symbol {
  TextRange declaration = 1;
  repeated TextRange reference = 2;
}

// Only FILE component has coverage information, and only executable lines should contains this information.
message LineCoverage {
  int32 line = 1;

  // Number of conditions to cover (if set, the value must be greater than 0)
  int32 conditions = 2;
  // Is the line has been touched by a unit test ? Returning false means that no test has touched this executable line.
  oneof has_hits {
    bool hits = 3;
  }
  // Number of conditions covered by tests
  oneof has_covered_conditions {
    int32 covered_conditions = 5;
  }
}

// Must be sorted by line and start offset
message SyntaxHighlightingRule {
  TextRange range = 1;
  HighlightingType type = 2;

  enum HighlightingType {
    UNSET = 0;
    ANNOTATION = 1;
    CONSTANT = 2;
    COMMENT = 3;
    STRUCTURED_COMMENT = 5;
    KEYWORD = 6;
    HIGHLIGHTING_STRING = 7;
    KEYWORD_LIGHT = 8;
    PREPROCESS_DIRECTIVE = 9;
  }
}

message AnalysisWarning {
  string text = 1;
  int64 timestamp = 2;
}