Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90689480
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
Sun, Nov 3, 21:52
Size
2 KB
Mime Type
text/x-python
Expires
Tue, Nov 5, 21:52 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22117596
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'
)
compiler_re
=
re
.
compile
(
".*build.*(gcc|clang)-err\.log"
)
self
.
_input_files
=
[]
for
_file
in
files
:
match
=
compiler_re
.
search
(
_file
)
if
match
:
self
.
_input_files
.
append
(
_file
)
def
generate_issues
(
self
):
'''parse warning files'''
for
_file
in
self
.
_input_files
:
match
=
compiler_re
.
search
(
_file
)
if
match
:
compiler
=
match
.
group
(
1
)
else
:
print_info
(
f
"Skipped {_file}, could not determine compiler"
)
continue
warnings
=
warn
.
get_warnings
(
_file
,
compiler
)
for
warning
in
warnings
:
issue
=
{
'name'
:
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'
if
warning
.
get_tool
()
in
self
.
CLASSIFICATIONS
:
classifications
=
self
.
CLASSIFICATIONS
[
warning
.
get_tool
()]
if
warning
.
get_category
()
in
classifications
:
cat
=
warning
.
get_category
()
categories
=
classifications
[
cat
][
'categories'
]
severity
=
classifications
[
cat
][
'severity'
]
return
(
categories
,
severity
)
Event Timeline
Log In to Comment