Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F95835868
issue_generator_warnings.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Dec 19, 18:48
Size
2 KB
Mime Type
text/x-python
Expires
Sat, Dec 21, 18:48 (2 d)
Engine
blob
Format
Raw Data
Handle
23065946
Attached To
rAKA akantu
issue_generator_warnings.py
View Options
#!/usr/bin/env python3
__copyright__
=
(
"Copyright (©) 2021-2023 EPFL (Ecole Polytechnique Fédérale de Lausanne)"
"Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)"
)
__license__
=
"LGPLv3"
from
.
import
print_info
from
.issue_generator
import
IssueGenerator
import
re
import
warning_parser
as
warn
class
WarningsIssueGenerator
(
IssueGenerator
):
"""Main class to run and convert the results of clang-tidy to the
code-quality format.
"""
CLASSIFICATIONS
=
{
"gcc"
:
{
"uninitialized"
:
{
"categories"
:
[
"Bug Risk"
],
"severity"
:
"major"
,
},
"sign-compare"
:
{
"categories"
:
[
"Bug Risk"
],
"severity"
:
"minor"
},
},
}
def
__init__
(
self
,
**
kwargs
):
super
()
.
__init__
(
**
kwargs
)
files
=
kwargs
.
pop
(
"files"
)
self
.
_input_files
=
{}
compiler_re
=
re
.
compile
(
r".*build.*(gcc|clang)-err\.log"
)
for
_file
in
files
:
match
=
compiler_re
.
search
(
_file
)
if
match
:
self
.
_input_files
[
match
.
group
(
1
)]
=
_file
else
:
print_info
(
f
"Skipped {_file}, could not determine compiler"
)
def
generate_issues
(
self
):
"""parse warning files"""
for
compiler
,
_file
in
self
.
_input_files
.
items
():
warnings
=
warn
.
get_warnings
(
_file
,
compiler
)
for
warning
in
warnings
:
issue
=
{
"name"
:
f
"warning:{compiler}-{warning.get_category()}"
,
"description"
:
warning
.
get_message
(),
"file"
:
warning
.
get_filepath
(),
"line"
:
warning
.
get_line
(),
"column"
:
warning
.
get_column
(),
"raw"
:
warning
,
}
self
.
add_issue
(
issue
)
def
_get_classifiaction
(
self
,
warning
):
categories
=
[
"Clarity"
]
severity
=
"info"
tool
=
warning
[
"raw"
]
.
get_tool
()
cat
=
warning
[
"raw"
]
.
get_category
()
if
tool
in
self
.
CLASSIFICATIONS
:
classifications
=
self
.
CLASSIFICATIONS
[
tool
]
if
cat
in
classifications
:
categories
=
classifications
[
cat
][
"categories"
]
severity
=
classifications
[
cat
][
"severity"
]
return
(
categories
,
severity
)
Event Timeline
Log In to Comment