inspectr 0.0.3__py3-none-any.whl → 0.0.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- inspectr/authenticity.py +10 -0
- inspectr/duplicates.py +2 -3
- {inspectr-0.0.3.dist-info → inspectr-0.0.5.dist-info}/METADATA +2 -1
- {inspectr-0.0.3.dist-info → inspectr-0.0.5.dist-info}/RECORD +8 -8
- {inspectr-0.0.3.dist-info → inspectr-0.0.5.dist-info}/WHEEL +0 -0
- {inspectr-0.0.3.dist-info → inspectr-0.0.5.dist-info}/entry_points.txt +0 -0
- {inspectr-0.0.3.dist-info → inspectr-0.0.5.dist-info}/licenses/LICENSE +0 -0
- {inspectr-0.0.3.dist-info → inspectr-0.0.5.dist-info}/top_level.txt +0 -0
inspectr/authenticity.py
CHANGED
@@ -6,13 +6,18 @@ from typing import List
|
|
6
6
|
|
7
7
|
def main(files: List[pathlib.Path]) -> None:
|
8
8
|
todo_count = 0
|
9
|
+
fixme_count = 0
|
10
|
+
placeholder_count = 0
|
9
11
|
empty_try_except_count = 0
|
10
12
|
stub_functions = []
|
11
13
|
|
12
14
|
for f in files:
|
13
15
|
src = f.read_text(encoding="utf-8")
|
14
16
|
|
17
|
+
# TODO: make these case insensitive
|
15
18
|
todo_count += src.count("TODO")
|
19
|
+
fixme_count += src.count("FIXME")
|
20
|
+
placeholder_count += src.count("Placeholder")
|
16
21
|
|
17
22
|
try:
|
18
23
|
tree = ast.parse(src, filename=str(f))
|
@@ -36,6 +41,9 @@ def main(files: List[pathlib.Path]) -> None:
|
|
36
41
|
continue
|
37
42
|
elif isinstance(stmt, ast.Return) and stmt.value is None:
|
38
43
|
continue
|
44
|
+
elif isinstance(stmt, ast.Expr) and isinstance(stmt.value, ast.Constant) and isinstance(stmt.value.value, str):
|
45
|
+
# ignore docstrings
|
46
|
+
continue
|
39
47
|
else:
|
40
48
|
is_stub = False
|
41
49
|
break
|
@@ -44,6 +52,8 @@ def main(files: List[pathlib.Path]) -> None:
|
|
44
52
|
|
45
53
|
print("Analysis results:")
|
46
54
|
print(f" TODO comments: {todo_count}")
|
55
|
+
print(f" FIXME comments: {fixme_count}")
|
56
|
+
print(f" Placeholder comments: {placeholder_count}")
|
47
57
|
print(f" Empty try/except blocks: {empty_try_except_count}")
|
48
58
|
print(f" Stub functions/methods: {len(stub_functions)}")
|
49
59
|
for stub in stub_functions:
|
inspectr/duplicates.py
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
# mytool/duplicates.py
|
2
1
|
import sys
|
3
2
|
import hashlib
|
4
3
|
from collections import defaultdict
|
5
4
|
|
6
|
-
def find_duplicates(files, block_size=
|
5
|
+
def find_duplicates(files, block_size=10, min_occur=3):
|
7
6
|
"""
|
8
7
|
Find duplicate blocks of code across files.
|
9
8
|
|
@@ -46,6 +45,6 @@ def main(args=None) -> None:
|
|
46
45
|
print("Usage: inspectr duplicates file1.py [file2.py ...]")
|
47
46
|
return
|
48
47
|
|
49
|
-
for fname, lnum, count in find_duplicates(args, block_size=
|
48
|
+
for fname, lnum, count in find_duplicates(args, block_size=10, min_occur=3):
|
50
49
|
print(f"{fname}:{lnum} (occurs {count} times)")
|
51
50
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: inspectr
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.5
|
4
4
|
Summary: A collection of python tools to inspect code quality.
|
5
5
|
Maintainer-email: Alex Mueller <amueller474@gmail.com>
|
6
6
|
License-Expression: Apache-2.0
|
@@ -36,6 +36,7 @@ where `<subtool>` is one of the following:
|
|
36
36
|
- `authenticity`: looks for TODO comments, empty try/except blocks, and stub functions
|
37
37
|
- `bare_ratio`: checks for the ratio of bare excepts to meaningful exception usage
|
38
38
|
- `count_exceptions`: counts how many of each type of exception there are (including bare except)
|
39
|
+
- `duplicates`: looks for occurrences of duplicate code (default: 10+ lines, 3+ occurrences)
|
39
40
|
- `size_counts`: various linecount-related code complexity checks
|
40
41
|
- `with_open`: checks for `open` in the absense of `with` and manual calls to `close()`
|
41
42
|
|
@@ -1,14 +1,14 @@
|
|
1
1
|
inspectr/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
inspectr/__main__.py,sha256=Rojob_KTdzcHjItkGgA3TPLqPd223pIfeajpCWDP3Gc,652
|
3
|
-
inspectr/authenticity.py,sha256=
|
3
|
+
inspectr/authenticity.py,sha256=r2nld4JZ8Cl6RWdpP-3jRcFG-5YJCWjAeEiNzFqfO4k,2202
|
4
4
|
inspectr/bare_ratio.py,sha256=oQfag96zjGnmFHofZ5qabBGGVoKUnmRNzGq_WX_8ZZg,1997
|
5
5
|
inspectr/count_exceptions.py,sha256=UhUc3ZZY8eDxLtlLX1USKzP_JEPY3clx8R8TPvtQ5LE,1588
|
6
|
-
inspectr/duplicates.py,sha256=
|
6
|
+
inspectr/duplicates.py,sha256=xAFNO90JVEhzZqmyHg8gXAo28e_DIrB3SYh7tONAzbU,1455
|
7
7
|
inspectr/size_counts.py,sha256=Yw-k5v7lPylzfh-9SUs1PtlV3Bhvdy9X7w2Pi93xL9g,2920
|
8
8
|
inspectr/with_open.py,sha256=qbCAb14cZ15yX7SbLo2C3nE1sDEKLiZ48bvFQfTAKJk,606
|
9
|
-
inspectr-0.0.
|
10
|
-
inspectr-0.0.
|
11
|
-
inspectr-0.0.
|
12
|
-
inspectr-0.0.
|
13
|
-
inspectr-0.0.
|
14
|
-
inspectr-0.0.
|
9
|
+
inspectr-0.0.5.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
10
|
+
inspectr-0.0.5.dist-info/METADATA,sha256=tzbZCSIw8J7QTMSzLQ9hyBDXZGQzQF2gBm7xRbzWKPk,1666
|
11
|
+
inspectr-0.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
12
|
+
inspectr-0.0.5.dist-info/entry_points.txt,sha256=IrOM4SpCRfFZzBWngg3ezXuX31ZqFBR-flSU5c8tbTo,52
|
13
|
+
inspectr-0.0.5.dist-info/top_level.txt,sha256=NlTFBMaWgYmxFzjQtp4Y6itVQQV8sBPtAAZvFnviT-A,9
|
14
|
+
inspectr-0.0.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|