vault backup: 2022-09-26 18:39:43

Affected files:
.obsidian/workspace
03. 資料收集/HTTP Server/Nginx.md
03. 資料收集/Hobby/RC.md
03. 資料收集/Hobby/模型/Traxxas Sledge.md
03. 資料收集/Hobby/模型/舊化作例.md
03. 資料收集/Hobby/軍武/虎式.md
03. 資料收集/Programming/COM/20210726 - COM Interface.md
03. 資料收集/Programming/DB/MySQL.md
03. 資料收集/Programming/DB/sqlite.md
03. 資料收集/Programming/Design Pattern.md
03. 資料收集/Programming/FFMPEG/00. Introduction.md
03. 資料收集/Programming/FFMPEG/01. Setup.md
03. 資料收集/Programming/FFMpeg.md
03. 資料收集/Programming/Flask.md
03. 資料收集/Programming/Media Foundation/20210604 - Windows media foundation.md
03. 資料收集/Programming/OpenCV.md
03. 資料收集/Programming/OpenGL.md
03. 資料收集/Programming/Python/argparse.ArgumentParser.md
03. 資料收集/Programming/Python/decorator.md
03. 資料收集/Programming/Python/logging.md
03. 資料收集/Programming/Python/opencv.md
03. 資料收集/Programming/Python/subprocess.md
03. 資料收集/Programming/Python/threading.md
03. 資料收集/Programming/Python/tkinter.md
03. 資料收集/Programming/Python/檢測工具.md
03. 資料收集/Programming/QT/Dropdown button.md
03. 資料收集/Programming/QT/QVariant.md
03. 資料收集/Programming/QT/Qt.md
03. 資料收集/Programming/Qt.md
03. 資料收集/Programming/UML.md
03. 資料收集/Programming/演算法.md
03. 資料收集/架站/03. Trojan.md
03. 資料收集/架站/Gitea.md
03. 資料收集/架站/HTTP Server/Apache.md
03. 資料收集/架站/HTTP Server/Nginx/Reverse Proxy(Layer4).md
03. 資料收集/架站/Pelican blog.md
03. 資料收集/架站/Proxmox VE.md
03. 資料收集/架站/SWAG Reverse proxy.md
03. 資料收集/架站/Storj.md
03. 資料收集/架站/Trojan.md
03. 資料收集/科技/802.11.md
03. 資料收集/科技/HDR Sensor.md
03. 資料收集/科技/量子電腦.md
03. 資料收集/科技/鋰電池.md
03. 資料收集/軟體工具/IPFS.md
03. 資料收集/軟體工具/MkDocs.md
03. 資料收集/軟體工具/Obsidian.md
03. 資料收集/軟體工具/docker.md
03. 資料收集/軟體工具/git/apply.md
03. 資料收集/軟體工具/git/submodule.md
This commit is contained in:
2022-09-26 18:39:43 +08:00
parent 95a804e0da
commit 2f312a4575
50 changed files with 15 additions and 440 deletions

View File

@@ -0,0 +1,96 @@
## 單元測試
### [pytest](https://docs.pytest.org/en/7.1.x/)
Pytest 不僅可以幫助我們運行測試還可以幫助我們配置如何運行它們、運行哪些文件等等……Pytest 有一個配置文件 `pytest.ini`,您可以在其中描述它的配置,例如哪個版本應該是 Pytest 或者哪些是測試文件,例如下列。
```ini
# pytet.ini
[pytest]
minversion = 6.0
addopts = -ra -q — cov=src — cov-report=html
python_files = test_*.py
```
### [tox](https://tox.wiki/en/latest/)
Tox 是一個通用的virtualenv管理和測試命令行工具。
使用不同的 Python 版本和解釋器檢查您的包是否正確安裝
在每個環境中運行您的測試,配置您選擇的測試工具
作為持續集成服務器的前端,大大減少樣板文件並合併 CI 和基於 shell 的測試。
Tox 也有它的配置文件。
```ini
[tox]
isolated_build = True
envlist = py{38}
[testenv]
usedevelop = true
deps = -r src/requirements_dev.txt
```
## 程式檢查工具
用來檢查程式是否符合coding style、PEP8之類的規範
### [pylint](https://github.com/PyCQA/pylint)
Pylint config: create `.pylintrc` file
```
[MESSAGES CONTROL]
disable=
missing-docstring,
too-few-public-methods[REPORTS]
output-format=colorized
files-output=no
reports=no
evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
```
### [flake8](https://github.com/pycqa/flake8)
Flake8 config: create `.flake8` file
```
[flake8]
ignore = E203, E266, E501, W503, F403, F401, E402
max-line-length = 120
max-complexity = 18
select = B,C,E,F,W,T4,B9
exclude =
.git,
tests
```
### [mypy](http://www.mypy-lang.org/)
## Git hook
### pre-commit
Pre-commit 是一個創建 git hook的framework以確保您的代碼編寫與您定義的代碼樣式相對應。
它會掃描您的原始碼並運行您將在預提交配置文件中定義的所有檢查器:`.pre-commit-config.yaml`
```
repos:
- repo: 'https://gitlab.com/pycqa/flake8'
rev: 3.8.2
hooks:
- id: flake8
name: Style Guide Enforcement (flake8)
args:
- '--max-line-length=120'
- repo: 'https://github.com/pre-commit/mirrors-mypy'
rev: v0.720
hooks:
- id: mypy
name: Optional Static Typing for Python (mypy)
```
## 漏洞檢查
### [SonarQube](https://www.sonarqube.org/)
有很多用於漏洞掃描的工具,但我們將看看[Sonarqube](https://www.sonarqube.org/)。Sonarqube 是用於代碼質量和安全掃描的開源強大工具,是該行業的領先工具之一。
更多在[官方文檔](https://docs.sonarqube.org/latest/)中。
您可以使用 Docker 映像設置本地 Sonarqube 服務器並定義`sonar-project.properties`
```
# must be unique in a given SonarQube instance
sonar.projectKey=python_app_blueprint
# --- optional properties ---
# defaults to project key
#sonar.projectName=My project
# defaults to 'not provided'
#sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Defaults to .
#sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
```