Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78351021
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
Mon, Aug 19, 23:55
Size
2 KB
Mime Type
text/x-python
Expires
Wed, Aug 21, 23:55 (2 d)
Engine
blob
Format
Raw Data
Handle
20000880
Attached To
rAKA akantu
issue_generator_warnings.py
View Options
#!/usr/bin/env python3
"""clang-tidy2code-quality.py: Conversion of clang-tidy output 2
code-quality"""
__author__
=
"Nicolas Richart"
__credits__
=
[
"Nicolas Richart <nicolas.richart@epfl.ch>"
,
]
__copyright__
=
(
"Copyright (©) 2018-2021 EPFL (Ecole Polytechnique Fédérale"
" de Lausanne) Laboratory (LSMS - Laboratoire de Simulation"
" en Mécanique des Solides)"
)
__license__
=
"LGPLv3"
from
.
import
print_debug
,
print_info
from
.issue_generator
import
IssueGenerator
import
re
import
sys
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
(
".*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