Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
| de:modul:ffit:3-jahr:cicd:learningunits:lu01:c [2025/12/08 15:33] – apeter | de:modul:ffit:3-jahr:cicd:learningunits:lu01:c [2026/12/01 09:04] (aktuell) – apeter | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| - | ====== LU01c - Testing Doubles | + | ====== LU01c - Linting & Formatting |
| - | ==== Übersicht | + | ==== Formatting |
| - | ^ Name ^ Beschreibung ^ Beispiel ^ | + | Formatter sorgen dafür, dass der gemeinsame Code einheitlich formatiert wird. Oftmals besitzen IDE bereits eine Standard-Formattierung oder die Möglichkeit, |
| - | | Mock | ... | ... | | + | |
| - | | Fake | ... | ... | | + | |
| - | | Spy | ... | ... | | + | |
| - | | Dummy | ... | ... | | + | |
| - | | Stub | ... | ... | | + | |
| - | | Fake | ... | ... | | + | |
| + | Beispiele von IDE-spezifischen Formatierungen: | ||
| + | * **IntelliJ**: | ||
| + | * **Visual Studio Code**: Settings unter '' | ||
| + | * **Eclipse: Code Style Formatter**: | ||
| + | * **Diverse IDE**: '' | ||
| - | '' | + | ^ IntelliJ Project.xml ^ VS Code settings.json ^ Eclipse java-formatter.xml ^ .editorconfig ^ |
| + | | < | ||
| + | </ | ||
| + | < | ||
| + | <!-- Tab size --> | ||
| + | < | ||
| + | <option name=" | ||
| + | <option name=" | ||
| + | <option name=" | ||
| + | </ | ||
| + | |||
| + | <!-- New line at end of file --> | ||
| + | <option name=" | ||
| + | </ | ||
| + | ...</ | ||
| + | // Tab size | ||
| + | " | ||
| + | " | ||
| + | |||
| + | // New line at end of file | ||
| + | " | ||
| + | |||
| + | // Java-specific | ||
| + | " | ||
| + | |||
| + | // Remove unused imports | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | }</ | ||
| + | <profile kind=" | ||
| + | |||
| + | <!-- Tab size --> | ||
| + | <setting id=" | ||
| + | <setting id=" | ||
| + | <setting id=" | ||
| + | |||
| + | <!-- New line at end of file --> | ||
| + | <setting id=" | ||
| + | |||
| + | </ | ||
| + | ...</ | ||
| + | [*] | ||
| + | indent_style = space | ||
| + | indent_size = 4 | ||
| + | tab_width = 4 | ||
| + | |||
| + | end_of_line = lf | ||
| + | insert_final_newline = true | ||
| + | trim_trailing_whitespace = true | ||
| + | ...</ | ||
| + | |||
| + | Das Problem von solchen Konfigurationen ist ihre Abhängigkeit zu der IDE. Sobald ein Teammitglied eine andere IDE nutzt, kommt es früher oder später zu Formatierungsunterschieden, | ||
| + | Ein weiteres Nachteil ist, dass solche Formatierungen in der Regel nicht in die Build-Pipeline eingebaut werden können. | ||
| + | |||
| + | Daher würde ich IDE-unabhängige Formatter bei komplexeren Formatierungsregeln bevorzugen. Einfache Regeln (Einrückungen, | ||
| + | |||
| + | Beispiele von IDE-unabhängigen Formatter-Bibliotheken: | ||
| + | * Javascript, Typescript, HTML, CSS, JSON -> Prettier | ||
| + | * Python -> black, pep8, ... | ||
| + | * Java -> Google Java Format | ||
| + | |||
| + | ==== Linting ==== | ||
| + | Linting (dt. " | ||
| + | |||
| + | Gängige Linter-Bibliotheken | ||
| + | * Javascript, Typescript -> ESLint(https:// | ||
| + | * Python -> Pylint (https:// | ||
| + | * Java -> PMD (https:// | ||
| + | * Diverse Sprachen -> SonarQube for IDE (SonarLint) | ||