caching + adjusted line count
This commit is contained in:
parent
9b2eaf9fe2
commit
0574470f99
10
.vscode/settings.json
vendored
10
.vscode/settings.json
vendored
@ -1,3 +1,11 @@
|
|||||||
{
|
{
|
||||||
"python.analysis.typeCheckingMode": "basic"
|
"python.analysis.typeCheckingMode": "basic",
|
||||||
|
"python.formatting.blackArgs": [
|
||||||
|
"--line-length",
|
||||||
|
"120"
|
||||||
|
],
|
||||||
|
"isort.args": [
|
||||||
|
"--profile",
|
||||||
|
"black"
|
||||||
|
]
|
||||||
}
|
}
|
@ -3,9 +3,14 @@ RUN cargo install rust-code-analysis-cli
|
|||||||
WORKDIR /code/
|
WORKDIR /code/
|
||||||
RUN git clone https://gitea.parrrate.ru/PTV/radn-rs.git
|
RUN git clone https://gitea.parrrate.ru/PTV/radn-rs.git
|
||||||
WORKDIR /code/radn-rs/
|
WORKDIR /code/radn-rs/
|
||||||
RUN git fetch && git checkout 540fdce02aefcb0dae5735c55daec690c4571b18
|
|
||||||
COPY metrics.py /code/metrics.py
|
COPY metrics.py /code/metrics.py
|
||||||
|
|
||||||
|
RUN git fetch && git checkout 664365ba728e5b566b85f4275aef556b2094f606
|
||||||
RUN python3 /code/metrics.py
|
RUN python3 /code/metrics.py
|
||||||
|
|
||||||
|
RUN git fetch && git checkout 82141aa35e01a71f190c1ee83dd467f4153406df
|
||||||
|
RUN python3 /code/metrics.py
|
||||||
|
|
||||||
FROM python:3.11
|
FROM python:3.11
|
||||||
RUN python3 -m pip install matplotlib
|
RUN python3 -m pip install matplotlib
|
||||||
WORKDIR /code/
|
WORKDIR /code/
|
||||||
|
@ -10,20 +10,34 @@ def filter_schema(obj, schema):
|
|||||||
|
|
||||||
entry_schema = {
|
entry_schema = {
|
||||||
"name": True,
|
"name": True,
|
||||||
"metrics": {"halstead": {"bugs": True, "difficulty": True}, "loc": {"ploc": True, "cloc": True, "blank": True}},
|
"metrics": {
|
||||||
|
"halstead": {"bugs": True, "difficulty": True},
|
||||||
|
"loc": {"ploc": True, "cloc": True, "blank": True},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open("/code/cache.json", "r") as file:
|
||||||
|
cache = json.load(file)
|
||||||
|
except FileNotFoundError:
|
||||||
|
cache = {}
|
||||||
commits = check_output(["git", "log", "--pretty=%H"], text=True).splitlines()
|
commits = check_output(["git", "log", "--pretty=%H"], text=True).splitlines()
|
||||||
entries = []
|
entries = []
|
||||||
for i, commit in enumerate(commits):
|
for i, commit in enumerate(commits):
|
||||||
print("running", commit)
|
if commit not in cache:
|
||||||
check_output(["git", "checkout", commit], text=True)
|
print("running", commit)
|
||||||
lines = check_output(
|
check_output(["git", "checkout", commit], text=True)
|
||||||
["rust-code-analysis-cli", "-m", "-p", "src", "-O", "json"], text=True
|
lines = check_output(
|
||||||
).splitlines()
|
["rust-code-analysis-cli", "-m", "-p", "src", "-O", "json"], text=True
|
||||||
print(len(lines))
|
).splitlines()
|
||||||
for line in lines:
|
print(len(lines))
|
||||||
entry = json.loads(line)
|
commit_entries = []
|
||||||
entries.append((i, filter_schema(entry, entry_schema)))
|
for line in lines:
|
||||||
|
entry = json.loads(line)
|
||||||
|
commit_entries.append(filter_schema(entry, entry_schema))
|
||||||
|
cache[commit] = commit_entries
|
||||||
|
entries.extend((i, entry) for entry in cache[commit])
|
||||||
|
with open("/code/cache.json", "w") as file:
|
||||||
|
json.dump(cache, file)
|
||||||
with open("/code/metrics.json", "w") as file:
|
with open("/code/metrics.json", "w") as file:
|
||||||
json.dump(entries, file)
|
json.dump(entries, file)
|
||||||
|
@ -66,13 +66,19 @@ def render_ploc():
|
|||||||
units.append((x, *ys))
|
units.append((x, *ys))
|
||||||
X, Yp, Yc, Yb = np.array(units).transpose()
|
X, Yp, Yc, Yb = np.array(units).transpose()
|
||||||
plt.clf()
|
plt.clf()
|
||||||
|
plt.axhline(7000, alpha=0.5)
|
||||||
|
plt.axhline(6000, alpha=0.5)
|
||||||
|
plt.axhline(0, alpha=0.5)
|
||||||
plt.plot(X, Yp, label="code")
|
plt.plot(X, Yp, label="code")
|
||||||
plt.plot(X, Yc, label="comments/docs")
|
plt.plot(X, Yc, label="comments/docs")
|
||||||
plt.plot(X, Yb, label="blank")
|
plt.plot(X, Yb, label="blank")
|
||||||
|
fmt, kwargs = ":", dict(alpha=0.5)
|
||||||
|
plt.plot(X, Yc * (k := Yp[0] / Yc[0]), fmt, label=f"c/d x{round(k, 1)}", c="C1", **kwargs)
|
||||||
|
plt.plot(X, Yb * (k := Yp[0] / Yb[0]), fmt, label=f"blank x{round(k, 1)}", c="C2", **kwargs)
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.savefig("/code/ploc.png")
|
plt.savefig("/code/ploc.png")
|
||||||
|
|
||||||
|
|
||||||
|
render_ploc()
|
||||||
render_halstead(False)
|
render_halstead(False)
|
||||||
render_halstead(True)
|
render_halstead(True)
|
||||||
render_ploc()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user