$npx -y skills add likweitan/abap-skills --skill abapCheck and improve ABAP code quality using abaplint and Clean ABAP principles. Use this skill when users ask to check, lint, validate, review, or analyze ABAP code for syntax errors, clean code compliance, code quality, best practices, or adherence to Clean ABAP guidelines. Also u
| 1 | # ABAP |
| 2 | |
| 3 | Check and improve ABAP code quality using two complementary approaches: |
| 4 | |
| 5 | - **abaplint**: Automated static analysis via CLI, checking syntax, types, and configurable rules |
| 6 | - **Clean ABAP**: Manual review against Clean ABAP style guide principles |
| 7 | |
| 8 | ## Workflow |
| 9 | |
| 10 | 1. **Determine check type** based on user request: |
| 11 | - If the user asks to lint, run abaplint, or check syntax: use **abaplint** |
| 12 | - If the user asks for clean code review, best practices, or code quality: use **Clean ABAP review** |
| 13 | - If unclear or the user asks for a full check: use **both** |
| 14 | |
| 15 | 2. **For abaplint checks**: |
| 16 | - Verify `abaplint` is installed (`npx @abaplint/cli --version` or `abaplint --version`) |
| 17 | - If not installed, install with: `npm install @abaplint/cli -g` |
| 18 | - Check if `abaplint.json` exists in the project root |
| 19 | - If no config exists, help the user create one (see starter configs in `references/abaplint.md`) |
| 20 | - Run `abaplint` in the project root directory |
| 21 | - Parse and present findings to the user |
| 22 | |
| 23 | 3. **For Clean ABAP reviews**: |
| 24 | - Read the ABAP code provided by the user |
| 25 | - Check against Clean ABAP categories: Names, Language, Constants, Variables, Tables, Strings, Booleans, Conditions, Ifs, Classes, Methods, Error Handling, Comments, Formatting, Testing |
| 26 | - Identify violations with specific line references |
| 27 | - Provide actionable recommendations with code examples |
| 28 | - Prioritize issues by impact (critical, major, minor) |
| 29 | |
| 30 | ## abaplint Quick Start |
| 31 | |
| 32 | Run in project root: |
| 33 | |
| 34 | ```bash |
| 35 | abaplint |
| 36 | ``` |
| 37 | |
| 38 | Generate default config (all rules): |
| 39 | |
| 40 | ```bash |
| 41 | abaplint -d > abaplint.json |
| 42 | ``` |
| 43 | |
| 44 | For detailed abaplint configuration including starter configs for On-Premise, Steampunk/BTP, and HANA compatibility, read `references/abaplint.md`. |
| 45 | |
| 46 | ## Clean ABAP Check Categories |
| 47 | |
| 48 | ### Names |
| 49 | |
| 50 | - Use descriptive names, snake*case, no Hungarian notation (iv*, lv*, lt*) |
| 51 | - Nouns for classes, verbs for methods, no noise words |
| 52 | |
| 53 | ### Language |
| 54 | |
| 55 | - Prefer OO over procedural, functional over imperative |
| 56 | - Use modern syntax: NEW, inline declarations, table expressions |
| 57 | |
| 58 | ### Constants |
| 59 | |
| 60 | - No magic numbers, use ENUM or grouped constants |
| 61 | |
| 62 | ### Variables |
| 63 | |
| 64 | - Prefer inline declarations, no chained DATA |
| 65 | |
| 66 | ### Tables |
| 67 | |
| 68 | - No DEFAULT KEY, use INSERT INTO TABLE, LINE_EXISTS, WHERE clauses |
| 69 | |
| 70 | ### Strings |
| 71 | |
| 72 | - Backticks for literals, pipes for string templates |
| 73 | |
| 74 | ### Booleans |
| 75 | |
| 76 | - Use ABAP_BOOL, ABAP_TRUE/ABAP_FALSE, XSDBOOL |
| 77 | |
| 78 | ### Conditions |
| 79 | |
| 80 | - Positive conditions, IS NOT over NOT IS, predicative method calls |
| 81 | |
| 82 | ### Ifs |
| 83 | |
| 84 | - No empty IF branches, CASE over ELSE IF, nesting depth <= 3 |
| 85 | |
| 86 | ### Methods |
| 87 | |
| 88 | - Instance over static, RETURNING over EXPORTING, <= 3 parameters, <= 20 lines |
| 89 | |
| 90 | ### Error Handling |
| 91 | |
| 92 | - Exceptions over return codes, class-based exceptions, no catching CX_ROOT |
| 93 | |
| 94 | ### Comments |
| 95 | |
| 96 | - Explain why not what, " over \*, no commented-out code |
| 97 | |
| 98 | ### Formatting |
| 99 | |
| 100 | - One statement per line, <= 120 chars, consistent indentation |
| 101 | |
| 102 | ### Testing |
| 103 | |
| 104 | - Given-when-then structure, focused assertions, dependency injection |
| 105 | |
| 106 | ## Output Format |
| 107 | |
| 108 | Structure analysis results as: |
| 109 | |
| 110 | ``` |
| 111 | # ABAP Check Results |
| 112 | |
| 113 | ## abaplint Findings |
| 114 | [abaplint output, grouped by severity] |
| 115 | |
| 116 | ## Clean ABAP Review |
| 117 | |
| 118 | ### Summary |
| 119 | - Total Issues: [count] |
| 120 | - Critical: [count] | Major: [count] | Minor: [count] |
| 121 | |
| 122 | ### Critical Issues |
| 123 | #### [Category] - [Issue Title] |
| 124 | **Location:** Line [X] / Method [name] |
| 125 | **Problem:** [description] |
| 126 | **Recommendation:** [how to fix] |
| 127 | |
| 128 | ### Major Issues |
| 129 | [Same format] |
| 130 | |
| 131 | ### Minor Issues |
| 132 | [Same format] |
| 133 | |
| 134 | ### Positive Observations |
| 135 | - [Things done well] |
| 136 | ``` |
| 137 | |
| 138 | ## References |
| 139 | |
| 140 | - **abaplint config & setup**: Read `references/abaplint.md` for installation, configuration options, and starter configs |
| 141 | - **Complete Clean ABAP guide**: Read `references/CleanABAP.md` for full style guide with rationale and examples |
| 142 | - **Quick patterns**: Read `references/quick-reference.md` for condensed good/bad code examples |
| 143 | - **Review checklist**: Read `references/checklist.md` for systematic review checklist |