Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
4660dce
saving progress
lucasborin Sep 10, 2021
06fc3cd
saving progress
lucasborin Sep 10, 2021
a6e564f
Update changelog.txt
lucasborin Sep 10, 2021
35822c4
global class vs local class
lucasborin Sep 13, 2021
1ba5549
local vs global test class
lucasborin Sep 13, 2021
dd025f0
Global Test Class fix
lucasborin Sep 14, 2021
287f76c
enabling unit test
lucasborin Sep 14, 2021
363d6ee
refactoring y_check_function uts
lucasborin Sep 14, 2021
70ce946
abaplint feedback
lucasborin Sep 14, 2021
f71dded
abaplint feedback
lucasborin Sep 14, 2021
15e85b0
removing unecessary fields and fixing checksum
lucasborin Sep 16, 2021
09dbd53
fixing coverages (statement)
lucasborin Sep 16, 2021
a20cd4f
default noaunit for test
lucasborin Sep 16, 2021
a1c2151
fixing bug in chain declaration
lucasborin Sep 16, 2021
d2c7d08
fixing unit test
lucasborin Sep 17, 2021
e4f42d4
Less than 3 newlines and at least a single newline are required in be…
lucasborin Sep 17, 2021
3aa1ef4
Merge branch '1.16.0' into refactoring_aunit
lucasborin Sep 17, 2021
d21cb61
ref #461
Sep 17, 2021
b430cd0
solving conflict
lucasborin Sep 17, 2021
6ceee07
Update changelog.txt
lucasborin Sep 17, 2021
9db855e
Update src/foundation/y_code_pal_ref_scan_double.clas.abap
lucasborin Sep 17, 2021
281dafa
Update src/foundation/y_code_pal_ref_scan_double.clas.abap
lucasborin Sep 17, 2021
6a1d45a
solving conflict
lucasborin Sep 17, 2021
947b494
Merge branch 'refactoring_aunit' of https://github.com/SAP/code-pal-f…
lucasborin Sep 17, 2021
da67d7f
fixing collect dump
Sep 22, 2021
912b319
fixing pseudo comment dump and performance issue
Sep 22, 2021
71af159
reusing refscan (performance)
Sep 22, 2021
a96c7fe
Update src/checks/y_check_pseudo_comment_usage.clas.abap
lucasborin Sep 22, 2021
2106e59
Update src/checks/y_check_pseudo_comment_usage.clas.abap
lucasborin Sep 22, 2021
d7a8ac8
Update src/checks/y_check_pseudo_comment_usage.clas.abap
lucasborin Sep 22, 2021
145a3de
Update src/checks/y_check_pseudo_comment_usage.clas.abap
lucasborin Sep 22, 2021
7f18f8f
pseudo comment refactoring (performance)
Sep 22, 2021
fbb3cb7
collect (performance)
Sep 22, 2021
f0d5666
Update changelog.txt
lucasborin Sep 22, 2021
bd6700c
Reorder definitions to top of routine
Sep 22, 2021
e09a66a
pseudo_comment_usage ignore_pseudo
Sep 23, 2021
2531c6e
more performance improvements
Sep 23, 2021
cbd1567
removing deprecated methods
Sep 23, 2021
91caabf
activating prefer_inline (#465)
lucasborin Sep 24, 2021
77371f6
performance improvement (check statement pos)
Sep 24, 2021
d52e5de
Prefer Inline Declarations, PROFILE_CONFIGURATIONS
Sep 28, 2021
63fe79a
Line break multiple parameters
Sep 28, 2021
7a5760a
Reorder definitions to top of routine
Sep 28, 2021
18d7611
Update changelog.txt
lucasborin Sep 28, 2021
55a3b82
magic number
Sep 28, 2021
16bd620
adding pseudo comments
Sep 28, 2021
bd71b98
Adding pseudo comment
Sep 29, 2021
51601fb
Fixing magic number
Sep 29, 2021
6927034
Use | to assemble text!
Sep 29, 2021
8f71414
Use | to assemble text!
Sep 29, 2021
cf9ff9a
Prefer RETURNING to EXPORTING!
Sep 29, 2021
4dddfe4
Prefer LINE_EXISTS or LINE_INDEX to READ TABLE or LOOP AT!
Sep 29, 2021
14fbb0e
Prefer IS NOT to NOT IS!
Sep 29, 2021
d5a850e
replacing pseudo
Sep 29, 2021
355f631
removing unecessary pseudos
Sep 29, 2021
33475a1
unecessary pseudo
Sep 29, 2021
dd8e52a
clean coding f4call
Sep 30, 2021
b32f96e
new SAP note dependency
lucasborin Oct 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Together, we both support you in writing a clean ABAP code.

- SAP NetWeaver **7.40 SP8** or higher
- [abapGit](https://docs.abapgit.org/)
- :new: [SAP Note 2527903 - Remote analysis (for check system)](https://launchpad.support.sap.com/#/notes/2527903)

## How-to Guides

Expand Down
2 changes: 1 addition & 1 deletion abaplint.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"parser_702_chaining": false,
"parser_error": true,
"parser_missing_space": true,
"prefer_inline": false,
"prefer_inline": true,
"prefer_is_not": true,
"prefer_raise_exception_new": true,
"prefer_returning_to_exporting": true,
Expand Down
15 changes: 10 additions & 5 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
code-pal-for-abap changelog
=================

Dependencies
------------------
1. SAP Note 2527903 - Remote analysis (for check system)

Upgrade Note
------------------
Whenever you upgrade code pal for ABAP, it is highly recommended to execute the Y_CI_CHECK_REGISTRATION report to activate/reactivate the Checks (SE38 transaction) and regenerate the respective Code Inspector Variant (SCI transaction)

Legend
------
------------------
* : fixed
! : changed
+ : added
- : removed

Upgrade Note
------------------
Whenever you upgrade code pal for ABAP, it is highly recommended to execute the Y_CI_CHECK_REGISTRATION report to activate/reactivate the Checks (SE38 transaction) and regenerate the respective Code Inspector Variant (SCI transaction)

2021-08-XX v.1.16.0
------------------
* Refactoring (#436,#452,#458)
* Cannot run unit tests on 752 (#461)
* Profiles: Allow Exemptions (#447)
* BAdI example class vs Percentage Comment (#443)
Expand Down
2 changes: 1 addition & 1 deletion src/checks/y_check_boolean_input_param.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ CLASS y_check_boolean_input_param IMPLEMENTATION.

METHOD has_boolean_input_param.
DATA(skip) = abap_true.
LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL(<token>)
LOOP AT ref_scan->tokens ASSIGNING FIELD-SYMBOL(<token>)
FROM statement-from TO statement-to.

IF <token>-str = 'IMPORTING'.
Expand Down
16 changes: 10 additions & 6 deletions src/checks/y_check_branch_coverage.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ CLASS y_check_branch_coverage IMPLEMENTATION.


METHOD execute_check.

TRY.
DATA(coverage) = y_unit_test_coverage=>get( program_name = program_name
object = VALUE #( object = object_type obj_name = object_name )
Expand All @@ -42,18 +41,23 @@ CLASS y_check_branch_coverage IMPLEMENTATION.
RETURN.
ENDTRY.

TRY.
DATA(first_statement) = ref_scan->statements[ 1 ].
CATCH cx_sy_itab_line_not_found.
RETURN.
ENDTRY.

DATA(check_configuration) = detect_check_configuration( error_count = CONV #( branch )
statement = VALUE #( level = 1 ) ).
statement = first_statement ).

raise_error( statement_level = 1
statement_index = 1
statement_from = 1
raise_error( statement_level = first_statement-level
statement_index = first_statement-from
statement_from = first_statement-from
check_configuration = check_configuration
parameter_01 = |{ branch }|
parameter_02 = |{ check_configuration-threshold }|
parameter_03 = |{ coverage->get_total( ) }|
parameter_04 = |{ coverage->get_executed( ) }| ).

ENDMETHOD.


Expand Down
27 changes: 16 additions & 11 deletions src/checks/y_check_chain_decl_usage.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ CLASS y_check_chain_decl_usage DEFINITION PUBLIC INHERITING FROM y_check_base CR
METHODS inspect_tokens REDEFINITION.

PRIVATE SECTION.
DATA rows_with_colon TYPE STANDARD TABLE OF stmnt_crow.
TYPES: BEGIN OF ty_raised_issues,
include TYPE slevel-name,
line_number_colon TYPE sstmnt-colonrow,
END OF ty_raised_issues.

METHODS has_error_not_raised_yet IMPORTING statement TYPE sstmnt RETURNING VALUE(result) TYPE abap_bool.
DATA raised_issues TYPE TABLE OF ty_raised_issues.

ENDCLASS.

Expand All @@ -30,26 +33,28 @@ CLASS Y_CHECK_CHAIN_DECL_USAGE IMPLEMENTATION.


METHOD inspect_tokens.

CHECK statement-colonrow IS NOT INITIAL.
CHECK statement-terminator = ','.
CHECK get_token_abs( statement-from ) = 'DATA'.
CHECK has_error_not_raised_yet( statement ).

APPEND statement-colonrow TO rows_with_colon.
DATA(include) = get_include( p_level = statement-level ).

DATA(raised_issue) = VALUE ty_raised_issues( include = include
line_number_colon = statement-colonrow ).

IF line_exists( raised_issues[ include = raised_issue-include
line_number_colon = raised_issue-line_number_colon ] ).
RETURN.
ENDIF.

APPEND raised_issue TO raised_issues.

DATA(configuration) = detect_check_configuration( statement ).

raise_error( statement_level = statement-level
statement_index = index
statement_from = statement-from
check_configuration = configuration ).

ENDMETHOD.


METHOD has_error_not_raised_yet.
result = xsdbool( NOT line_exists( rows_with_colon[ table_line = statement-colonrow ] ) ).
ENDMETHOD.


Expand Down
4 changes: 2 additions & 2 deletions src/checks/y_check_check_in_loop.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ CLASS y_check_check_in_loop IMPLEMENTATION.

METHOD get_back_statement.
TRY.
DATA(back_structure) = ref_scan_manager->structures[ structure-back ].
result = ref_scan_manager->statements[ back_structure-stmnt_from ].
DATA(back_structure) = ref_scan->structures[ structure-back ].
result = ref_scan->statements[ back_structure-stmnt_from ].
CATCH cx_sy_itab_line_not_found.
CLEAR result.
ENDTRY.
Expand Down
8 changes: 5 additions & 3 deletions src/checks/y_check_check_stmnt_position.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ CLASS y_check_check_stmnt_position IMPLEMENTATION.


METHOD has_wrong_position.
LOOP AT ref_scan_manager->statements ASSIGNING FIELD-SYMBOL(<statement>)
LOOP AT ref_scan->statements ASSIGNING FIELD-SYMBOL(<statement>)
FROM structure-stmnt_from TO structure-stmnt_to.
IF <statement>-type = scan_stmnt_type-empty
OR <statement>-type = scan_stmnt_type-comment
Expand All @@ -89,8 +89,10 @@ CLASS y_check_check_stmnt_position IMPLEMENTATION.


METHOD is_check_in_loop.
LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL(<token>)
FROM structure-stmnt_from TO check-from
DATA(scope) = ref_scan->statements[ structure-stmnt_from ].

LOOP AT ref_scan->tokens ASSIGNING FIELD-SYMBOL(<token>)
FROM scope-from TO check-from
WHERE str = 'LOOP'
OR str = 'ENDLOOP'.
result = xsdbool( <token>-str = 'LOOP' ).
Expand Down
29 changes: 20 additions & 9 deletions src/checks/y_check_collect.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ENDCLASS.



CLASS y_check_collect IMPLEMENTATION.
CLASS Y_CHECK_COLLECT IMPLEMENTATION.


METHOD constructor.
Expand Down Expand Up @@ -92,7 +92,7 @@ CLASS y_check_collect IMPLEMENTATION.


METHOD extract_itab_name.
LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL(<token>)
LOOP AT ref_scan->tokens ASSIGNING FIELD-SYMBOL(<token>)
FROM statement-from TO statement-to.
IF <token>-str = 'INTO'.
result = get_token_abs( sy-tabix + 1 ).
Expand All @@ -107,8 +107,16 @@ CLASS y_check_collect IMPLEMENTATION.


METHOD find_itab_declaration.
LOOP AT ref_scan_manager->statements ASSIGNING FIELD-SYMBOL(<statement>)
LOOP AT ref_scan->statements ASSIGNING FIELD-SYMBOL(<statement>)
FROM structure-stmnt_from TO structure-stmnt_to.
DATA(first_token) = get_token_abs( <statement>-from ).

IF first_token <> 'DATA'
AND first_token <> 'TYPES'
AND first_token <> 'CLASS-DATA'.
CONTINUE.
ENDIF.

DATA(tokens) = condense_tokens( <statement> ).

IF tokens NP |DATA { name } TYPE *|
Expand All @@ -135,14 +143,14 @@ CLASS y_check_collect IMPLEMENTATION.
ENDLOOP.

IF structure-back > 0.
result = find_itab_declaration( structure = ref_scan_manager->structures[ structure-back ]
result = find_itab_declaration( structure = ref_scan->structures[ structure-back ]
name = name ).
ENDIF.
ENDMETHOD.


METHOD extract_itab_type.
LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL(<token>)
LOOP AT ref_scan->tokens ASSIGNING FIELD-SYMBOL(<token>)
FROM statement-from TO statement-to
WHERE str = 'OF'.
IF get_token_abs( sy-tabix - 1 ) = 'TABLE'.
Expand All @@ -151,7 +159,7 @@ CLASS y_check_collect IMPLEMENTATION.
ENDIF.
ENDLOOP.

LOOP AT ref_scan_manager->tokens ASSIGNING <token>
LOOP AT ref_scan->tokens ASSIGNING <token>
FROM statement-from TO statement-to
WHERE str = 'TYPE'
OR str = 'LIKE'.
Expand All @@ -176,8 +184,11 @@ CLASS y_check_collect IMPLEMENTATION.
RETURN.
ENDIF.

result ?= rtti_type.
TRY.
result ?= rtti_type.
CATCH cx_sy_move_cast_error.
" Not a TableDescr type
RETURN.
ENDTRY.
ENDMETHOD.


ENDCLASS.
6 changes: 3 additions & 3 deletions src/checks/y_check_comment_position.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ CLASS y_check_comment_position IMPLEMENTATION.

METHOD has_wrong_position.
TRY.
DATA(previous_token) = ref_scan_manager->tokens[ statement-to - 1 ].
DATA(current_token) = ref_scan_manager->tokens[ statement-to ].
DATA(previous_token) = ref_scan->tokens[ statement-to - 1 ].
DATA(current_token) = ref_scan->tokens[ statement-to ].
CATCH cx_sy_itab_line_not_found.
RETURN.
ENDTRY.
Expand Down Expand Up @@ -114,7 +114,7 @@ CLASS y_check_comment_position IMPLEMENTATION.

METHOD get_next_token.
DATA(next_position) = current_position + 1.
result = ref_scan_manager->tokens[ next_position ].
result = ref_scan->tokens[ next_position ].
IF is_pragma( result ) = abap_true.
result = get_next_token( next_position ).
ENDIF.
Expand Down
2 changes: 1 addition & 1 deletion src/checks/y_check_comment_type.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CLASS y_check_comment_type IMPLEMENTATION.


METHOD has_wrong_comment_type.
LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL(<token>)
LOOP AT ref_scan->tokens ASSIGNING FIELD-SYMBOL(<token>)
FROM statement-from TO statement-to.
IF get_first_character( <token> ) = '*'
AND get_second_character( <token> ) <> '&'.
Expand Down
14 changes: 6 additions & 8 deletions src/checks/y_check_comment_usage.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ CLASS y_check_comment_usage IMPLEMENTATION.
abs_statement_number = abs_statement_number + ( statement-to - statement-from ).
ENDIF.

LOOP AT ref_scan_manager->tokens ASSIGNING FIELD-SYMBOL(<token>)
LOOP AT ref_scan->tokens ASSIGNING FIELD-SYMBOL(<token>)
FROM statement-from TO statement-to
WHERE type = scan_token_type-comment.
IF NOT is_comment_excluded( <token>-str ).
IF is_comment_excluded( <token>-str ) = abap_false.
comment_number = comment_number + 1.
ENDIF.
ENDLOOP.
Expand All @@ -110,8 +110,8 @@ CLASS y_check_comment_usage IMPLEMENTATION.
start_with = |"#EC| )
OR has_token_started_with( token = token
start_with = |* INCLUDE| )
OR token CP '"' && object_name && '*.'
OR token CO '*'.
OR token CP |"{ object_name }*.|
OR token CO |*|.

result = abap_true.

Expand All @@ -133,7 +133,7 @@ CLASS y_check_comment_usage IMPLEMENTATION.
METHOD check_result.
DATA(percentage_of_comments) = get_percentage_of_comments( ).

DATA(statement_for_message) = ref_scan_manager->statements[ structure-stmnt_from ].
DATA(statement_for_message) = ref_scan->statements[ structure-stmnt_from ].

DATA(check_configuration) = detect_check_configuration( error_count = percentage_of_comments
statement = statement_for_message ).
Expand All @@ -149,9 +149,7 @@ CLASS y_check_comment_usage IMPLEMENTATION.


METHOD get_percentage_of_comments.
DATA percentage TYPE decfloat16.

percentage = ( comment_number / abs_statement_number ) * 100.
DATA(percentage) = CONV decfloat16( comment_number / abs_statement_number ) * 100.

result = round( val = percentage
dec = 0
Expand Down
2 changes: 1 addition & 1 deletion src/checks/y_check_constants_interface.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ CLASS Y_CHECK_CONSTANTS_INTERFACE IMPLEMENTATION.
METHOD check_result.
CHECK has_something_else = abap_false.

DATA(statement_for_message) = ref_scan_manager->statements[ structure-stmnt_from ].
DATA(statement_for_message) = ref_scan->statements[ structure-stmnt_from ].

DATA(check_configuration) = detect_check_configuration( statement_for_message ).

Expand Down
2 changes: 1 addition & 1 deletion src/checks/y_check_cx_root_usage.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CLASS y_check_cx_root_usage IMPLEMENTATION.


METHOD has_cx_root.
LOOP AT ref_scan_manager->tokens TRANSPORTING NO FIELDS
LOOP AT ref_scan->tokens TRANSPORTING NO FIELDS
FROM statement-from TO statement-to
WHERE str = 'CX_ROOT'.
result = abap_true.
Expand Down
2 changes: 1 addition & 1 deletion src/checks/y_check_cyclomatic_complexity.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ CLASS Y_CHECK_CYCLOMATIC_COMPLEXITY IMPLEMENTATION.
c_cyclo_comp = c_cyclo_comp + 1.
ENDIF.
WHEN 'DO'.
READ TABLE ref_scan_manager->tokens INDEX statement_wa-to INTO DATA(token).
READ TABLE ref_scan->tokens INDEX statement_wa-to INTO DATA(token).
IF token-str = 'TIMES'.
c_cyclo_comp = c_cyclo_comp + 1.
ENDIF.
Expand Down
Loading