Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Block commit/push if code inspection has errors
- new local setting to set check variant - new local setting to block pull if code inspector check fails - check is executed before staging - new page to display code inspector results
- Loading branch information
1 parent
307c139
commit ea79819
Showing
25 changed files
with
1,121 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,271 @@ | ||
CLASS zcl_abapgit_gui_page_code_insp DEFINITION PUBLIC FINAL CREATE PUBLIC | ||
INHERITING FROM zcl_abapgit_gui_page. | ||
|
||
PUBLIC SECTION. | ||
METHODS: | ||
constructor | ||
IMPORTING | ||
io_repo TYPE REF TO zcl_abapgit_repo | ||
RAISING | ||
zcx_abapgit_exception, | ||
|
||
zif_abapgit_gui_page~on_event | ||
REDEFINITION, | ||
|
||
zif_abapgit_gui_page~render | ||
REDEFINITION. | ||
|
||
|
||
PROTECTED SECTION. | ||
DATA: mo_repo TYPE REF TO zcl_abapgit_repo_online. | ||
|
||
METHODS: | ||
render_content REDEFINITION. | ||
|
||
PRIVATE SECTION. | ||
CONSTANTS: | ||
BEGIN OF c_actions, | ||
stage TYPE string VALUE 'stage' ##NO_TEXT, | ||
rerun TYPE string VALUE 'rerun' ##NO_TEXT, | ||
END OF c_actions. | ||
|
||
DATA: | ||
mt_result TYPE scit_alvlist. | ||
|
||
METHODS: | ||
build_menu | ||
RETURNING | ||
VALUE(ro_menu) TYPE REF TO zcl_abapgit_html_toolbar, | ||
|
||
run_code_inspector | ||
RAISING | ||
zcx_abapgit_exception, | ||
|
||
has_inspection_errors | ||
RETURNING | ||
VALUE(rv_has_inspection_errors) TYPE abap_bool, | ||
|
||
is_stage_allowed | ||
RETURNING | ||
VALUE(rv_is_stage_allowed) TYPE abap_bool, | ||
jump | ||
IMPORTING | ||
is_item TYPE zif_abapgit_definitions=>ty_item | ||
RAISING | ||
zcx_abapgit_exception. | ||
|
||
ENDCLASS. | ||
|
||
|
||
|
||
CLASS zcl_abapgit_gui_page_code_insp IMPLEMENTATION. | ||
|
||
|
||
METHOD build_menu. | ||
|
||
DATA: lv_opt TYPE c LENGTH 1. | ||
|
||
CREATE OBJECT ro_menu. | ||
|
||
ro_menu->add( iv_txt = 'Re-Run' | ||
iv_act = c_actions-rerun | ||
iv_cur = abap_false ) ##NO_TEXT. | ||
|
||
IF is_stage_allowed( ) = abap_false. | ||
lv_opt = zif_abapgit_definitions=>gc_html_opt-crossout. | ||
ENDIF. | ||
|
||
ro_menu->add( iv_txt = 'Stage' | ||
iv_act = c_actions-stage | ||
iv_cur = abap_false | ||
iv_opt = lv_opt ) ##NO_TEXT. | ||
|
||
ENDMETHOD. | ||
|
||
|
||
METHOD constructor. | ||
super->constructor( ). | ||
mo_repo ?= io_repo. | ||
ms_control-page_title = 'Code Inspector'. | ||
run_code_inspector( ). | ||
ENDMETHOD. " constructor. | ||
|
||
|
||
METHOD has_inspection_errors. | ||
|
||
READ TABLE mt_result TRANSPORTING NO FIELDS | ||
WITH KEY kind = 'E'. | ||
rv_has_inspection_errors = boolc( sy-subrc = 0 ). | ||
|
||
ENDMETHOD. | ||
|
||
|
||
METHOD is_stage_allowed. | ||
|
||
rv_is_stage_allowed = boolc( NOT ( mo_repo->get_local_settings( )-block_commit = abap_true | ||
AND has_inspection_errors( ) = abap_true ) ). | ||
|
||
ENDMETHOD. | ||
|
||
|
||
METHOD render_content. | ||
|
||
DATA: lv_check_variant TYPE sci_chkv, | ||
lv_class TYPE string. | ||
FIELD-SYMBOLS: <ls_result> TYPE scir_alvlist. | ||
|
||
CREATE OBJECT ro_html. | ||
|
||
lv_check_variant = mo_repo->get_local_settings( )-code_inspector_check_variant. | ||
|
||
IF lv_check_variant IS INITIAL. | ||
ro_html->add( |No check variant maintained in repo settings.| ). | ||
RETURN. | ||
ENDIF. | ||
|
||
ro_html->add( '<div class="toc"><br/>' ). | ||
|
||
ro_html->add( |Code inspector check variant: { | ||
mo_repo->get_local_settings( )-code_inspector_check_variant | ||
}<br/>| ). | ||
|
||
IF lines( mt_result ) = 0. | ||
ro_html->add( '<br/><div class="success">No code inspector findings</div>' ). | ||
ENDIF. | ||
|
||
ro_html->add( |<br/>| ). | ||
|
||
LOOP AT mt_result ASSIGNING <ls_result>. | ||
|
||
ro_html->add( '<div>' ). | ||
ro_html->add_a( iv_txt = |{ <ls_result>-objtype } { <ls_result>-objname }| | ||
iv_act = |{ <ls_result>-objtype }{ <ls_result>-objname }| | ||
iv_typ = zif_abapgit_definitions=>gc_action_type-sapevent ). | ||
ro_html->add( '</div>' ). | ||
|
||
CASE <ls_result>-kind. | ||
WHEN 'E'. | ||
lv_class = 'error'. | ||
WHEN 'W'. | ||
lv_class = 'warning'. | ||
WHEN OTHERS. | ||
lv_class = 'grey'. | ||
ENDCASE. | ||
|
||
ro_html->add( |<div class="{ lv_class }">Line { <ls_result>-line ALPHA = OUT }: { <ls_result>-text }</div><br>| ). | ||
ENDLOOP. | ||
|
||
ro_html->add( '</div>' ). | ||
|
||
ENDMETHOD. "render_content | ||
|
||
|
||
METHOD run_code_inspector. | ||
|
||
mt_result = mo_repo->run_code_inspector( ). | ||
|
||
ENDMETHOD. | ||
|
||
|
||
METHOD zif_abapgit_gui_page~on_event. | ||
|
||
DATA: lo_repo_online TYPE REF TO zcl_abapgit_repo_online, | ||
ls_item TYPE zif_abapgit_definitions=>ty_item. | ||
|
||
lo_repo_online ?= mo_repo. | ||
|
||
CASE iv_action. | ||
WHEN c_actions-stage. | ||
|
||
IF is_stage_allowed( ) = abap_true. | ||
|
||
" we need to refresh as the source might have changed | ||
lo_repo_online->refresh( ). | ||
|
||
CREATE OBJECT ei_page TYPE zcl_abapgit_gui_page_stage | ||
EXPORTING | ||
io_repo = lo_repo_online. | ||
|
||
ev_state = zif_abapgit_definitions=>gc_event_state-new_page. | ||
|
||
ELSE. | ||
|
||
ei_page = me. | ||
ev_state = zif_abapgit_definitions=>gc_event_state-no_more_act. | ||
|
||
ENDIF. | ||
|
||
WHEN c_actions-rerun. | ||
|
||
run_code_inspector( ). | ||
|
||
ei_page = me. | ||
ev_state = zif_abapgit_definitions=>gc_event_state-re_render. | ||
|
||
WHEN OTHERS. | ||
|
||
ls_item-obj_type = iv_action(4). | ||
ls_item-obj_name = iv_action+4(*). | ||
|
||
jump( ls_item ). | ||
|
||
* zcl_abapgit_objects=>jump( ls_item ). | ||
|
||
ev_state = zif_abapgit_definitions=>gc_event_state-no_more_act. | ||
|
||
ENDCASE. | ||
|
||
ENDMETHOD. | ||
|
||
|
||
METHOD zif_abapgit_gui_page~render. | ||
|
||
ms_control-page_menu = build_menu( ). | ||
ro_html = super->zif_abapgit_gui_page~render( ). | ||
|
||
ENDMETHOD. | ||
|
||
|
||
METHOD jump. | ||
|
||
DATA: lo_test TYPE REF TO cl_ci_test_root, | ||
li_code_inspector TYPE REF TO zif_abapgit_code_inspector, | ||
ls_info TYPE scir_rest, | ||
lo_result TYPE REF TO cl_ci_result_root, | ||
lv_check_variant_name TYPE sci_chkv, | ||
lv_package TYPE devclass, | ||
lv_srcid TYPE scr_source_id. | ||
|
||
FIELD-SYMBOLS: <ls_result> TYPE scir_alvlist. | ||
|
||
READ TABLE mt_result WITH KEY objtype = is_item-obj_type | ||
objname = is_item-obj_name | ||
ASSIGNING <ls_result>. | ||
ASSERT sy-subrc = 0. | ||
|
||
lv_package = mo_repo->get_package( ). | ||
lv_check_variant_name = mo_repo->get_local_settings( )-code_inspector_check_variant. | ||
|
||
li_code_inspector = zcl_abapgit_factory=>get_code_inspector( | ||
iv_package = lv_package | ||
iv_check_variant_name = lv_check_variant_name ). | ||
|
||
" see SCI_LCL_DYNP_530 / HANDLE_DOUBLE_CLICK | ||
|
||
MOVE-CORRESPONDING <ls_result> TO ls_info. | ||
|
||
lo_test = cl_ci_tests=>get_test_ref( <ls_result>-test ). | ||
lo_result = lo_test->get_result_node( <ls_result>-kind ). | ||
|
||
lv_srcid = li_code_inspector->get_inspection( )->objs->objectsinf-srcid. | ||
|
||
lo_result->set_srcid( | ||
p_info = ls_info | ||
p_srcid = lv_srcid ). | ||
|
||
lo_result->set_info( ls_info ). | ||
lo_result->if_ci_test~navigate( ). | ||
|
||
ENDMETHOD. | ||
|
||
ENDCLASS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0"> | ||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"> | ||
<asx:values> | ||
<VSEOCLASS> | ||
<CLSNAME>ZCL_ABAPGIT_GUI_PAGE_CODE_INSP</CLSNAME> | ||
<VERSION>1</VERSION> | ||
<LANGU>E</LANGU> | ||
<DESCRIPT>GUI - Syntax check page</DESCRIPT> | ||
<EXPOSURE>2</EXPOSURE> | ||
<STATE>1</STATE> | ||
<CLSFINAL>X</CLSFINAL> | ||
<CLSCCINCL>X</CLSCCINCL> | ||
<FIXPT>X</FIXPT> | ||
<UNICODE>X</UNICODE> | ||
</VSEOCLASS> | ||
</asx:values> | ||
</asx:abap> | ||
</abapGit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.