Skip to content

Commit

Permalink
store lint failures in files
Browse files Browse the repository at this point in the history
  • Loading branch information
m-aciek committed Feb 15, 2025
1 parent 13cf817 commit b391889
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion generate_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def get_metadata(
and completion
and (
build_warnings.number(clones_dir, repo, language.code),
sum(sphinx_lint.errors(clones_dir, repo)),
sphinx_lint.store_and_count_failures(clones_dir, repo, language.code),
)
) or (0, 0)

Expand Down
4 changes: 3 additions & 1 deletion metadata.html.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
<td data-label="warnings">
{% if project.completion %}<a href="warnings-{{ project.language.code }}.txt">{{ metadata[0] }}</a>{% else %}{{ metadata[0] }}{% endif %}
</td>
<td data-label="lint">{{ metadata[1] }}</td>
<td data-label="lint">
{% if project.completion %}<a href="warnings-lint-{{ project.language.code }}.txt">{{ metadata[1] }}</a>{% else %}{{ metadata[1] }}{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
Expand Down
18 changes: 11 additions & 7 deletions sphinx_lint.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
from collections.abc import Iterator
from itertools import chain
from pathlib import Path

from sphinxlint import check_file, checkers


def errors(clones_dir: str, repo: str) -> Iterator[int]:
def store_and_count_failures(clones_dir: str, repo: str, language_code: str) -> int:
failed_checks = list(chain.from_iterable(yield_failures(clones_dir, repo)))
filepath = Path(f'warnings-lint-{language_code}.txt')
filepath.write_text('\n'.join([str(c) for c in failed_checks]))
return len(failed_checks)


def yield_failures(clones_dir: str, repo: str) -> Iterator[str]:
enabled_checkers = [c for c in checkers.all_checkers.values() if c.enabled]
for path in Path(clones_dir, repo).rglob('*.po'):
yield len(
check_file(
path.as_posix(),
[c for c in checkers.all_checkers.values() if c.enabled],
)
)
yield check_file(path.as_posix(), enabled_checkers)

0 comments on commit b391889

Please sign in to comment.