Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dos
flow3r firmware
Commits
68aaea0a
Commit
68aaea0a
authored
1 year ago
by
q3k
Browse files
Options
Downloads
Patches
Plain Diff
ci: submit clang-tidy as codequality json
parent
7043496e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+5
-2
5 additions, 2 deletions
.gitlab-ci.yml
tools/clang-tidy-report.py
+113
-0
113 additions, 0 deletions
tools/clang-tidy-report.py
with
118 additions
and
2 deletions
.gitlab-ci.yml
+
5
−
2
View file @
68aaea0a
...
@@ -17,8 +17,11 @@ clang-tidy:
...
@@ -17,8 +17,11 @@ clang-tidy:
script
:
script
:
-
"
idf.py
build"
-
"
idf.py
build"
-
"
idf.py
clang-check"
-
"
idf.py
clang-check"
-
"
grep
warning:
warnings.txt
>
only-warnings.txt"
-
"
python3
tools/clang-tidy-report.py
warnings.txt
>
clang-tidy-cqual.json"
-
"
[
-s
only-warnings.txt
]
&&
echo
'clang-tidy
found
issues:'
&&
cat
only-warnings.txt
&&
exit
1"
artifacts
:
when
:
always
reports
:
codequality
:
clang-tidy-cqual.json
build-p3
:
build-p3
:
stage
:
build
stage
:
build
...
...
This diff is collapsed.
Click to expand it.
tools/clang-tidy-report.py
0 → 100644
+
113
−
0
View file @
68aaea0a
#!/usr/bin/env python3
import
sys
import
os
import
enum
import
json
import
dataclasses
import
hashlib
from
dataclasses
import
dataclass
from
typing
import
Literal
,
Union
,
List
,
Any
class
MagicJSONEncoder
(
json
.
JSONEncoder
):
def
default
(
self
,
o
:
Any
)
->
Any
:
if
dataclasses
.
is_dataclass
(
o
):
return
dataclasses
.
asdict
(
o
)
return
super
().
default
(
o
)
@dataclass
class
Position
:
line
:
int
column
:
int
@dataclass
class
Positions
:
begin
:
Position
@dataclass
class
Location
:
path
:
str
positions
:
Positions
class
Severity
(
str
,
enum
.
Enum
):
info
=
"
info
"
minor
=
"
minor
"
major
=
"
major
"
critical
=
"
critical
"
blocker
=
"
blocker
"
@dataclass
class
Issue
:
description
:
str
check_name
:
Union
[
str
,
None
]
severity
:
Severity
location
:
Location
fingerprint
:
str
def
parse_line
(
s
:
str
)
->
Union
[
Issue
,
None
]:
parts
=
s
.
split
(
'
:
'
,
4
)
path
=
parts
[
0
]
path
=
path
.
removeprefix
(
os
.
getcwd
()
+
'
/
'
)
line
=
int
(
parts
[
1
])
col
=
int
(
parts
[
2
])
level
=
parts
[
3
].
strip
()
severity
:
Severity
=
{
'
warning
'
:
Severity
.
major
,
'
error
'
:
Severity
.
blocker
,
}.
get
(
level
,
Severity
.
info
)
rest
=
parts
[
4
].
strip
()
check
=
''
if
rest
.
endswith
(
'
]
'
):
rest
,
check
=
rest
.
split
(
'
[
'
)
rest
=
rest
.
strip
()
check
=
check
.
rstrip
(
'
]
'
)
location
=
Location
(
path
=
path
,
positions
=
Positions
(
begin
=
Position
(
line
=
line
,
column
=
col
)))
fp
=
hashlib
.
md5
(
f
'
{
check
}
{
path
}
{
line
}
'
.
encode
()).
hexdigest
()
return
Issue
(
description
=
rest
,
check_name
=
check
,
severity
=
severity
,
location
=
location
,
fingerprint
=
fp
)
def
main
()
->
None
:
if
len
(
sys
.
argv
)
<
2
:
sys
.
stderr
.
write
(
f
"
Usage:
{
sys
.
argv
[
0
]
}
warnings.txt
\n
"
)
sys
.
stderr
.
flush
()
sys
.
exit
(
1
)
res
:
List
[
Issue
]
=
[]
with
open
(
sys
.
argv
[
1
])
as
f
:
in_checks
=
False
in_list
=
False
in_context
=
False
for
line
in
f
:
line
=
line
.
strip
()
if
line
==
'
Enabled checks:
'
:
in_checks
=
True
continue
if
in_checks
and
not
line
:
in_list
=
True
in_checks
=
False
continue
if
in_list
:
if
line
.
split
()[
0
].
endswith
(
'
clang-tidy
'
):
in_context
=
False
continue
if
not
in_context
:
v
=
parse_line
(
line
)
if
v
is
not
None
:
res
.
append
(
v
)
in_context
=
True
json
.
dump
(
res
,
sys
.
stdout
,
cls
=
MagicJSONEncoder
)
if
res
!=
[]:
sys
.
stderr
.
write
(
"
Clang-tidy report not empty
"
)
sys
.
stderr
.
flush
()
os
.
exit
(
1
)
if
__name__
==
'
__main__
'
:
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment