Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ECSS Services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AcubeSat-OBC
ECSS Services
Commits
055536af
Unverified
Commit
055536af
authored
5 years ago
by
Grigoris Pavlakis
Committed by
kongr45gpen
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add line-based suppression feature. Credits to @dimst23 for the idea and implementation!
parent
6baa4696
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ci/summarizer.py
+10
-1
10 additions, 1 deletion
ci/summarizer.py
with
10 additions
and
1 deletion
ci/summarizer.py
+
10
−
1
View file @
055536af
#!/bin/env python3
#!/bin/env python3
import
os
from
argparse
import
ArgumentParser
from
argparse
import
ArgumentParser
"""
"""
...
@@ -38,6 +39,12 @@ class Summarizer(object):
...
@@ -38,6 +39,12 @@ class Summarizer(object):
file_name
=
line_contents
[
0
]
# first part is the filename (index 0)
file_name
=
line_contents
[
0
]
# first part is the filename (index 0)
violation
=
(
line_contents
[
1
],
line_contents
[
2
].
strip
(
violation
=
(
line_contents
[
1
],
line_contents
[
2
].
strip
(
'
\n
'
))
# index 1 is the line number, index 2 is the number of violated rule (both are strings)
'
\n
'
))
# index 1 is the line number, index 2 is the number of violated rule (both are strings)
with
open
(
os
.
path
.
abspath
(
file_name
))
as
code_file
:
code_lines
=
code_file
.
readlines
()
# Read the source code file
line_of_interest
=
code_lines
[
int
(
violation
[
0
])
-
1
]
# Get the desired violation line
if
line_of_interest
.
find
(
"
// Ignore-MISRA
"
)
>=
0
:
continue
if
file_name
not
in
self
.
violations_map
.
keys
():
if
file_name
not
in
self
.
violations_map
.
keys
():
self
.
violations_map
[
self
.
violations_map
[
...
@@ -45,7 +52,7 @@ class Summarizer(object):
...
@@ -45,7 +52,7 @@ class Summarizer(object):
# rule no.
# rule no.
self
.
violations_map
[
file_name
].
append
(
violation
)
self
.
violations_map
[
file_name
].
append
(
violation
)
else
:
else
:
self
.
violations_map
[
file_name
].
append
(
violation
)
# do not
append
if it already exists
self
.
violations_map
[
file_name
].
append
(
violation
)
# do not
create a key
if it already exists
for
e
in
self
.
suppression_list
:
for
e
in
self
.
suppression_list
:
for
file_name
in
self
.
violations_map
.
keys
():
for
file_name
in
self
.
violations_map
.
keys
():
...
@@ -55,6 +62,7 @@ class Summarizer(object):
...
@@ -55,6 +62,7 @@ class Summarizer(object):
self
.
violations_map
=
{
k
:
v
for
(
k
,
v
)
in
self
.
violations_map
.
items
()
if
len
(
v
)
!=
0
}
self
.
violations_map
=
{
k
:
v
for
(
k
,
v
)
in
self
.
violations_map
.
items
()
if
len
(
v
)
!=
0
}
# "delete" all keys whose lists are empty
# "delete" all keys whose lists are empty
def
pretty_print_violations
(
self
):
def
pretty_print_violations
(
self
):
"""
"""
Just a pretty printing function, no fancy logic here.
Just a pretty printing function, no fancy logic here.
...
@@ -64,6 +72,7 @@ class Summarizer(object):
...
@@ -64,6 +72,7 @@ class Summarizer(object):
for
file_name
in
self
.
violations_map
:
for
file_name
in
self
.
violations_map
:
print
(
""
)
print
(
""
)
for
violation
in
sorted
(
self
.
violations_map
[
file_name
],
key
=
lambda
x
:
int
(
x
[
0
])):
for
violation
in
sorted
(
self
.
violations_map
[
file_name
],
key
=
lambda
x
:
int
(
x
[
0
])):
name_string
=
f
"
{
self
.
bold
}{
self
.
red
}
File
{
self
.
yellow
}{
file_name
}{
self
.
red
}
"
name_string
=
f
"
{
self
.
bold
}{
self
.
red
}
File
{
self
.
yellow
}{
file_name
}{
self
.
red
}
"
rule_violated_string
=
f
"
violates rule
{
self
.
yellow
}
#
{
violation
[
1
]
}{
self
.
red
}
"
\
rule_violated_string
=
f
"
violates rule
{
self
.
yellow
}
#
{
violation
[
1
]
}{
self
.
red
}
"
\
f
"
of the MISRA C 2012 standard
"
f
"
of the MISRA C 2012 standard
"
...
...
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