Don't run code inspector in parallel when disabled (#3348)

* Don't run code inspector in parallel when disabled

* Restructure if

* Fix spacing

* Fix comment position
This commit is contained in:
Frederik Hudák 2020-05-07 11:30:35 +02:00 committed by GitHub
parent 14a2820d30
commit a64b6d96f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,14 +40,16 @@ CLASS zcl_abapgit_code_inspector DEFINITION
PRIVATE SECTION.
DATA mv_success TYPE abap_bool .
TYPES: t_run_mode TYPE sychar01.
CONSTANTS:
BEGIN OF co_run_mode,
run_with_popup TYPE sychar01 VALUE 'P',
run_after_popup TYPE sychar01 VALUE 'A',
run_via_rfc TYPE sychar01 VALUE 'R',
run_in_batch TYPE sychar01 VALUE 'B',
run_loc_parallel TYPE sychar01 VALUE 'L',
run_direct TYPE sychar01 VALUE 'L',
run_with_popup TYPE t_run_mode VALUE 'P',
run_after_popup TYPE t_run_mode VALUE 'A',
run_via_rfc TYPE t_run_mode VALUE 'R',
run_in_batch TYPE t_run_mode VALUE 'B',
run_loc_parallel TYPE t_run_mode VALUE 'L',
run_direct TYPE t_run_mode VALUE 'L',
END OF co_run_mode .
DATA mo_inspection TYPE REF TO cl_ci_inspection .
DATA mv_name TYPE sci_objs .
@ -66,12 +68,16 @@ CLASS zcl_abapgit_code_inspector DEFINITION
zcx_abapgit_exception .
METHODS create_inspection
IMPORTING
!io_set TYPE REF TO cl_ci_objectset
!io_variant TYPE REF TO cl_ci_checkvariant
io_set TYPE REF TO cl_ci_objectset
io_variant TYPE REF TO cl_ci_checkvariant
RETURNING
VALUE(ro_inspection) TYPE REF TO cl_ci_inspection
RAISING
zcx_abapgit_exception .
METHODS decide_run_mode
RETURNING
VALUE(rv_run_mode) TYPE t_run_mode.
ENDCLASS.
@ -125,13 +131,7 @@ CLASS zcl_abapgit_code_inspector IMPLEMENTATION.
" Because we want to persist them so we can run it in parallel.
" Both are deleted afterwards.
mv_name = |{ sy-uname }_{ sy-datum }_{ sy-uzeit }|.
" We have to disable parallelization in batch because of lock errors.
IF sy-batch = abap_true.
mv_run_mode = co_run_mode-run_via_rfc.
ELSE.
mv_run_mode = co_run_mode-run_loc_parallel.
ENDIF.
mv_run_mode = decide_run_mode( ).
ENDMETHOD.
@ -339,4 +339,21 @@ CLASS zcl_abapgit_code_inspector IMPLEMENTATION.
ENDTRY.
ENDMETHOD.
METHOD decide_run_mode.
DATA: lo_settings TYPE REF TO zcl_abapgit_settings.
lo_settings = zcl_abapgit_persist_settings=>get_instance( )->read( ).
IF sy-batch = abap_true.
" We have to disable parallelization in batch because of lock errors.
rv_run_mode = co_run_mode-run_via_rfc.
ELSEIF lo_settings->get_parallel_proc_disabled( ) = abap_false.
rv_run_mode = co_run_mode-run_loc_parallel.
ELSE.
rv_run_mode = co_run_mode-run_via_rfc.
ENDIF.
ENDMETHOD.
ENDCLASS.