Metadata-Version: 2.4
Name: gen-linter-config
Version: 1.0.3
Summary: GenerateLinterConfig - 代码检查规则生成工具
Author-email: crowdedplus <522025330089@smail.nju.edu.cn>
License: MIT
Project-URL: Homepage, https://github.com/crowdedplus/gen-linter-config
Project-URL: Repository, https://github.com/crowdedplus/gen-linter-config.git
Project-URL: Issues, https://github.com/crowdedplus/gen-linter-config/issues
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: litellm~=1.81.3
Requires-Dist: dotenv~=0.9.9
Requires-Dist: python-dotenv~=1.2.1
Requires-Dist: pip~=25.2
Requires-Dist: attrs~=25.4.0
Requires-Dist: distro~=1.9.0
Requires-Dist: retry~=0.9.2
Requires-Dist: PySocks~=1.7.1
Requires-Dist: pillow~=11.1.0
Requires-Dist: Jinja2~=3.1.6
Requires-Dist: openai~=2.15.0
Requires-Dist: tiktoken~=0.12.0
Requires-Dist: requests~=2.33.0
Requires-Dist: beautifulsoup4~=4.14.2
Requires-Dist: setuptools~=80.9.0
Requires-Dist: httpx~=0.28.1
Requires-Dist: pytest~=9.0.3
Dynamic: license-file

[![en](https://img.shields.io/badge/lang-en-red.svg)](https://github.com/crowdedplus/gen-linter-config/blob/main/README.md)
[![zh-cn](https://img.shields.io/badge/lang-zh--cn-blue.svg)](https://github.com/crowdedplus/gen-linter-config/blob/main/README.zh-CN.md)

# gen-linter-config

A LLM-based linter configuration generate tool .

## How to use

1. install:

```python
pip install gen-linter-config
```

2. Configuring LLM: This project uses `litellm` to call large model in a unified format, so please make sure that you have configured your key as an environment variable and have sufficient token resources before using it.

3. Usage Example：

   ```python
   gen-linter-config -t checkstyle --input "No more than 5 function parameters"
   gen-linter-config -t checkstyle --input rule.txt --out output.json
   gen-linter-config -t checkstyle --input "Wrap the code block in braces" --format json
   gen-linter-config --tool Cppcheck --model dashscope/qwen3-max --input "It is forbidden to use malloc functions that may return null pointers without checking."
   # Cppcheck does not apply to the attribute name system, so it will not actually return the content containing the attribute name.
   ```
   
   If you don't specify an output file, the output will directly printed in the console.

## Configure key as a system-level environment variable

Windows：Through the system property settings. Find system-properties, find advanced system settings-environment variable, and then create a new user variable with the variable named OPENAI_API_KEY and the value of the key in the user environment variable above.

Linux/macos：Set environment variables in the shell configuration file. Open the terminal and execute the instructions according to different shell:

```python
# Bash
nano ~/.bashrc
# Zsh
nano ~/.zshrc
# Other shell may need to consult relevant documents.
```

Add in the configuration file:

```py
export OPENAI_API_KEY=[Your OpenAI API key]
```

Then save and exit. Make the changes take effect:

```python
# Bash
source ~/.bashrc
# Zsh
source ~/.zshrc
# 其它的shell可能需要查阅相关文档确定具体指令。
```

## List of supported tools

| Tool       | Y/N  |
| :--------- | ---- |
| Checkstyle | Y    |
| ESLint     | Y    |
| Biome      | Y    |
| ClangTidy  | Y    |
| CppCheck   | Y    |
| Flake8     | Y    |
| PMD        | Y    |
| Pylint     | Y    |
| Reek       | Y    |
| RuboCop    | Y    |
| Ruff       | Y    |

Among them, Checkstyle and ESLint support a relatively perfect generation mechanism, while other tools do not. The configuration generation of more tools is still under development.
