Key features implemented: - Updated package metadata and dependencies in PKG-INFO, setup files - Added main.py entry point for backward compatibility with README launch method - Enhanced CLI with config options, system info command, and proper signal handling - Implemented minimal PluginManager loading only plugin-loader core plugin - Refactored PluginLoader to follow minimal core design, removed sandbox/isolation complexity - Updated auto-dependency plugin with safer PL injection mechanism and disabled pl_injection - Removed legacy plugin files (firewall, frp_proxy, ftp_server, multi_lang_deploy, ops_toolbox, security_gateway) as functionality moved to core plugin system - Improved gitignore with comprehensive ignore patterns The changes implement a minimal core framework design where only the plugin-loader is directly loaded by the core, with all other plugins managed through the PL injection mechanism, significantly simplifying the architecture.
71 lines
2.1 KiB
Python
71 lines
2.1 KiB
Python
"""风格检查器"""
|
|
|
|
|
|
class StyleChecker:
|
|
"""风格检查器"""
|
|
|
|
def check(self, filepath: str, content: str) -> list:
|
|
"""执行风格检查"""
|
|
issues = []
|
|
|
|
# 检查行长度
|
|
issues.extend(self._check_line_length(filepath, content))
|
|
|
|
# 检查空行
|
|
issues.extend(self._check_blank_lines(filepath, content))
|
|
|
|
# 检查文件末尾换行
|
|
issues.extend(self._check_final_newline(filepath, content))
|
|
|
|
return issues
|
|
|
|
def _check_line_length(self, filepath: str, content: str) -> list:
|
|
"""检查行长度"""
|
|
issues = []
|
|
|
|
for i, line in enumerate(content.split('\n'), 1):
|
|
if len(line) > 120:
|
|
issues.append({
|
|
"file": filepath,
|
|
"line": i,
|
|
"severity": "info",
|
|
"type": "line_too_long",
|
|
"message": f"行过长 ({len(line)} 字符)"
|
|
})
|
|
|
|
return issues
|
|
|
|
def _check_blank_lines(self, filepath: str, content: str) -> list:
|
|
"""检查连续空行"""
|
|
issues = []
|
|
blank_count = 0
|
|
|
|
for i, line in enumerate(content.split('\n'), 1):
|
|
if line.strip() == '':
|
|
blank_count += 1
|
|
if blank_count > 2:
|
|
issues.append({
|
|
"file": filepath,
|
|
"line": i,
|
|
"severity": "info",
|
|
"type": "too_many_blanks",
|
|
"message": "连续空行过多"
|
|
})
|
|
else:
|
|
blank_count = 0
|
|
|
|
return issues
|
|
|
|
def _check_final_newline(self, filepath: str, content: str) -> list:
|
|
"""检查文件末尾换行"""
|
|
if content and not content.endswith('\n'):
|
|
return [{
|
|
"file": filepath,
|
|
"line": len(content.split('\n')),
|
|
"severity": "info",
|
|
"type": "missing_final_newline",
|
|
"message": "文件末尾缺少换行符"
|
|
}]
|
|
|
|
return []
|