Skip to content

Commit 42cf834

Browse files
Update optional-parameters.md
1 parent 52b2c74 commit 42cf834

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

docs/checks/optional-parameters.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,20 @@
1-
# code pal for ABAP
2-
31
[code pal for ABAP](../../README.md) > [Documentation](../check_documentation.md) > [Optional Parameters](optional-parameters.md)
42

53
## Optional Parameters
64

75
### What is the Intent of the Check?
86

9-
Avoid usage of `OPTIONAL` parameters because they confuse callers:
7+
This check searches for OPTIONAL parameter in method signatures. It is recommended to avoid the usage of `OPTIONAL` parameters because they might confuse the consumers of the class:
108

11-
* Which ones are really required?
12-
* Which combinations are valid?
13-
* Which ones exclude each other?
9+
* Which parameters are really required?
10+
* Which combination of parameters are valid?
11+
* Which parameters exclude each other?
1412

1513
Multiple methods with specific parameters for the use case avoid this confusion by giving clear guidance which parameter combinations are valid and expected.
1614

1715
### How to solve the issue?
1816

19-
Splitting methods instead of adding `OPTIONAL` parameters.
20-
21-
### What to do in case of exception?
22-
23-
You can suppress Code Inspector findings generated by this check using the pseudo comment `"#EC OPTL_PARAM`.
24-
The pseudo comment has to be placed after the method declaration.
25-
26-
```abap
27-
METHODS do_one_or_the_other
28-
IMPORTING
29-
what_i_need TYPE string OPTIONAL
30-
something_else TYPE i OPTIONAL. "#EC OPTL_PARAM
31-
```
17+
Splitting methods (creating new ones) instead of adding `OPTIONAL` parameters.
3218

3319
### Example
3420

@@ -48,6 +34,17 @@ After the check:
4834
METHODS do_another_thing IMPORTING something_else TYPE i.
4935
```
5036

37+
### What to do in case of exception?
38+
39+
In exceptional cases, you can suppress this finding by using the pseudo comment `"#EC OPTL_PARAM` which should to be placed after the method declaration:
40+
41+
```abap
42+
METHODS do_one_or_the_other
43+
IMPORTING
44+
what_i_need TYPE string OPTIONAL
45+
something_else TYPE i OPTIONAL. "#EC OPTL_PARAM
46+
```
47+
5148
### Further Readings & Knowledge
5249

5350
* [ABAP Styleguides on Clean Code](https://github.com/SAP/styleguides/blob/master/clean-abap/CleanABAP.md#split-methods-instead-of-adding-optional-parameters)

0 commit comments

Comments
 (0)