Skip to content

Commit

Permalink
1.12.0 (SAP#306)
Browse files Browse the repository at this point in the history
* Update README.md

* disabling rfc

* Update changelog.txt

* Update changelog.txt

* 1.12.0

* Profile Tool - UX Refinement (SAP#313)

Minor UX Changes

* Update changelog.txt

* Update changelog.txt

* Performance (SAP#317)

* buffer size

* fixing dump when object is not supported by sci

* solving dump when ref scan is not set

* Update y_ref_scan_manager.clas.abap

* Update changelog.txt

* removing shared memory (SAP#319)

* Update changelog.txt

* Performance Improvements (SAP#318)

* moving application component valid. to ref_scan

* wip

* changing validation sequence

* fixing minor bug

* fixing bug

* refactoring former buffer

* syntax error

* fixing ut

* fixing unit test base

* abaplint hint

* Update changelog.txt

* Code review (SAP#322)

* removing unused exception

* solving empty catch

* moving buffer cleanup

* pretty printer

Co-authored-by: Eugen Günther <[email protected]>
  • Loading branch information
lucasborin and Eugen Günther authored Feb 8, 2021
1 parent e534141 commit fd5b82d
Show file tree
Hide file tree
Showing 44 changed files with 463 additions and 875 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ The Profile Management Tool, which is an alternative of working with SCI based v
- Multiple execution of several profiles at the same time (the sharpest/strongest and time valid configuration/threshold will be taken);
- Delegation principle to facilitate team work (all delegates, for instance: team members, can work with the same profile);

:warning: The checks are not RFC-Enabled due to local dependencies.

## List of Checks

- [Check Documentation](docs/check_documentation.md)
Expand Down
8 changes: 8 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ 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-01-XX v1.12.0
------------------
+ Performance Improvements (#318)
- Shared Memory (#319)
* Performance Issues (#317)
* Profile Tool - UX Refinement (#313)
- RFC Disabled (#305)

2021-01-22 v1.11.1
------------------
* Dump in DB access in UT (#309)
Expand Down
5 changes: 0 additions & 5 deletions src/checks/y_check_db_access_in_ut.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ CLASS y_check_db_access_in_ut IMPLEMENTATION.

LOOP AT ref_scan_manager->statements ASSIGNING FIELD-SYMBOL(<statement>)
FROM class_definition-stmnt_from TO class_definition-stmnt_to.

IF is_in_scope( <statement> ) = abap_false.
CONTINUE.
ENDIF.

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

test_risk_level = COND #( WHEN tokens CS 'RISK LEVEL HARMLESS' THEN risk_level_harmless
Expand Down
4 changes: 2 additions & 2 deletions src/checks/y_check_function.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ CLASS ltd_ref_scan_manager IMPLEMENTATION.
ENDMETHOD.
ENDCLASS.

CLASS ltd_clean_code_exemption_no DEFINITION FOR TESTING INHERITING FROM y_exemption_handler.
CLASS ltd_clean_code_exemption_no DEFINITION FOR TESTING.
PUBLIC SECTION.
METHODS y_if_exemption~is_object_exempted REDEFINITION.
INTERFACES y_if_exemption.
ENDCLASS.

CLASS ltd_clean_code_exemption_no IMPLEMENTATION.
Expand Down
98 changes: 35 additions & 63 deletions src/foundation/y_check_base.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ CLASS y_check_base DEFINITION PUBLIC ABSTRACT

METHODS execute_check.

METHODS check_start_conditions RAISING ycx_object_not_processed
ycx_object_is_exempted.
METHODS check_start_conditions RAISING ycx_object_not_processed.

"! <p class="shorttext synchronized" lang="en">Validates the Customizing</p>
"! @parameter statement | Received from inspect_tokens method.
Expand Down Expand Up @@ -120,14 +119,11 @@ CLASS y_check_base DEFINITION PUBLIC ABSTRACT
METHODS keyword REDEFINITION.
METHODS set_check_message IMPORTING message TYPE itex132.
METHODS get_class_description RETURNING VALUE(result) TYPE string.
METHODS is_in_scope IMPORTING statement TYPE sstmnt
RETURNING VALUE(result) TYPE abap_bool.

PRIVATE SECTION.
METHODS do_attributes_exist RETURNING VALUE(result) TYPE abap_bool.

METHODS instantiate_objects.
METHODS enable_rfc.

METHODS is_skipped IMPORTING config TYPE y_if_clean_code_manager=>check_configuration
error_count TYPE int4
Expand All @@ -144,7 +140,7 @@ CLASS y_check_base DEFINITION PUBLIC ABSTRACT
METHODS should_skip_test_code IMPORTING structure TYPE sstruc
RETURNING VALUE(result) TYPE abap_bool.

METHODS should_skip_type IMPORTING structure TYPE sstruc
METHODS should_skip_type IMPORTING structure TYPE sstruc
RETURNING VALUE(result) TYPE abap_bool.

METHODS is_statement_type_relevant IMPORTING structure TYPE sstruc
Expand All @@ -153,10 +149,8 @@ CLASS y_check_base DEFINITION PUBLIC ABSTRACT
METHODS is_structure_type_relevant IMPORTING structure TYPE sstruc
RETURNING VALUE(result) TYPE abap_bool.



METHODS get_application_component IMPORTING level TYPE slevel
RETURNING VALUE(result) TYPE df14l-ps_posid.
METHODS is_app_comp_in_scope IMPORTING level TYPE stmnt_levl
RETURNING value(result) TYPE abap_bool.

ENDCLASS.

Expand All @@ -169,16 +163,11 @@ CLASS y_check_base IMPLEMENTATION.
IF ref_scan_manager->is_scan_ok( ) = abap_false.
RAISE EXCEPTION TYPE ycx_object_not_processed.
ENDIF.

IF clean_code_exemption_handler->is_object_exempted( object_name = object_name object_type = object_type ) = abap_true.
RAISE EXCEPTION TYPE ycx_object_is_exempted.
ENDIF.
ENDMETHOD.


METHOD constructor.
super->constructor( ).
enable_rfc( ).

description = get_class_description( ).
category = 'Y_CATEGORY_CODE_PAL'.
Expand Down Expand Up @@ -210,9 +199,18 @@ CLASS y_check_base IMPLEMENTATION.


METHOD detect_check_configuration.
DATA tadir_keys TYPE tadir.

DATA(include) = get_include( p_level = statement-level ).
DATA(creation_date) = NEW y_object_creation_date( )->y_if_object_creation_date~get_program_create_date( include ).
DATA(level) = ref_scan_manager->levels[ statement-level ].

CALL FUNCTION 'TR_TRANSFORM_TRDIR_TO_TADIR'
EXPORTING
iv_trdir_name = level-name
IMPORTING
es_tadir_keys = tadir_keys.

DATA(creation_date) = clean_code_manager->calculate_obj_creation_date( object_type = tadir_keys-object
object_name = tadir_keys-obj_name ).

LOOP AT check_configurations ASSIGNING FIELD-SYMBOL(<configuration>)
WHERE object_creation_date <= creation_date.
Expand Down Expand Up @@ -249,8 +247,8 @@ CLASS y_check_base IMPLEMENTATION.

METHOD inspect_structures.
LOOP AT ref_scan_manager->structures ASSIGNING FIELD-SYMBOL(<structure>).
IF should_skip_test_code( <structure> ) = abap_true
OR should_skip_type( <structure> ) = abap_true.
IF should_skip_type( <structure> ) = abap_true
OR should_skip_test_code( <structure> ) = abap_true.
CONTINUE.
ENDIF.

Expand All @@ -265,10 +263,6 @@ CLASS y_check_base IMPLEMENTATION.
LOOP AT ref_scan_manager->statements ASSIGNING FIELD-SYMBOL(<statement>)
FROM structure-stmnt_from
TO structure-stmnt_to.
IF is_in_scope( <statement> ) = abap_false.
CONTINUE.
ENDIF.

inspect_tokens( index = index
structure = structure
statement = <statement> ).
Expand Down Expand Up @@ -586,7 +580,7 @@ CLASS y_check_base IMPLEMENTATION.
ENDIF.

IF clean_code_exemption_handler IS NOT BOUND.
clean_code_exemption_handler = y_exemption_handler=>create( ).
clean_code_exemption_handler = new y_exemption_handler( ).
ENDIF.

IF test_code_detector IS NOT BOUND.
Expand Down Expand Up @@ -636,13 +630,22 @@ CLASS y_check_base IMPLEMENTATION.


METHOD raise_error.
IF clean_code_exemption_handler->is_object_exempted( object_name = object_name object_type = object_type ) = abap_true.
RETURN.
ENDIF.

IF is_app_comp_in_scope( statement_level ) = abap_false.
RETURN.
ENDIF.

statistics->collect( kind = error_priority
pc = NEW y_pseudo_comment_detector( )->is_pseudo_comment( ref_scan_manager = ref_scan_manager
scimessages = scimessages
test = myname
code = get_code( error_priority )
suppress = settings-pseudo_comment
position = statement_index ) ).

IF cl_abap_typedescr=>describe_by_object_ref( ref_scan_manager )->get_relative_name( ) EQ 'Y_REF_SCAN_MANAGER'.
inform( p_sub_obj_type = object_type
p_sub_obj_name = get_include( p_level = statement_level )
Expand All @@ -664,7 +667,6 @@ CLASS y_check_base IMPLEMENTATION.
p_comments = pseudo_comments ).
ENDIF.


ENDMETHOD.


Expand Down Expand Up @@ -692,8 +694,7 @@ CLASS y_check_base IMPLEMENTATION.
ELSEIF attributes_ok = abap_true.
profile_configurations = check_configurations.
ENDIF.
CATCH ycx_object_not_processed
ycx_object_is_exempted.
CATCH ycx_object_not_processed.
FREE ref_scan_manager.
RETURN.

Expand All @@ -709,19 +710,6 @@ CLASS y_check_base IMPLEMENTATION.
ENDMETHOD.


METHOD enable_rfc.
ASSIGN me->('remote_rfc_enabled') TO FIELD-SYMBOL(<remote_rfc_enabled>).
IF sy-subrc = 0.
<remote_rfc_enabled> = abap_true.
ENDIF.
ASSIGN me->('remote_enabled') TO FIELD-SYMBOL(<remote_enabled>).
IF sy-subrc = 0.
<remote_enabled> = abap_true.
ENDIF.
UNASSIGN: <remote_rfc_enabled>, <remote_enabled>.
ENDMETHOD.


METHOD set_check_message.
y_message_registration=>add_message(
EXPORTING
Expand Down Expand Up @@ -790,30 +778,14 @@ CLASS y_check_base IMPLEMENTATION.
ENDMETHOD.


METHOD is_in_scope.
TRY.
DATA(main_level) = ref_scan_manager->levels[ level = 0 ].
DATA(main_application_component) = get_application_component( main_level ).
CATCH cx_sy_itab_line_not_found.
RETURN.
ENDTRY.

METHOD is_app_comp_in_scope.
TRY.
DATA(current_level) = ref_scan_manager->levels[ statement-level ].
DATA(current_application_component) = get_application_component( current_level ).
CATCH cx_sy_itab_line_not_found.
RETURN.
ENDTRY.

result = xsdbool( current_application_component = main_application_component ).
ENDMETHOD.


METHOD get_application_component.
TRY.
result = y_code_pal_app_comp=>get( level-name ).
CATCH ycx_entry_not_found.
RETURN.
DATA(main_app_comp) = y_code_pal_app_comp=>get( ref_scan_manager->levels[ level = 0 ] ).
DATA(curr_app_comp) = y_code_pal_app_comp=>get( ref_scan_manager->levels[ level ] ).
result = xsdbool( main_app_comp = curr_app_comp ).
CATCH cx_sy_itab_line_not_found
ycx_entry_not_found.
result = abap_false.
ENDTRY.
ENDMETHOD.

Expand Down
2 changes: 2 additions & 0 deletions src/foundation/y_check_base.clas.locals_imp.abap
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ CLASS ltd_check_base IMPLEMENTATION.
METHOD constructor.
super->constructor( ).
ref_scan_manager = NEW ltd_ref_scan_manager( ).
ref_scan_manager->set_ref_scan( VALUE #( ) ).
clean_code_manager = NEW y_clean_code_manager_double( me ).
ENDMETHOD.


Expand Down
20 changes: 4 additions & 16 deletions src/foundation/y_clean_code_manager.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ CLASS y_clean_code_manager DEFINITION PUBLIC CREATE PUBLIC.
INTERFACES y_if_clean_code_manager.
ALIASES calculate_obj_creation_date FOR y_if_clean_code_manager~calculate_obj_creation_date.
ALIASES read_check_customizing FOR y_if_clean_code_manager~read_check_customizing.
PROTECTED SECTION.

PRIVATE SECTION.
DATA object_creation_date TYPE REF TO y_if_object_creation_date.
METHODS determine_profiles RETURNING VALUE(result) TYPE string_table
RAISING ycx_no_check_customizing.

METHODS determine_checks IMPORTING profile TYPE ycicc_profile
checkid TYPE seoclsname
RETURNING VALUE(result) TYPE y_if_clean_code_manager=>check_configurations
Expand Down Expand Up @@ -76,20 +76,8 @@ CLASS y_clean_code_manager IMPLEMENTATION.


METHOD calculate_obj_creation_date.
IF object_creation_date IS NOT BOUND.
object_creation_date = NEW y_object_creation_date( ).
ENDIF.
CASE object_type.
WHEN 'INTF'.
result = object_creation_date->get_interface_create_date( object_name ).
WHEN 'CLAS'.
result = object_creation_date->get_class_create_date( object_name ).
WHEN 'FUGR'.
result = object_creation_date->get_function_group_create_date( object_name ).
WHEN 'PROG'.
result = object_creation_date->get_program_create_date( object_name ).
WHEN OTHERS.
ENDCASE.
result = y_object_creation_date=>get_created_on( object_type = object_type
object_name = object_name ).
ENDMETHOD.


Expand Down
Loading

0 comments on commit fd5b82d

Please sign in to comment.