Skip to content

Commit

Permalink
version 1.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgrassau committed Nov 6, 2023
1 parent 23dd235 commit 1748662
Show file tree
Hide file tree
Showing 28 changed files with 405 additions and 65 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ while giving you full control over which rules are used and how.
![ABAP cleaner - code cleanup at a keystroke](docs/images/cleanup-example.png "ABAP cleaner - code cleanup at a keystroke")

With ABAP cleaner, you can clean any amount of code from a single statement to an entire code document
with **one keystroke**. ABAP cleaner then applies **60+ different [cleanup rules](docs/rules.md)** to your code section,
with **one keystroke**. ABAP cleaner then applies **65+ different [cleanup rules](docs/rules.md)** to your code section,
cleaning approx. 1 MB of code per second.

> Please don't get us wrong: Of course, an automated tool can NOT replace all other clean code efforts.
Expand Down Expand Up @@ -78,7 +78,7 @@ allowing you to stay in SAP GUI and do the cleanup with *Ctrl + C*, *Ctrl + V*.
### Scope of the Tool

ABAP cleaner can be used to clean up both existing and new code, both product code and test code,
both with a "broadband" approach (simultaneously applying 60+ different rules)
both with a "broadband" approach (simultaneously applying 65+ different rules)
and a focused approach (cleaning with a limited selection of rules).

ABAP cleaner was implemented with object-oriented ABAP in mind, but it may also be used for code in reports and functions.
Expand Down
2 changes: 1 addition & 1 deletion com.sap.adt.abapcleaner.app/abapcleaner.product
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?pde version="3.5"?>

<product name="ABAP cleaner" uid="com.sap.adt.abapcleaner.app" application="com.sap.adt.abapcleaner.standalone.app" version="1.10.1.qualifier" useFeatures="true" includeLaunchers="true">
<product name="ABAP cleaner" uid="com.sap.adt.abapcleaner.app" application="com.sap.adt.abapcleaner.standalone.app" version="1.11.0" useFeatures="true" includeLaunchers="true">

<configIni use="default">
</configIni>
Expand Down
4 changes: 2 additions & 2 deletions com.sap.adt.abapcleaner.app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<modelVersion>4.0.0</modelVersion>
<groupId>com.sap.adt.abapcleaner</groupId>
<artifactId>com.sap.adt.abapcleaner.app</artifactId>
<version>1.10.1-SNAPSHOT</version>
<version>1.11.0</version>
<name>com.sap.adt.abapcleaner.app</name>
<packaging>eclipse-repository</packaging>

<parent>
<artifactId>parent</artifactId>
<groupId>com.sap.adt.abapcleaner</groupId>
<version>1.10.1-SNAPSHOT</version>
<version>1.11.0</version>
<relativePath>../</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion com.sap.adt.abapcleaner.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="com.sap.adt.abapcleaner.feature"
label="ABAP cleaner"
version="1.10.1.qualifier">
version="1.11.0">

<description>
ABAP cleaner plug-in for ABAP Development Tools
Expand Down
4 changes: 2 additions & 2 deletions com.sap.adt.abapcleaner.feature/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<modelVersion>4.0.0</modelVersion>
<artifactId>com.sap.adt.abapcleaner.feature</artifactId>
<groupId>com.sap.adt.abapcleaner</groupId>
<version>1.10.1-SNAPSHOT</version>
<version>1.11.0</version>
<name>com.sap.adt.abapcleaner.feature</name>
<packaging>eclipse-feature</packaging>

<parent>
<artifactId>parent</artifactId>
<groupId>com.sap.adt.abapcleaner</groupId>
<version>1.10.1-SNAPSHOT</version>
<version>1.11.0</version>
<relativePath>../</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion com.sap.adt.abapcleaner.gui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: com.sap.adt.abapcleaner.gui;singleton:=true
Bundle-Version: 1.10.1.qualifier
Bundle-Version: 1.11.0
Bundle-Vendor: %Provider-Name
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11
Expand Down
4 changes: 2 additions & 2 deletions com.sap.adt.abapcleaner.gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<modelVersion>4.0.0</modelVersion>
<groupId>com.sap.adt.abapcleaner</groupId>
<artifactId>com.sap.adt.abapcleaner.gui</artifactId>
<version>1.10.1-SNAPSHOT</version>
<version>1.11.0</version>
<name>com.sap.adt.abapcleaner.gui</name>
<packaging>eclipse-plugin</packaging>

<parent>
<artifactId>parent</artifactId>
<groupId>com.sap.adt.abapcleaner</groupId>
<version>1.10.1-SNAPSHOT</version>
<version>1.11.0</version>
<relativePath>../</relativePath>
</parent>

Expand Down
4 changes: 2 additions & 2 deletions com.sap.adt.abapcleaner.updatesite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<artifactId>com.sap.adt.abapcleaner.updatesite</artifactId>
<version>1.10.1-SNAPSHOT</version>
<version>1.11.0</version>
<name>ABAP Cleaner for ABAP Development Tools (ADT)</name>
<packaging>eclipse-repository</packaging>

<parent>
<artifactId>parent</artifactId>
<groupId>com.sap.adt.abapcleaner</groupId>
<version>1.10.1-SNAPSHOT</version>
<version>1.11.0</version>
<relativePath>../</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion com.sap.adt.abapcleaner/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: com.sap.adt.abapcleaner;singleton:=true
Bundle-Version: 1.10.1.qualifier
Bundle-Version: 1.11.0
Bundle-Vendor: %Provider-Name
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-11
Expand Down
4 changes: 2 additions & 2 deletions com.sap.adt.abapcleaner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<modelVersion>4.0.0</modelVersion>
<groupId>com.sap.adt.abapcleaner</groupId>
<artifactId>com.sap.adt.abapcleaner</artifactId>
<version>1.10.1-SNAPSHOT</version>
<version>1.11.0</version>
<name>com.sap.adt.abapcleaner</name>
<packaging>eclipse-plugin</packaging>

<parent>
<artifactId>parent</artifactId>
<groupId>com.sap.adt.abapcleaner</groupId>
<version>1.10.1-SNAPSHOT</version>
<version>1.11.0</version>
<relativePath>../</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private Term(Token firstToken, boolean expandWithArithmeticOps) throws Unexpecte
// cp. for the following: Term.isFirstTokenAllowed(Token)
if (firstToken.isAnyKeyword(ABAP.constructorOperators)) {
// constructor expression, see ABAP Reference, "Constructor Operators for Constructor Expressions", https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenconstructor_expressions.htm
token = token.getNext();
token = token.getNextCodeToken();
} else if (firstToken.isAnyKeyword("DATA(", "FINAL(")) {
// continue below
} else if (firstToken.isKeyword() && firstToken.textStartsWith("TEXT-")) {
Expand All @@ -165,18 +165,18 @@ private Term(Token firstToken, boolean expandWithArithmeticOps) throws Unexpecte
}
}

// optionally, continue reading if token.getNext() is a binary operator (e.g. if called from ValueStatementRule.createTableFromAssignmentSequence())
// optionally, continue reading if token is followed by a binary operator (e.g. if called from ValueStatementRule.createTableFromAssignmentSequence())
// like in the parameter assignment "amount = <ls_tdc_ev_pob>-event_based-list_price_per_unit * <ls_tdc_ev_pob>-event_based-qty / 2"
if (expandWithArithmeticOps) {
while (token.getNext() != null && token.getNext().textEqualsAny(binaryOperators)) {
token = token.getNext().getNext();
while (token.getNextCodeToken() != null && token.getNextCodeToken().textEqualsAny(binaryOperators)) {
token = token.getNextCodeToken().getNextCodeToken();
if (token.startsStringTemplate()) {
while (!token.endsStringTemplate()) {
token = token.getNextSibling();
}
} else {
if (token.isAnyKeyword(ABAP.constructorOperators)) // e.g. "... + COND any_data_element( WHEN ... THEN ... )
token = token.getNext();
token = token.getNextCodeToken();
while (token.getOpensLevel()) {
token = token.getNextSibling(); // the next sibling closes the level again, but might open another level
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public static String getVersion() {

public static Release[] getReleases() {
return new Release[] {
Release.create("1.11.0", 2023, 11, 6),
Release.create("1.10.0", 2023, 11, 1),
Release.create("1.9.0", 2023, 10, 30),
Release.create("1.8.0", 2023, 10, 23),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class NeedlessParenthesesRule extends RuleForLogicalExpressions {
public String getHintsAndRestrictions() { return "If parentheses are removed, '" + AlignLogicalExpressionsRule.DEFAULT_NAME + "' is executed, even if it is otherwise deactivated."; }

@Override
public LocalDate getDateCreated() { return LocalDate.of(2023, 11, 1); }
public LocalDate getDateCreated() { return LocalDate.of(2023, 11, 2); }

@Override
public RuleReference[] getReferences() { return references; }
Expand Down
9 changes: 9 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ as well as bugfixes of reported issues, i.e. anything that enhances or changes t
For a complete list of changes (including documentation, tests, refactoring etc.), please refer to
the list of [commits](../../../commits/main).

## 2023-11-06 (version 1.11.0)

**Thanks** a lot to [**jan-jezek**](https://github.com/jan-jezek), [**jelliottp**](https://github.com/jelliottp) and
[**ConjuringCoffee**](https://github.com/ConjuringCoffee) for opening the issues that led to these new features!

* Added new rule '**Remove needless parentheses**' ([#105](../../../issues/105))
* Added new rule '**Standardize assertion parameter order**' ([#85](../../../issues/85))
* Enhanced rule '**Unchain into multiple statements**' for **TYPES: BEGIN OF** and related table types ([#94](../../../issues/94))

## 2023-11-01 (version 1.10.0)

**Thanks a lot**, [**ConjuringCoffee**](https://github.com/ConjuringCoffee), [**csopaki**](https://github.com/csopaki),
Expand Down
4 changes: 3 additions & 1 deletion docs/rules.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Available Cleanup Rules

ABAP cleaner offers 64 cleanup rules with a total of 226 configuration options:
ABAP cleaner offers 66 cleanup rules with a total of 235 configuration options:

## Empty Lines

Expand Down Expand Up @@ -43,6 +43,7 @@ ABAP cleaner offers 64 cleanup rules with a total of 226 configuration options:
* [Prefer =, <>, <= etc. to EQ, NE, LE etc.](rules/ComparisonOperatorRule.md)
* [Prefer IS NOT to NOT IS](rules/NotIsRule.md)
* [Move AND/OR etc. from line end to next line start](rules/LogicalOperatorPositionRule.md)
* [Remove needless parentheses](rules/NeedlessParenthesesRule.md)
* [Remove empty commands](rules/EmptyCommandRule.md)
* [Shorten VALUE statements](rules/ValueStatementRule.md)
* [Remove the self-reference me->](rules/SelfReferenceMeRule.md)
Expand All @@ -64,6 +65,7 @@ ABAP cleaner offers 64 cleanup rules with a total of 226 configuration options:
* [Use assert\_true and assert\_false](rules/AssertEqualsBooleanRule.md)
* [Use assert\_subrc instead of assert\_equals](rules/AssertEqualsSubrcRule.md)
* [Use assert class instead of ASSERT](rules/AssertClassRule.md)
* [Standardize assertion parameter order](rules/AssertParameterOrderRule.md)

## Pretty Printer

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/AssertClassRule.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[<-- previous rule](AssertEqualsSubrcRule.md) | [overview](../rules.md) | [next rule -->](UpperAndLowerCaseRule.md)
[<-- previous rule](AssertEqualsSubrcRule.md) | [overview](../rules.md) | [next rule -->](AssertParameterOrderRule.md)

# Use assert class instead of ASSERT

Expand Down
132 changes: 132 additions & 0 deletions docs/rules/AssertParameterOrderRule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
[<-- previous rule](AssertClassRule.md) | [overview](../rules.md) | [next rule -->](UpperAndLowerCaseRule.md)

# Standardize assertion parameter order

Rearranges parameters in CL\_ABAP\_UNIT\_ASSERT calls to follow a standardized order for expected and actual values.

If an assert class for product code exists with signatures similar to CL\_ABAP\_UNIT\_ASSERT \(see rule 'Use assert class instead of ASSERT'\), calls to this class can be processed, too.

## Options

* Ensure order of parameters for expectation and actual value:
* Methods comparing values \(ASSERT\_EQUALS..., \_DIFFERS, \_THAT, \_CHAR...\) \[expectation first \(EXP\)\]
* Methods checking numbers, text and tables \(\_NUMBER..., \_TEXT\_..., \_TABLE\_...\) \[expectation first \(LOWER..UPPER, PATTERN, LINE\)\]
* Methods checking return code \(ASSERT\_SUBRC, \_RETURN\_CODE\): \[expectation first \(EXP\)\]
* Product code assert class name: \[\]

## Examples


```ABAP
METHOD test_anything.
" given
prepare_test_case( ).
" when
call_method_under_test( ).
" then
" 1. ASSERT_EQUALS[_FLOAT], ASSERT_DIFFERS, ASSERT_CHAR_CP, ASSERT_CHAR_NP, ASSERT_THAT, ASSUME_THAT:
" the signatures of these methods start with parameter ACT, but you may want calls to start with EXP:
cl_abap_unit_assert=>assert_equals( act = ms_data-item_type
exp = if_any_interface=>co_any_item_type ).
cl_abap_unit_assert=>assert_equals( msg = 'unexpected value for component1!'
exp = 'new value' " comment on exp
act = lts_act_table[ 1 ]-component1 ).
cl_abap_unit_assert=>assert_differs( act = lo_atc_item_instance->ms_data-item_category
exp = if_any_interface=>co_any_item_category
msg = 'unexpected item category'
quit = if_aunit_constants=>quit-no ).
cl_abap_unit_assert=>assert_differs( exp = 3 act = lines( lts_act_table ) ).
cl_abap_unit_assert=>assert_char_cp( act = lt_result[ 1 ] exp = |*;'-z2;*| ).
" 2. ASSERT_NUMBER_BETWEEN, ASSERT_TEXT[_NOT]_MATCHES, ASSERT_TABLE[_NOT]_CONTAINS:
" the signatures of these methods start with the parameters for the expectation (UPPER, LOWER;
" PATTERN; LINE), followed by the actual value (NUMBER; TEXT; TABLE)
cl_abap_unit_assert=>assert_number_between( " must be between 5 and 10 incl.
number = lv_result_value
upper = 10
lower = 5 ).
cl_abap_unit_assert=>assert_text_matches( text = lv_act_message_text
pattern = lv_exp_message_pattern ).
cl_abap_unit_assert=>assert_table_not_contains( line = ls_deleted_table_line
table = lt_act_table
msg = 'deletion of line failed' ).
" 3. ASSERT_SUBRC, ASSERT_RETURN_CODE, ASSUME_RETURN_CODE: parameter ACT has SY-SUBRC as its default value
" these methods use SY-SUBRC as the default value for parameter SY-SUBRC; the signature starts with EXP
cl_abap_unit_assert=>assert_subrc( quit = if_aunit_constants=>quit-no
exp = 4 ).
cl_abap_unit_assert=>assert_return_code( exp = 4
act = lv_return_code ).
ENDMETHOD.
```

Resulting code:

```ABAP
METHOD test_anything.
" given
prepare_test_case( ).
" when
call_method_under_test( ).
" then
" 1. ASSERT_EQUALS[_FLOAT], ASSERT_DIFFERS, ASSERT_CHAR_CP, ASSERT_CHAR_NP, ASSERT_THAT, ASSUME_THAT:
" the signatures of these methods start with parameter ACT, but you may want calls to start with EXP:
cl_abap_unit_assert=>assert_equals( exp = if_any_interface=>co_any_item_type
act = ms_data-item_type ).
cl_abap_unit_assert=>assert_equals( exp = 'new value' " comment on exp
act = lts_act_table[ 1 ]-component1
msg = 'unexpected value for component1!' ).
cl_abap_unit_assert=>assert_differs( exp = if_any_interface=>co_any_item_category
act = lo_atc_item_instance->ms_data-item_category
msg = 'unexpected item category'
quit = if_aunit_constants=>quit-no ).
cl_abap_unit_assert=>assert_differs( exp = 3 act = lines( lts_act_table ) ).
cl_abap_unit_assert=>assert_char_cp( exp = |*;'-z2;*| act = lt_result[ 1 ] ).
" 2. ASSERT_NUMBER_BETWEEN, ASSERT_TEXT[_NOT]_MATCHES, ASSERT_TABLE[_NOT]_CONTAINS:
" the signatures of these methods start with the parameters for the expectation (UPPER, LOWER;
" PATTERN; LINE), followed by the actual value (NUMBER; TEXT; TABLE)
cl_abap_unit_assert=>assert_number_between( " must be between 5 and 10 incl.
lower = 5
upper = 10
number = lv_result_value ).
cl_abap_unit_assert=>assert_text_matches( pattern = lv_exp_message_pattern
text = lv_act_message_text ).
cl_abap_unit_assert=>assert_table_not_contains( line = ls_deleted_table_line
table = lt_act_table
msg = 'deletion of line failed' ).
" 3. ASSERT_SUBRC, ASSERT_RETURN_CODE, ASSUME_RETURN_CODE: parameter ACT has SY-SUBRC as its default value
" these methods use SY-SUBRC as the default value for parameter SY-SUBRC; the signature starts with EXP
cl_abap_unit_assert=>assert_subrc( exp = 4
quit = if_aunit_constants=>quit-no ).
cl_abap_unit_assert=>assert_return_code( exp = 4
act = lv_return_code ).
ENDMETHOD.
```

## Related code

* [Rule implementation](../../com.sap.adt.abapcleaner/src/com/sap/adt/abapcleaner/rules/commands/AssertParameterOrderRule.java)
* [Tests](../../test/com.sap.adt.abapcleaner.test/src/com/sap/adt/abapcleaner/rules/commands/AssertParameterOrderTest.java)

Loading

0 comments on commit 1748662

Please sign in to comment.