Skip to main content

Code Scanner - 代码审查辅助工具

一个用于扫描代码库中常见问题并生成报告的命令行工具。

功能特性

  • SecretScanner: 检测硬编码的敏感信息(AWS Key、GitHub Token等)
  • FunctionLengthScanner: 检测超过80行的函数
  • ImportScanner: 检测未使用的import语句
  • TodoScanner: 检测TODO/FIXME注释及其年龄

安装

pip install code-scanner-plus

或从源码安装:

pip install -e .

使用方法

扫描代码

# 扫描当前目录(默认JSON格式)
python -m code_scanner.cli scan

# 扫描指定目录
python -m code_scanner.cli scan --path /path/to/project

# 输出为Markdown格式(输出到控制台)
python -m code_scanner.cli scan --output markdown

# 输出为Markdown格式(保存到文件)
python -m code_scanner.cli scan --output markdown --file report.md

生成自检报告

python -m code_scanner.cli self-report .

测试

pytest tests/ -v

扫描结果说明

工具会扫描所有Python文件并报告:

  1. 敏感信息 - 硬编码的密码、API Key等
  2. 超长函数 - 超过80行的函数
  3. 未使用导入 - 未被使用的import语句
  4. TODO/FIXME - 待办事项和需要修复的问题

示例输出

运行 secret 扫描器...
运行 function_length 扫描器...
运行 import 扫描器...
运行 todo 扫描器...

扫描完成!
扫描文件数: 13
secret: 2 个问题
function_length: 1 个问题
import: 10 个问题
todo: 2 个问题

项目结构

code-scanner/
├── src/code_scanner/
│   ├── cli.py              # 命令行接口
│   └── scanners/           # 扫描器模块
│       ├── secret.py
│       ├── function_length.py
│       ├── imports.py
│       └── todo.py
├── tests/                  # 测试文件
└── pyproject.toml         # 项目配置

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

code_scanner_plus-0.1.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

code_scanner_plus-0.1.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file code_scanner_plus-0.1.0.tar.gz.

File metadata

  • Download URL: code_scanner_plus-0.1.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for code_scanner_plus-0.1.0.tar.gz
Algorithm Hash digest
SHA256 40dee384393743ea05173bf44045f6aa913ba55ecdd3eb805875c9178ee0a6e5
MD5 2fa74e6bcf0dbae616e2cc639b81c067
BLAKE2b-256 1f8aadaf73784c3dbf555da5d71f1aa6a481e4010db6fa05d3ec2a18ef050e99

See more details on using hashes here.

File details

Details for the file code_scanner_plus-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for code_scanner_plus-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92d891434547db3d524e19ae3a26d5443a051770769ea0d2aa0cdda0f3946b46
MD5 5327ecdceb81ad29a78cfb6e279b5c36
BLAKE2b-256 d84dd871e5d55780f4e7462f7da674bfcb4ed486135ca811483dca34b419a84e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page