ondivi
Version 0.6.0

이것은 GIT 저장소에서 변경된 라인에 대해서만 코딩 위반 (정적 분석기로 식별)을 필터링하도록 설계된 간단한 파이썬 스크립트입니다.
이 도구는 다음을 포함하되 이에 국한되지 않는 모든 라이터 또는 정적 코드 분석기와 함께 작동합니다.
pip install ondiviGIT 저장소의 루트 디렉토리에 있는지 확인하십시오.
스크립트 실행 :
flake8 script.py | ondivi
# with ruff:
ruff check file.py --output-format=concise | ondivi또는:
flake8 script.py > violations.txt
ondivi --fromfile=violations.txt $ ondivi --help
Usage: ondivi [OPTIONS]
Ondivi (Only diff violations).
Python script filtering coding violations, identified by static analysis,
only for changed lines in a Git repo. Usage example:
flake8 script.py | ondivi
Options:
--baseline TEXT Commit or branch which will contain legacy code. Program
filter out violations on baseline (default: "master")
--fromfile TEXT Path to file with violations. Expected "utf-8" encoding
--format TEXT Template for parsing linter messages. The template should
include the following named parts:
{filename} The name of the file with the error/warning
{line_num} The line number with the error/warning
(integer)
Example usage:
--format "{filename}:{line_num:d}{other}"
In this example, the linter message
"src/app_types/listable.py:23:1: UP035 Import from
collections.abc instead: Sequence"
will be recognized and parsed into the following
components:
- filename: "src/app_types/listable.py"
- line_num: 23
- other: :1: "UP035 Import from collections.abc instead:
Sequence"
Ensure that the template matches the format of the
messages generated by your linter.
(default: "{filename}:{line_num:d}{other}")
--only-violations Show only violations
--help Show this message and exit.
스크립트는 각 파일의 변경된 줄을 식별하기 위해 git diff 출력을 구문 분석합니다.
그런 다음 주어진 코딩 위반을 필터링하여 변경된 라인에 해당하는 위반 만 포함합니다.
Flakeheaven과 Flakehell은 내부 Flake8 API에 의존하기 때문에 지원되지 않으므로 Flake8이 발전함에 따라 호환성 문제로 이어질 수 있습니다. 대조적으로, Ondivi는 위반의 텍스트 출력과 Git 저장소 상태 만 사용하여보다 강력하고 유지 관리가 더 쉽습니다.
Flake8 파일 :
$ flake8 file.py
file.py:3:1: E302 expected 2 blank lines, found 1
file.py:9:1: E302 expected 2 blank lines, found 1
file.py:10:121: E501 line too long (123 > 120 characters)
file.py:14:1: E305 expected 2 blank lines after class or function definition, found 1변경의 예 :
from dataclasses import dataclass
@dataclass
class User(object):
name: str
age: int
def greet(user: User):
print('Long string in initial commit ################################################################################')
print(f'Hello, {user.name}!')
+ print('Long string in new commit ################################################################################')
if __name__ == '__main__':
greet(User(345, 23))
+ greet(User('Bob', '23'))Git Diff에 의해 우리는 두 개의 새로운 라인이 추가되었음을 알 수 있습니다 (12 및 16).
Ondivi는 위반을 필터링하고 12 행에 대해서는 하나만 표시합니다.
$ flake8 script.py | ondivi
file.py:12:80: E501 line too long (119 > 79 characters)이 프로젝트는 MIT 라이센스에 따라 라이센스가 부여됩니다. 자세한 내용은 라이센스 파일을 참조하십시오.