Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
a5d55bae
Commit
a5d55bae
authored
Mar 28, 2013
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update the suspicious builder to detect unused rules, and remove currently unusued rules.
parent
44ea77bd
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
101 deletions
+11
-101
Doc/tools/sphinxext/susp-ignored.csv
Doc/tools/sphinxext/susp-ignored.csv
+0
-101
Doc/tools/sphinxext/suspicious.py
Doc/tools/sphinxext/suspicious.py
+11
-0
No files found.
Doc/tools/sphinxext/susp-ignored.csv
View file @
a5d55bae
This diff is collapsed.
Click to expand it.
Doc/tools/sphinxext/suspicious.py
View file @
a5d55bae
...
@@ -68,6 +68,10 @@ class Rule:
...
@@ -68,6 +68,10 @@ class Rule:
# None -> don't care
# None -> don't care
self
.
issue
=
issue
# the markup fragment that triggered this rule
self
.
issue
=
issue
# the markup fragment that triggered this rule
self
.
line
=
line
# text of the container element (single line only)
self
.
line
=
line
# text of the container element (single line only)
self
.
used
=
False
def
__repr__
(
self
):
return
'{0.docname},,{0.issue},{0.line}'
.
format
(
self
)
...
@@ -107,6 +111,12 @@ class CheckSuspiciousMarkupBuilder(Builder):
...
@@ -107,6 +111,12 @@ class CheckSuspiciousMarkupBuilder(Builder):
doctree
.
walk
(
visitor
)
doctree
.
walk
(
visitor
)
def
finish
(
self
):
def
finish
(
self
):
unused_rules
=
[
rule
for
rule
in
self
.
rules
if
not
rule
.
used
]
if
unused_rules
:
self
.
warn
(
'Found %s/%s unused rules:'
%
(
len
(
unused_rules
),
len
(
self
.
rules
)))
for
rule
in
unused_rules
:
self
.
info
(
repr
(
rule
))
return
return
def
check_issue
(
self
,
line
,
lineno
,
issue
):
def
check_issue
(
self
,
line
,
lineno
,
issue
):
...
@@ -131,6 +141,7 @@ class CheckSuspiciousMarkupBuilder(Builder):
...
@@ -131,6 +141,7 @@ class CheckSuspiciousMarkupBuilder(Builder):
if
(
rule
.
lineno
is
not
None
)
and
\
if
(
rule
.
lineno
is
not
None
)
and
\
abs
(
rule
.
lineno
-
lineno
)
>
5
:
continue
abs
(
rule
.
lineno
-
lineno
)
>
5
:
continue
# if it came this far, the rule matched
# if it came this far, the rule matched
rule
.
used
=
True
return
True
return
True
return
False
return
False
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment