FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
codeql/shared/cpp/Diagnostics.cpp at main · github/codeql · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
github
/
codeql
Public
Notifications
You must be signed in to change notification settings
Fork
2.1k
Star
10k
Code
Issues
997
Pull requests
459
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
codeql
/
shared
/
cpp
/
Diagnostics.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
75 lines (66 loc) · 1.97 KB
Breadcrumbs
codeql
/
shared
/
cpp
/
Diagnostics.cpp
Copy path
File metadata and controls
75 lines (66 loc) · 1.97 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
"
Diagnostics.h
"
#
include
<
fmt/format.h
>
#
include
<
fmt/chrono.h
>
#
include
"
absl/strings/str_join.h
"
#
include
"
absl/strings/str_cat.h
"
namespace
codeql
{
namespace
{
std::string_view
severityToString
(Diagnostic::Severity severity) {
using
S = Diagnostic::Severity;
switch
(severity) {
case
S::note:
return
"
note
"
;
case
S::warning:
return
"
warning
"
;
case
S::error:
return
"
error
"
;
default
:
return
"
unknown
"
;
}
}
}
//
namespace
nlohmann::json
Diagnostic::json
(
const
std::chrono::system_clock::time_point& timestamp,
std::string_view message)
const
{
nlohmann::json ret{
{
"
source
"
,
{
{
"
id
"
,
absl::StrJoin
({extractorName, programName, id},
"
/
"
)},
{
"
name
"
, name},
{
"
extractorName
"
, extractorName},
}},
{
"
visibility
"
,
{
{
"
statusPage
"
,
has
(Visibility::statusPage)},
{
"
cliSummaryTable
"
,
has
(Visibility::cliSummaryTable)},
{
"
telemetry
"
,
has
(Visibility::telemetry)},
}},
{
"
severity
"
,
severityToString
(severity)},
{
"
markdownMessage
"
,
absl::StrCat
(message,
"
\n\n
"
, action)},
{
"
timestamp
"
,
fmt::format
(
"
{:%FT%T%z}
"
, timestamp)},
};
if
(location) {
ret[
"
location
"
] = location->
json
();
}
return
ret;
}
std::string
Diagnostic::abbreviation
()
const
{
if
(location) {
return
absl::StrCat
(id,
"
@
"
, location->
str
());
}
return
std::string{id};
}
bool
Diagnostic::has
(Visibility v)
const
{
return
(visibility & v) != Visibility::none;
}
nlohmann::json
DiagnosticsLocation::json
()
const
{
nlohmann::json ret{{
"
file
"
, file}};
if
(startLine) ret[
"
startLine
"
] = startLine;
if
(startColumn) ret[
"
startColumn
"
] = startColumn;
if
(endLine) ret[
"
endLine
"
] = endLine;
if
(endColumn) ret[
"
endColumn
"
] = endColumn;
return
ret;
}
std::string
DiagnosticsLocation::str
()
const
{
return
absl::StrJoin
(std::tuple{file, startLine, startColumn, endLine, endColumn},
"
:
"
);
}
}
//
namespace codeql
Back
|
FazBrowse Home
|
New Git URL