-
Notifications
You must be signed in to change notification settings - Fork 71
Unit Test Assert does not allow to check method calls for idempotence #460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Unfortunately, Code Pal performs a static check (string-based), and it cannot detect idempotent calls. |
I think that's too specific, you can also have cl_abap_unit_assert=>assert_differs(
act = get_next( )
exp = get_next( ) ). But I also think this is a narrow use case that is easy enough to work around by assigning one of the values to a variable. |
Actually I just spotted that we're only talking about method calls. In this case it should be sufficient to exclude anything that has a "(" in it, no? |
I am with you guys, it makes sense to disable this rule on these method calls due to this technical limitation. I am unsure about the DATA(memory) = '010101110101'.
cl_abap_unit_assert=>assert_differs( act = memory+2(1)
exp = memory+3(1) ). |
I was wondering to check the tokens " Singleton
cl_abap_unit_assert=>assert_equals( act = my_class=>get_instance( )
exp = my_class=>get_instance( ) ). |
If you're treating it as a string then matching |
Why not just extend it not to trigger if it ends with ‚( ).‘ so all method
calls are exempt?
Lucas Borin ***@***.***> schrieb am Mi. 15. Sept. 2021 um
16:03:
… Unfortunately, Code Pal performs a static check (string-based), and it
cannot detect idempotent calls.
What we could implement is exempting if the act&exp ends with get_instance(
). How about it?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#460 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AN5H6UCQFHCECVFWYB22XXDUCCRSBANCNFSM5ECCN35A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Oh wait, too late for me to really think straight 🙈 parameters might be
there 😂
Philipp Rembold ***@***.***> schrieb am Mi. 15. Sept. 2021
um 22:36:
… Why not just extend it not to trigger if it ends with ‚( ).‘ so all method
calls are exempt?
Lucas Borin ***@***.***> schrieb am Mi. 15. Sept. 2021 um
16:03:
> Unfortunately, Code Pal performs a static check (string-based), and it
> cannot detect idempotent calls.
> What we could implement is exempting if the act&exp ends with get_instance(
> ). How about it?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <#460 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AN5H6UCQFHCECVFWYB22XXDUCCRSBANCNFSM5ECCN35A>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
>
|
Yes, on second thoughts it's a little more complex. The expression |
* Functional operand check * Fix unit test and nesting syntax * Lint * Update exemption unit test * Fix unit test * Add functional operand fix #460 to changelog * removing static test, and adding more test cases Co-authored-by: Lucas Borin <[email protected]>
@PeregrinTooc fix available under branch |
2021-11-01 v.1.16.0 ------------------ * Prefer New: Dynamic Call with Parameters (#502) * DB Access in UT: Global Inheritance (#500) * DB Access in UT: Local Inheritance (#498) * Skip 'Prefer RETURNING to EXPORTING' when both exist (#490) * Pseudo Comment Usage: Multiple Inline Entries (#494) * Prefer Pragmas to Pseudo Comments: Multiple Pseudo Comments (#489) * Y_CHECK_MESSAGE_EASY_TO_FIND dump (#492) * Chain Declaration for Complex Structures (#488) * Empty Catch Alternative Pseudo Comment (#337) + Alternative Pseudo Comment (#486) * line_exists does not support the operator IN (#484) * Empty Catch: Test Double Framework (#483) * Y_CHECK_FORM: Screen Events (#454) * Magic Number: CASE SY-TABIX and CO NUMBERS (#480) * Magic Number: Leading Zeros (#479) * Prefer New to Create Object: Dynamic Type (#469) * Magic Number: Table Index (#468) * Use native *_wa variables (#474) * Refactoring (#436,#452,#458) * Cannot run unit tests on 752 (#461) * Profiles: Allow Exemptions (#447) * BAdI example class vs Percentage Comment (#443) * Unit-Test Assert Validator (#450) + Prefer Pragmas to Pseudo Comments (#421) + COLLECT restriction (#441) * RAP needs CREATE OBJECT ... FOR TESTING (#444) * Filter functional operands in "Unit Test Assert" check (#460)
* 1.16.0 * enabling changelog * RAP needs CREATE OBJECT ... FOR TESTING (#448) * resolves #444 * changelog * COLLECT restrictions (#442) * new check * abapLint * supporting programs * closing gaps * adding documentation * Adding Changelog * exempt ddic typed table * supporting ddic table type * supporting header line * removing gap section * supporting class attributes * Use functional writing style for method calls * Adding example * Prefer Pragmas to Pseudo Comments (#446) * new check * new check * documentation * exempting SLIN * Adding example * Unit-Test Assert Validator (#450) * Unit-Test Assert Validator resolve #449 * changelog * BAdI example class vs Percentage Comment (#451) * BAdI example class vs Percentage Comment resolve #443 * changelog * Allow Exemptions (#453) * big refactoring * isolating unit tests * changelog * forcing commit * forcing commit * Handle functional operand in assert check (#462) * Functional operand check * Fix unit test and nesting syntax * Lint * Update exemption unit test * Fix unit test * Add functional operand fix #460 to changelog * removing static test, and adding more test cases Co-authored-by: Lucas Borin <[email protected]> * Unit Test on 752 (#463) * fix #461 * changelog Co-authored-by: Lucas Borin <[email protected]> * Refactoring Code Pal (#457) * saving progress * saving progress * Update changelog.txt * global class vs local class * local vs global test class * Global Test Class fix * enabling unit test * refactoring y_check_function uts * abaplint feedback * abaplint feedback * removing unecessary fields and fixing checksum * fixing coverages (statement) * default noaunit for test * fixing bug in chain declaration * fixing unit test * Less than 3 newlines and at least a single newline are required in between metho * ref #461 * solving conflict * Update changelog.txt * Update src/foundation/y_code_pal_ref_scan_double.clas.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * Update src/foundation/y_code_pal_ref_scan_double.clas.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * fixing collect dump * fixing pseudo comment dump and performance issue * reusing refscan (performance) * Update src/checks/y_check_pseudo_comment_usage.clas.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * Update src/checks/y_check_pseudo_comment_usage.clas.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * Update src/checks/y_check_pseudo_comment_usage.clas.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * Update src/checks/y_check_pseudo_comment_usage.clas.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * pseudo comment refactoring (performance) * collect (performance) * Update changelog.txt * Reorder definitions to top of routine * pseudo_comment_usage ignore_pseudo * more performance improvements * removing deprecated methods * activating prefer_inline (#465) * activating prefer_inline * Prefer Inline Declarations, PERCENTAGE * Prefer Inline Declarations, RISK_LVL * Prefer Inline Declarations, HAS_REDIRECTION * Prefer Inline Declarations, TITLE * Prefer Inline Declarations, CLASS_SEARCH_STRING Co-authored-by: Lucas Borin <[email protected]> * performance improvement (check statement pos) * Prefer Inline Declarations, PROFILE_CONFIGURATIONS * Line break multiple parameters * Reorder definitions to top of routine * Update changelog.txt * magic number * adding pseudo comments * Adding pseudo comment * Fixing magic number * Use | to assemble text! * Use | to assemble text! * Prefer RETURNING to EXPORTING! * Prefer LINE_EXISTS or LINE_INDEX to READ TABLE or LOOP AT! * Prefer IS NOT to NOT IS! * replacing pseudo * removing unecessary pseudos * unecessary pseudo * clean coding f4call * new SAP note dependency Co-authored-by: Lucas Borin <[email protected]> Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * use native *_wa variables (#475) * resolves #474 * changelog * forcing commit * restore Co-authored-by: Lucas Borin <[email protected]> * disabling abaplint check_syntax * Magic Number: Table Index (#477) * resolves #474 * fix #475 * fixing case * changelog Co-authored-by: Lucas Borin <[email protected]> * Prefer New to Create Object: Dynamic Type (#478) * Fixes #469 * changelog Co-authored-by: Lucas Borin <[email protected]> * Magic Number: Leading Zeros (#479) * fixing magic number for leading zeros * changelog Co-authored-by: Lucas Borin <[email protected]> * Magic Number: CASE SY-TABIX and CO NUMBERS (#480) * case sy-tabix and Co numbers * changelog Co-authored-by: Lucas Borin <[email protected]> * Y_CHECK_FORM: Screen Events (#482) * Fixes #454 * changelog Co-authored-by: Lucas Borin <[email protected]> * Empty Catch: Test Double Framework (#483) * Fixes #332 * Missing space between string or character literal and parentheses * changelog Co-authored-by: Lucas Borin <[email protected]> * line_exists does not support the operator IN (#485) * Fixes #484 * changelog Co-authored-by: Lucas Borin <[email protected]> * Alternative Pseudo Comment (#486) * saving progress * saving progress * saving progress * alternative pseudo * fixing 7.40 compatibility * 7.40 compatibility * revert checksum * adjusting pseudo comment usage * adding unit tests * Missing space between string or character literal and parentheses * new pseudo comment * changelog * alt_pcom in ut * Update empty_catch.md Co-authored-by: Lucas Borin <[email protected]> * Chain Declaration for Complex Structures (#488) * new test scope * fixes #466 * cleaning self-reference * cleaning chain declaration * cleaning chain declaration * cleaning chain declaration * fixing syntax error * changelog * documentation Co-authored-by: Lucas Borin <[email protected]> * fixing syntax error * `Y_CHECK_MESSAGE_EASY_TO_FIND` dump (#492) * fixes #491 * changelog Co-authored-by: Lucas Borin <[email protected]> * short review (#493) Co-authored-by: Lucas Borin <[email protected]> * Prefer Pragmas to Pseudo Comments (#495) * fixes #489 * changelog Co-authored-by: Lucas Borin <[email protected]> * Pseudo Comment Usage: Multiple Inline Entries (#496) * fixes #494 * changelog Co-authored-by: Lucas Borin <[email protected]> * Skip `Prefer RETURNING to EXPORTING` when both exist (#497) * fixes #490 * changelog Co-authored-by: Lucas Borin <[email protected]> * DB Access in UT: Local Inheritance (#498) * partially solves #433 * changelog * renaming variable Co-authored-by: Lucas Borin <[email protected]> * DB Access in UT: Global Inheritance (#500) * fixes #433 * changelog Co-authored-by: Lucas Borin <[email protected]> * fixing short dump (#501) Co-authored-by: Lucas Borin <[email protected]> * removing unecessary pseudo comment * Prefer New: Dynamic Call with Parameters (#503) * fixes #502 * changelog Co-authored-by: Lucas Borin <[email protected]> * mass change of check data * Update changelog.txt * UI finetuning * minor change * abaplint compliance * abaplint picky compliance * UI Changes * Revert "UI Changes" This reverts commit cac373d. * UI Changes * small UI adjustments * Update changelog.txt Co-authored-by: Lucas Borin <[email protected]> Co-authored-by: Mike Pokraka <[email protected]> Co-authored-by: Lucas Borin <[email protected]> Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com>
* new version * Quickfix: Pseudo Comment (#509) * adding quickfixes * Less than 3 newlines and at least a single newline are required in between metho * changelog Co-authored-by: Lucas Borin <[email protected]> * fixing (#515) Co-authored-by: Lucas Borin <[email protected]> * abapgit 1.112.0 * remove unused variable (#522) Co-authored-by: Eugen Günther <[email protected]> * mass change of check data (#507) * 1.16.0 * enabling changelog * RAP needs CREATE OBJECT ... FOR TESTING (#448) * resolves #444 * changelog * COLLECT restrictions (#442) * new check * abapLint * supporting programs * closing gaps * adding documentation * Adding Changelog * exempt ddic typed table * supporting ddic table type * supporting header line * removing gap section * supporting class attributes * Use functional writing style for method calls * Adding example * Prefer Pragmas to Pseudo Comments (#446) * new check * new check * documentation * exempting SLIN * Adding example * Unit-Test Assert Validator (#450) * Unit-Test Assert Validator resolve #449 * changelog * BAdI example class vs Percentage Comment (#451) * BAdI example class vs Percentage Comment resolve #443 * changelog * Allow Exemptions (#453) * big refactoring * isolating unit tests * changelog * forcing commit * forcing commit * Handle functional operand in assert check (#462) * Functional operand check * Fix unit test and nesting syntax * Lint * Update exemption unit test * Fix unit test * Add functional operand fix #460 to changelog * removing static test, and adding more test cases Co-authored-by: Lucas Borin <[email protected]> * Unit Test on 752 (#463) * fix #461 * changelog Co-authored-by: Lucas Borin <[email protected]> * Refactoring Code Pal (#457) * saving progress * saving progress * Update changelog.txt * global class vs local class * local vs global test class * Global Test Class fix * enabling unit test * refactoring y_check_function uts * abaplint feedback * abaplint feedback * removing unecessary fields and fixing checksum * fixing coverages (statement) * default noaunit for test * fixing bug in chain declaration * fixing unit test * Less than 3 newlines and at least a single newline are required in between metho * ref #461 * solving conflict * Update changelog.txt * Update src/foundation/y_code_pal_ref_scan_double.clas.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * Update src/foundation/y_code_pal_ref_scan_double.clas.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * fixing collect dump * fixing pseudo comment dump and performance issue * reusing refscan (performance) * Update src/checks/y_check_pseudo_comment_usage.clas.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * Update src/checks/y_check_pseudo_comment_usage.clas.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * Update src/checks/y_check_pseudo_comment_usage.clas.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * Update src/checks/y_check_pseudo_comment_usage.clas.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * pseudo comment refactoring (performance) * collect (performance) * Update changelog.txt * Reorder definitions to top of routine * pseudo_comment_usage ignore_pseudo * more performance improvements * removing deprecated methods * activating prefer_inline (#465) * activating prefer_inline * Prefer Inline Declarations, PERCENTAGE * Prefer Inline Declarations, RISK_LVL * Prefer Inline Declarations, HAS_REDIRECTION * Prefer Inline Declarations, TITLE * Prefer Inline Declarations, CLASS_SEARCH_STRING Co-authored-by: Lucas Borin <[email protected]> * performance improvement (check statement pos) * Prefer Inline Declarations, PROFILE_CONFIGURATIONS * Line break multiple parameters * Reorder definitions to top of routine * Update changelog.txt * magic number * adding pseudo comments * Adding pseudo comment * Fixing magic number * Use | to assemble text! * Use | to assemble text! * Prefer RETURNING to EXPORTING! * Prefer LINE_EXISTS or LINE_INDEX to READ TABLE or LOOP AT! * Prefer IS NOT to NOT IS! * replacing pseudo * removing unecessary pseudos * unecessary pseudo * clean coding f4call * new SAP note dependency Co-authored-by: Lucas Borin <[email protected]> Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * use native *_wa variables (#475) * resolves #474 * changelog * forcing commit * restore Co-authored-by: Lucas Borin <[email protected]> * disabling abaplint check_syntax * Magic Number: Table Index (#477) * resolves #474 * fix #475 * fixing case * changelog Co-authored-by: Lucas Borin <[email protected]> * Prefer New to Create Object: Dynamic Type (#478) * Fixes #469 * changelog Co-authored-by: Lucas Borin <[email protected]> * Magic Number: Leading Zeros (#479) * fixing magic number for leading zeros * changelog Co-authored-by: Lucas Borin <[email protected]> * Magic Number: CASE SY-TABIX and CO NUMBERS (#480) * case sy-tabix and Co numbers * changelog Co-authored-by: Lucas Borin <[email protected]> * Y_CHECK_FORM: Screen Events (#482) * Fixes #454 * changelog Co-authored-by: Lucas Borin <[email protected]> * Empty Catch: Test Double Framework (#483) * Fixes #332 * Missing space between string or character literal and parentheses * changelog Co-authored-by: Lucas Borin <[email protected]> * line_exists does not support the operator IN (#485) * Fixes #484 * changelog Co-authored-by: Lucas Borin <[email protected]> * Alternative Pseudo Comment (#486) * saving progress * saving progress * saving progress * alternative pseudo * fixing 7.40 compatibility * 7.40 compatibility * revert checksum * adjusting pseudo comment usage * adding unit tests * Missing space between string or character literal and parentheses * new pseudo comment * changelog * alt_pcom in ut * Update empty_catch.md Co-authored-by: Lucas Borin <[email protected]> * Chain Declaration for Complex Structures (#488) * new test scope * fixes #466 * cleaning self-reference * cleaning chain declaration * cleaning chain declaration * cleaning chain declaration * fixing syntax error * changelog * documentation Co-authored-by: Lucas Borin <[email protected]> * fixing syntax error * `Y_CHECK_MESSAGE_EASY_TO_FIND` dump (#492) * fixes #491 * changelog Co-authored-by: Lucas Borin <[email protected]> * short review (#493) Co-authored-by: Lucas Borin <[email protected]> * Prefer Pragmas to Pseudo Comments (#495) * fixes #489 * changelog Co-authored-by: Lucas Borin <[email protected]> * Pseudo Comment Usage: Multiple Inline Entries (#496) * fixes #494 * changelog Co-authored-by: Lucas Borin <[email protected]> * Skip `Prefer RETURNING to EXPORTING` when both exist (#497) * fixes #490 * changelog Co-authored-by: Lucas Borin <[email protected]> * DB Access in UT: Local Inheritance (#498) * partially solves #433 * changelog * renaming variable Co-authored-by: Lucas Borin <[email protected]> * DB Access in UT: Global Inheritance (#500) * fixes #433 * changelog Co-authored-by: Lucas Borin <[email protected]> * fixing short dump (#501) Co-authored-by: Lucas Borin <[email protected]> * removing unecessary pseudo comment * Prefer New: Dynamic Call with Parameters (#503) * fixes #502 * changelog Co-authored-by: Lucas Borin <[email protected]> * mass change of check data * Update changelog.txt * UI finetuning * minor change * abaplint compliance * abaplint picky compliance * UI Changes * Revert "UI Changes" This reverts commit cac373d. * UI Changes * small UI adjustments * Update changelog.txt Co-authored-by: Lucas Borin <[email protected]> Co-authored-by: Mike Pokraka <[email protected]> Co-authored-by: Lucas Borin <[email protected]> Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * Refactoring Quick Fixes (#523) * quickfixes are now mandatory * first check + message * no quickfix * wip * implementing abstract method * pseudo comments won't enable the quickfix * removing unnecessary : * removing duplicated quick fix * changelog Co-authored-by: Lucas Borin <[email protected]> Co-authored-by: Eugen Günther <[email protected]> * Replace class by interface in check documentation (#543) * Update test-seam-usage.md * Update db-access-in-ut.md * Update external-call-in-ut.md * Update unit_test_assert.md * Replace class by interface In the check "Constants Interface Check", the documentation of the exception referred to class definition instead of interface definition. * Update db-access-in-ut.md * Update external-call-in-ut.md * Update test-seam-usage.md * Update test-seam-usage.md * Update unit_test_assert.md * Update unit_test_assert.md * Update unit_test_assert.md Co-authored-by: estevao-schultz-neto-SAP <[email protected]> Co-authored-by: Eugen Günther <[email protected]> * Update changelog.txt * Update changelog.txt Co-authored-by: Lucas Borin <[email protected]> Co-authored-by: Lars Hvam <[email protected]> Co-authored-by: Eugen Günther <[email protected]> Co-authored-by: Mike Pokraka <[email protected]> Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> Co-authored-by: Michael Schneider <[email protected]> Co-authored-by: estevao-schultz-neto-SAP <[email protected]>
Check Name
unit test assert
Actual Behavior
If the same method is called twice in actual and expected, e.g. to test that a factory method returns a singleton, 'illegal assert' is raised
Expected Behavior
For method calls, dispense with the rule, since idempotence is a meaningful test.
The text was updated successfully, but these errors were encountered: