|
8 | 8 |
|
9 | 9 | <h1 align="center">MethodenAnalyser</h1> |
10 | 10 |
|
11 | | -<h4 align="center">Statischer Python-Code-Analyser mit GUI: findet ungenutzte Imports, tote Definitionen und ähnliche Code-Blöcke.</h4> |
| 11 | +<h4 align="center">Static Python code analyzer with a local Tkinter GUI: detects unused imports, dead definitions, and similar code blocks using AST analysis.</h4> |
| 12 | + |
| 13 | +<p align="center"> |
| 14 | + <b>English</b> | <a href="README_de.md">Deutsch</a> |
| 15 | +</p> |
12 | 16 |
|
13 | 17 | --- |
14 | 18 |
|
15 | 19 | ## Features |
16 | 20 |
|
17 | | -| Feature | Beschreibung | |
| 21 | +| Feature | Description | |
18 | 22 | |---------|-------------| |
19 | | -| **AST-Analyse** | Präzise Analyse über den Python Abstract Syntax Tree | |
20 | | -| **Import-Tracking** | Erkennt genutzte und ungenutzte Imports | |
21 | | -| **Methoden-Katalog** | Listet alle Funktionen, Methoden und Klassen | |
22 | | -| **Duplikat-Erkennung** | Findet ähnliche Code-Blöcke mit konfigurierbarem Schwellwert | |
23 | | -| **Framework-Erkennung** | Erkennt implizite Nutzung durch Tkinter, requests, asyncio und weitere Frameworks | |
24 | | -| **Callback-Erkennung** | Identifiziert Callback-Funktionen korrekt als genutzt | |
25 | | -| **Multi-File** | Analysiert ganze Python-Projekte rekursiv | |
26 | | -| **GUI** | Einfache Tkinter-Oberfläche, kein Terminal nötig | |
| 23 | +| **AST Analysis** | Precise analysis powered by the Python Abstract Syntax Tree (AST) | |
| 24 | +| **Import Tracking** | Detects used, unused, and duplicate imports | |
| 25 | +| **Method Catalog** | Lists all functions, methods, and classes in a structured layout | |
| 26 | +| **Duplicate Detection** | Finds similar code blocks with a configurable similarity threshold | |
| 27 | +| **Framework Awareness** | Recognizes implicit usage in Tkinter, requests, asyncio, and other frameworks | |
| 28 | +| **Callback Detection** | Correctly identifies callback functions as actively used | |
| 29 | +| **Multi-File Scan** | Recursively analyzes entire Python projects | |
| 30 | +| **Desktop GUI** | Clean Tkinter-based user interface; no terminal required for basic usage | |
27 | 31 |
|
28 | | -### Was unterscheidet MethodenAnalyser von pylint / flake8 / vulture? |
| 32 | +### How does MethodenAnalyser compare to pylint, flake8, vulture, and radon? |
29 | 33 |
|
30 | 34 | | Feature | MethodenAnalyser | pylint | flake8 | vulture | radon | |
31 | 35 | |---------|:---:|:---:|:---:|:---:|:---:| |
32 | | -| Ungenutzte Imports | ja | ja | teilweise | ja | nein | |
33 | | -| Ungenutzte Definitionen | ja | teilweise | nein | ja | nein | |
34 | | -| **Code-Ähnlichkeit** | ja | nein | nein | nein | nein | |
35 | | -| **Framework-Erkennung** | ja | teilweise | nein | nein | nein | |
36 | | -| **GUI** | ja | nein | nein | nein | nein | |
37 | | -| **Callback-Erkennung** | ja | nein | nein | teilweise | nein | |
38 | | -| Keine Installation | ja | nein | nein | nein | nein | |
| 36 | +| Unused Imports | **yes** | yes | partial | yes | no | |
| 37 | +| Unused Definitions | **yes** | partial | no | yes | no | |
| 38 | +| **Code Similarity** | **yes** | no | no | no | no | |
| 39 | +| **Framework Awareness** | **yes** | partial | no | no | no | |
| 40 | +| **GUI Interface** | **yes** | no | no | no | no | |
| 41 | +| **Callback Recognition** | **yes** | no | no | partial | no | |
| 42 | +| Zero Installation (Portable) | **yes** | no | no | no | no | |
39 | 43 |
|
40 | 44 | --- |
41 | 45 |
|
42 | 46 | ## Screenshot |
43 | 47 |
|
44 | | - |
| 48 | + |
45 | 49 |
|
46 | | -Die aktuelle Ansicht zeigt die dateibasierte Analyse mit GUI-Workflow statt reiner CLI-Ausgabe. |
| 50 | +*The desktop user interface displaying file-based analysis results and structural metrics.* |
47 | 51 |
|
48 | 52 | --- |
49 | 53 |
|
50 | 54 | ## Installation |
51 | 55 |
|
52 | | -Keine externen Laufzeit-Abhängigkeiten. Nur Python 3.10+ wird benötigt. |
| 56 | +MethodenAnalyser requires no external runtime dependencies. Only a Python 3.10+ environment is needed. |
53 | 57 |
|
54 | 58 | ```bash |
55 | 59 | git clone https://github.com/dev-bricks/MethodenAnalyser.git |
56 | 60 | cd MethodenAnalyser |
57 | 61 | python MethodenAnalyser3.py |
58 | 62 | ``` |
59 | 63 |
|
60 | | -Unter Windows kann das Tool auch per Doppelklick auf `START.bat` gestartet werden. |
| 64 | +On Windows, you can also start the tool by double-clicking `START.bat`. |
61 | 65 |
|
62 | 66 | --- |
63 | 67 |
|
64 | | -## Verwendung |
65 | | - |
66 | | -### Einzelne Datei analysieren |
67 | | - |
68 | | -1. Tool starten: `python MethodenAnalyser3.py` oder `START.bat`. |
69 | | -2. **Datei analysieren** klicken und eine `.py`-Datei auswählen. |
70 | | -3. Ergebnisse im Ausgabefenster prüfen. |
| 68 | +## Usage |
71 | 69 |
|
72 | | -### Ganzes Projekt analysieren |
| 70 | +### 1. Analyze a Single File via GUI |
| 71 | +1. Launch the tool: `python MethodenAnalyser3.py` or double-click `START.bat`. |
| 72 | +2. Click **Analyze File** (Datei analysieren) and select a `.py` file. |
| 73 | +3. Review the findings in the output text area. |
73 | 74 |
|
74 | | -1. **Projekt analysieren** klicken und einen Projektordner auswählen. |
75 | | -2. Alle `.py`-Dateien werden rekursiv durchsucht. |
76 | | -3. Der aggregierte Projekt-Report wird im Ausgabefenster angezeigt. |
| 75 | +### 2. Analyze a Project via GUI |
| 76 | +1. Click **Analyze Project** (Projekt analysieren) and select a folder. |
| 77 | +2. The tool recursively scans all `.py` files inside the directory. |
| 78 | +3. An aggregated project report is compiled and displayed. |
77 | 79 |
|
78 | | -### CLI-Modus für Automationen |
79 | | - |
80 | | -Die GUI bleibt Standard, zusätzlich kann MethodenAnalyser jetzt headless laufen: |
| 80 | +### 3. CLI Mode for Automations & CI/CD |
| 81 | +MethodenAnalyser can also run completely headless for terminal integration or CI pipelines: |
81 | 82 |
|
82 | 83 | ```bash |
83 | | -python MethodenAnalyser3.py --file pfad/zur/datei.py |
84 | | -python MethodenAnalyser3.py --project pfad/zum/projekt |
85 | | -python MethodenAnalyser3.py --file pfad/zur/datei.py --json-output |
86 | | -type pfad\zur\datei.py | python MethodenAnalyser3.py --stdin --json-output snippet.json |
87 | | -``` |
| 84 | +# Analyze a single file |
| 85 | +python MethodenAnalyser3.py --file path/to/file.py |
88 | 86 |
|
89 | | -`--json-output` schreibt zusätzlich den maschinenlesbaren Report `methodenanalyser-report-v1.json`. Mit eigenem Dateinamen kann der Report gezielt abgelegt werden; das Format ist in [EXPORTFORMAT.md](EXPORTFORMAT.md) dokumentiert. |
| 87 | +# Analyze an entire project folder |
| 88 | +python MethodenAnalyser3.py --project path/to/project |
90 | 89 |
|
91 | | -### Lokale Weboberfläche |
| 90 | +# Analyze a file and export findings to JSON |
| 91 | +python MethodenAnalyser3.py --file path/to/file.py --json-output |
92 | 92 |
|
93 | | -Für Snippets, einzelne Python-Dateien und kleine ZIP-Archive gibt es zusätzlich eine optionale lokale Weboberfläche: |
94 | | - |
95 | | -```bash |
96 | | -python webapp/server.py |
| 93 | +# Analyze via stdin and pipe output to a JSON file |
| 94 | +type path\to\file.py | python MethodenAnalyser3.py --stdin --json-output snippet.json |
97 | 95 | ``` |
98 | 96 |
|
99 | | -Unter Windows startet `START_WEBAPP.bat` denselben lokalen Server. Die Oberfläche läuft standardmäßig unter `http://127.0.0.1:8765/`, nutzt den bestehenden Analysekern und zeigt Text- sowie JSON-Reports an. ZIP-Uploads werden lokal an den Python-Prozess geschickt, dort temporär entpackt und als kleines Projekt analysiert. Zusätzlich kann die lokale Weboberfläche bestehende `methodenanalyser-report-v1.json`-Dateien importieren. Sie ist ein Hilfs-/Demo-Modus für denselben Rechner, keine Companion-App und keine eigene Mobile-Produktlinie. Details stehen in [WEBAPP.md](WEBAPP.md). |
100 | | - |
101 | | -Die PWA speichert den aktuellen Entwurf und den letzten JSON-Report lokal im Browser, bietet einen Install-Flow für Chromium-basierte Browser und hält die bereits geladene Oberfläche per Service Worker offline verfügbar. Für neue Analysen muss der lokale Python-Server trotzdem laufen. |
| 97 | +The `--json-output` flag exports a machine-readable report named `methodenanalyser-report-v1.json` (or a custom name if specified). Its structure is documented in [EXPORTFORMAT.md](EXPORTFORMAT.md). |
102 | 98 |
|
103 | | -Für Android-/iOS-Tests im selben WLAN kann derselbe lokale Dienst gezielt auf dem Netzwerk lauschen: |
| 99 | +### 4. Local Web Companion & PWA |
| 100 | +For browser-based code snippets, file uploads, or analyzing small ZIP archives, you can launch the optional local web helper: |
104 | 101 |
|
105 | 102 | ```bash |
106 | | -python webapp/server.py --host 0.0.0.0 --port 8765 |
| 103 | +python webapp/server.py |
107 | 104 | ``` |
108 | 105 |
|
109 | | -Die lokale Weboberfläche kann LAN-URLs anzeigen, falls der Server bewusst im Netzwerk freigegeben wird. Das bleibt ein technischer Testpfad, kein geplantes Android-/iOS-Produkt. |
110 | | -Zusätzlich bündelt die **PWA-Testkarte** Install-Status, Service-Worker-, Speicher- und Viewport-Diagnostik in einer kopierbaren Kurzfassung für lokale Browser-Smokes. |
111 | | - |
112 | | -### macOS- und Linux-Smoke |
| 106 | +Or double-click `START_WEBAPP.bat` on Windows. The server runs at `http://127.0.0.1:8765/` by default and utilizes the same AST analysis engine. |
| 107 | +* **PWA Support:** It acts as a Progressive Web App (PWA) with offline capabilities (service worker) and local browser draft saving. |
| 108 | +* **Report Import:** You can import existing `methodenanalyser-report-v1.json` files to view them in the browser. |
| 109 | +* **LAN Access:** For cross-device testing (e.g. previewing on mobile devices), make the server listen on your local network: |
| 110 | + ```bash |
| 111 | + python webapp/server.py --host 0.0.0.0 --port 8765 |
| 112 | + ``` |
| 113 | + For further details, consult [WEBAPP.md](WEBAPP.md). |
113 | 114 |
|
114 | | -Die Desktop-Version bleibt Windows-first, aber der Quellstand wird jetzt gezielt auch als Source-Smoke für macOS und Linux abgesichert. Lokal reicht dafür dieselbe Basis: |
| 115 | +### 5. macOS and Linux Source Verification |
| 116 | +While the GUI is optimized for Windows (using Tkinter), the codebase is fully verified to run from source on macOS and Linux. You can run unit tests and compile checks with: |
115 | 117 |
|
116 | 118 | ```bash |
117 | 119 | python -m py_compile MethodenAnalyser3.py manage_translations.py translator.py webapp/server.py |
118 | 120 | python -m unittest discover -s tests -v |
119 | 121 | ``` |
120 | 122 |
|
121 | | -Zusätzlich prüft die GitHub-Action denselben Stand automatisch auf Windows (Python 3.10 bis 3.12) sowie auf Ubuntu und macOS (jeweils Python 3.11). Damit bleiben Tkinter-Import, CLI und Web-Companion auch außerhalb von Windows im Blick, ohne bereits eine eigene Mac- oder Linux-Paketlinie zu versprechen. |
| 123 | +The repository includes a GitHub Actions workflow that executes this test suite across a matrix of Windows (Python 3.10-3.12), Ubuntu (Python 3.11), and macOS (Python 3.11). |
122 | 124 |
|
123 | | -Exit-Codes: |
| 125 | +--- |
| 126 | + |
| 127 | +## Exit Codes |
124 | 128 |
|
125 | | -- `0` = Analyse erfolgreich und keine Findings im Report |
126 | | -- `1` = Aufruf- oder Analysefehler |
127 | | -- `2` = Analyse erfolgreich, aber Findings vorhanden |
128 | | -- `3` = Projektanalyse mit Teilfehlern in einzelnen Dateien |
| 129 | +For CI/CD scripts, the tool returns the following exit codes: |
| 130 | +- `0` = Analysis succeeded, no issues/findings detected. |
| 131 | +- `1` = Syntax, argument, or analysis error. |
| 132 | +- `2` = Analysis succeeded, but findings (unused code, similar blocks) were detected. |
| 133 | +- `3` = Project analysis completed, but some individual files failed to parse. |
129 | 134 |
|
130 | 135 | --- |
131 | 136 |
|
132 | | -## Beispiel-Output |
| 137 | +## Example Output |
133 | 138 |
|
134 | 139 | ```text |
135 | | -=== ANALYSE: my_script.py === |
| 140 | +=== ANALYSIS: my_script.py === |
136 | 141 |
|
137 | | -IMPORTS (3 gesamt): |
138 | | - os - genutzt |
139 | | - json - genutzt |
140 | | - pathlib - möglicherweise ungenutzt |
| 142 | +IMPORTS (3 total): |
| 143 | + os - active |
| 144 | + json - active |
| 145 | + pathlib - potentially unused |
141 | 146 |
|
142 | | -DEFINITIONEN (5 gesamt): |
| 147 | +DEFINITIONS (5 total): |
143 | 148 | main() |
144 | 149 | load_config() |
145 | | - old_helper() - nicht referenziert |
| 150 | + old_helper() - no references found |
146 | 151 |
|
147 | | -ÄHNLICHE CODE-BLÖCKE (Schwellwert: 80%): |
148 | | - Zeilen 42-55 <-> Zeilen 88-101 (Ähnlichkeit: 91%) |
| 152 | +SIMILAR CODE BLOCKS (Threshold: 80%): |
| 153 | + Lines 42-55 <-> Lines 88-101 (Similarity: 91%) |
149 | 154 | ``` |
150 | 155 |
|
151 | 156 | --- |
152 | 157 |
|
153 | | -## Konfiguration |
| 158 | +## Configuration |
154 | 159 |
|
155 | | -Im Quellcode anpassbar: |
| 160 | +You can customize the detection parameters directly inside the source code: |
156 | 161 |
|
157 | 162 | ```python |
158 | | -SIMILARITY_THRESHOLD = 0.8 # Schwellwert für Duplikat-Erkennung |
159 | | -WINDOW_GEOMETRY = "1200x700" # Fenstergröße |
| 163 | +SIMILARITY_THRESHOLD = 0.8 # Similarity threshold (0.0 to 1.0) for duplicate detection |
| 164 | +WINDOW_GEOMETRY = "1200x700" # Desktop window dimensions |
160 | 165 | ``` |
161 | 166 |
|
162 | 167 | --- |
163 | 168 |
|
164 | | -## Datenschutz / Privacy |
| 169 | +## Data & Privacy |
165 | 170 |
|
166 | | -MethodenAnalyser arbeitet vollständig lokal. Der ausgewählte Python-Code, Dateipfade und Analyseergebnisse werden nicht an den Entwickler oder externe Dienste übertragen. |
| 171 | +MethodenAnalyser operates 100% locally. Your Python code, local file paths, and analysis results are never sent over the internet. There are no analytics, cloud integrations, telemetry features, or third-party tracking scripts. |
167 | 172 |
|
168 | | -Release-Artefakte wie EXE-Dateien, lokale Builds und Store-Pakete bleiben außerhalb des Git-Repositorys und gehören in lokale `releases/`-Ordner oder GitHub Releases. |
| 173 | +Build, packaging, and sign-related files are configured in `.gitignore` to stay outside of the version control system. |
169 | 174 |
|
170 | | -## Repository-Hygiene |
| 175 | +## Repository Hygiene |
171 | 176 |
|
172 | | -Stand: 2026-05-16 |
173 | | - |
174 | | -- GitHub-Remote: `dev-bricks/MethodenAnalyser` |
175 | | -- Lokaler Branch `master` war vor diesem Pflege-Update synchron mit `origin/master` (`0 ahead / 0 behind`). |
176 | | -- Secret-/Privacy-Check: keine Tokens, Schlüssel oder Credentials in den getrackten Projektdateien gefunden. |
177 | | -- Keine Telemetrie, keine Netzwerkverbindungen und keine Cloud-Synchronisierung aus der Anwendung heraus. |
178 | | -- Lokale Build-, Release-, Coverage-, Cache- und Signierartefakte sind über `.gitignore` ausgeschlossen. |
179 | | -- Interne Wartungsnotizen wie `AUFGABEN.txt` bleiben lokal und werden nicht im Git-Quellbaum veröffentlicht. |
180 | | -- Vor Veröffentlichungen: `git status --short`, Secret-Scan und `python -m py_compile MethodenAnalyser3.py manage_translations.py translator.py` ausführen. |
| 177 | +- GitHub Remote: `dev-bricks/MethodenAnalyser` |
| 178 | +- Local `master` branch is synchronized with `origin/master` (`0 ahead / 0 behind`). |
| 179 | +- Secret & Privacy Scans: verified to have no API keys, private tokens, or credentials in tracked files. |
| 180 | +- Before committing: run `git status --short`, execute a secret scan, and verify local compilation using `python -m py_compile MethodenAnalyser3.py manage_translations.py translator.py`. |
181 | 181 |
|
182 | 182 | --- |
183 | 183 |
|
184 | | -## Entwicklung / Verification |
| 184 | +## Development & Testing |
185 | 185 |
|
186 | 186 | ```bash |
| 187 | +# Verify Python syntax and AST compilation |
187 | 188 | python -m py_compile MethodenAnalyser3.py manage_translations.py translator.py webapp/server.py |
| 189 | +
|
| 190 | +# Run unit tests |
188 | 191 | python -m unittest discover -s tests -v |
189 | 192 | ``` |
190 | 193 |
|
191 | | -GitHub Actions führt denselben Smoke-Test jetzt auf Windows (Python 3.10 bis 3.12) sowie zusätzlich auf Ubuntu und macOS (Python 3.11) aus. |
192 | | - |
193 | | -Für Crawler, LLMs und Verzeichnisdienste liegt ein knapper maschinenlesbarer Projektkontext in [llms.txt](llms.txt). Die Community-Workflows verwenden aktuelle `actions/stale`- und `actions/first-interaction`-Versionen. |
194 | | - |
195 | | ---- |
196 | | - |
197 | | -## Lizenz |
198 | | - |
199 | | -Dieses Projekt steht unter der [MIT License](LICENSE). |
| 194 | +GitHub Actions runs these smoke tests on every push. For LLM agents and crawlers, a lightweight machine-readable context file is provided in [llms.txt](llms.txt). |
200 | 195 |
|
201 | 196 | --- |
202 | 197 |
|
203 | | -## English |
204 | | - |
205 | | -MethodenAnalyser is a static Python code analyzer with AST analysis, duplicate detection, and a small Tkinter GUI. |
206 | | - |
207 | | -### Features |
208 | | - |
209 | | -- AST-based static analysis |
210 | | -- Duplicate code detection |
211 | | -- Method and class catalog |
212 | | -- Callback and framework awareness |
213 | | -- Recursive project analysis |
214 | | -- No external runtime dependencies |
| 198 | +## License |
215 | 199 |
|
216 | | -### Installation |
217 | | - |
218 | | -```bash |
219 | | -git clone https://github.com/dev-bricks/MethodenAnalyser.git |
220 | | -cd MethodenAnalyser |
221 | | -python "MethodenAnalyser3.py" |
222 | | -``` |
223 | | - |
224 | | -### License |
225 | | - |
226 | | -See [LICENSE](LICENSE) for details. |
| 200 | +This project is licensed under the [MIT License](LICENSE). |
227 | 201 |
|
228 | 202 | --- |
229 | 203 |
|
230 | | -## Haftung / Liability |
231 | | - |
232 | | -Dieses Projekt ist eine **unentgeltliche Open-Source-Schenkung** im Sinne der §§ 516 ff. BGB. Die Haftung des Urhebers ist gemäß **§ 521 BGB** auf **Vorsatz und grobe Fahrlässigkeit** beschränkt. Ergänzend gilt der Haftungsausschluss der MIT License. |
| 204 | +## Liability / Haftung |
233 | 205 |
|
234 | | -Nutzung auf eigenes Risiko. Keine Wartungszusage, keine Verfügbarkeitsgarantie, keine Gewähr für Fehlerfreiheit oder Eignung für einen bestimmten Zweck. |
| 206 | +This project is a gratuitous open-source donation ("unentgeltliche Open-Source-Schenkung" under German Civil Code §§ 516 ff. BGB). Under German law (**§ 521 BGB**), liability is limited to intent and gross negligence. The standard MIT License disclaimer applies globally. |
235 | 207 |
|
236 | | -This project is an unpaid open-source donation. Liability is limited to intent and gross negligence (§ 521 German Civil Code). Use at your own risk. No warranty, no maintenance guarantee, no fitness-for-purpose assumed. |
| 208 | +Use at your own risk. No support guarantees, no warranty for fitness for a particular purpose or error-free operation. |
0 commit comments