Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tor
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin J. Thompson
Tor
Commits
371ea65c
Commit
371ea65c
authored
6 years ago
by
George Kadianakis
Browse files
Options
Downloads
Patches
Plain Diff
Improve #include counting func and move it to metrics.py.
parent
a7684fcb
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
scripts/maint/practracker/metrics.py
+8
-0
8 additions, 0 deletions
scripts/maint/practracker/metrics.py
scripts/maint/practracker/practracker.py
+1
-4
1 addition, 4 deletions
scripts/maint/practracker/practracker.py
with
9 additions
and
4 deletions
scripts/maint/practracker/metrics.py
+
8
−
0
View file @
371ea65c
...
...
@@ -8,6 +8,14 @@ def file_len(f):
pass
return
i
+
1
def
get_include_count
(
f
):
"""
Get number of #include statements in the file
"""
include_count
=
0
for
line
in
f
:
if
re
.
match
(
r
'
*# *include
'
,
line
):
include_count
+=
1
return
include_count
def
function_lines
(
f
):
"""
Return iterator which iterates over functions and returns (function name, function lines)
...
...
This diff is collapsed.
Click to expand it.
scripts/maint/practracker/practracker.py
+
1
−
4
View file @
371ea65c
...
...
@@ -57,10 +57,7 @@ def consider_file_size(fname, f, exceptions_str):
print_violation_if_not_exception
(
violation_str
,
exceptions_str
)
def
consider_includes
(
fname
,
f
,
exceptions_str
):
include_count
=
0
for
_
,
line
in
enumerate
(
f
):
if
line
.
startswith
(
"
#include
"
):
include_count
+=
1
include_count
=
metrics
.
get_include_count
(
f
)
if
include_count
>
MAX_INCLUDE_COUNT
:
violation_str
=
"
violation include-count %s %d
"
%
(
fname
,
include_count
)
...
...
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