Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x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constructor IMPORTING !iv_package TYPE devclass RAISING zcx_abapgit_exception . PROTECTED SECTION. DATA mv_package TYPE devclass . METHODS create_variant IMPORTING !iv_variant TYPE sci_chkv RETURNING VALUE(ro_variant) TYPE REF TO cl_ci_checkvariant RAISING zcx_abapgit_exception . METHODS cleanup IMPORTING !io_set TYPE REF TO cl_ci_objectset RAISING zcx_abapgit_exception . METHODS skip_object IMPORTING !is_obj TYPE scir_objs RETURNING VALUE(rv_skip) TYPE abap_bool. PRIVATE SECTION. DATA mv_success TYPE abap_bool . DATA mv_summary TYPE string. TYPES: ty_run_mode TYPE c LENGTH 1. CONSTANTS: BEGIN OF co_run_mode, run_with_popup TYPE ty_run_mode VALUE 'P', run_after_popup TYPE ty_run_mode VALUE 'A', run_via_rfc TYPE ty_run_mode VALUE 'R', run_in_batch TYPE ty_run_mode VALUE 'B', run_loc_parallel TYPE ty_run_mode VALUE 'L', run_direct TYPE ty_run_mode VALUE 'L', END OF co_run_mode . DATA mo_inspection TYPE REF TO cl_ci_inspection . DATA mv_name TYPE sci_objs . DATA mv_run_mode TYPE c LENGTH 1 . METHODS create_objectset RETURNING VALUE(ro_set) TYPE REF TO cl_ci_objectset . METHODS run_inspection IMPORTING !io_inspection TYPE REF TO cl_ci_inspection RETURNING VALUE(rt_list) TYPE scit_alvlist RAISING zcx_abapgit_exception . METHODS create_inspection IMPORTING !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 ty_run_mode . METHODS filter_inspection CHANGING !ct_list TYPE scit_alvlist . ENDCLASS. CLASS zcl_abapgit_code_inspector IMPLEMENTATION. METHOD cleanup. IF mo_inspection IS BOUND. mo_inspection->delete( EXCEPTIONS locked = 1 error_in_enqueue = 2 not_authorized = 3 exceptn_appl_exists = 4 OTHERS = 5 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Couldn't delete inspection. Subrc = { sy-subrc }| ). ENDIF. ENDIF. io_set->delete( EXCEPTIONS exists_in_insp = 1 locked = 2 error_in_enqueue = 3 not_authorized = 4 exists_in_objs = 5 OTHERS = 6 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Couldn't delete objectset. Subrc = { sy-subrc }| ). ENDIF. ENDMETHOD. METHOD constructor. IF iv_package IS INITIAL. zcx_abapgit_exception=>raise( |Please supply package| ). ENDIF. mv_package = iv_package. " We create the inspection and objectset with dummy names. " 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 }|. mv_run_mode = decide_run_mode( ). ENDMETHOD. METHOD create_inspection. cl_ci_inspection=>create( EXPORTING p_user = sy-uname p_name = mv_name RECEIVING p_ref = ro_inspection EXCEPTIONS locked = 1 error_in_enqueue = 2 not_authorized = 3 OTHERS = 4 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Failed to create inspection. Subrc = { sy-subrc }| ). ENDIF. ro_inspection->set( p_chkv = io_variant p_objs = io_set ). ro_inspection->save( EXCEPTIONS missing_information = 1 insp_no_name = 2 not_enqueued = 3 OTHERS = 4 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Failed to save inspection. Subrc = { sy-subrc }| ). ENDIF. ENDMETHOD. METHOD create_objectset. DATA: lt_objs TYPE scit_objs, ls_obj TYPE scir_objs, lt_objs_check TYPE scit_objs, ls_item TYPE zif_abapgit_definitions=>ty_item, lt_packages TYPE zif_abapgit_sap_package=>ty_devclass_tt. lt_packages = zcl_abapgit_factory=>get_sap_package( mv_package )->list_subpackages( ). INSERT mv_package INTO TABLE lt_packages. SELECT object AS objtype obj_name AS objname FROM tadir INTO CORRESPONDING FIELDS OF TABLE lt_objs FOR ALL ENTRIES IN lt_packages WHERE devclass = lt_packages-table_line AND delflag = abap_false AND pgmid = 'R3TR' ##TOO_MANY_ITAB_FIELDS. "#EC CI_GENBUFF LOOP AT lt_objs INTO ls_obj. IF skip_object( ls_obj ) = abap_true. CONTINUE. ENDIF. ls_item-obj_type = ls_obj-objtype. ls_item-obj_name = ls_obj-objname. IF zcl_abapgit_objects=>exists( ls_item ) = abap_false. CONTINUE. ENDIF. INSERT ls_obj INTO TABLE lt_objs_check. ENDLOOP. ro_set = cl_ci_objectset=>save_from_list( p_name = mv_name p_objects = lt_objs_check ). ENDMETHOD. METHOD create_variant. IF iv_variant IS INITIAL. zcx_abapgit_exception=>raise( |No check variant supplied.| ). ENDIF. cl_ci_checkvariant=>get_ref( EXPORTING p_user = '' p_name = iv_variant RECEIVING p_ref = ro_variant EXCEPTIONS chkv_not_exists = 1 missing_parameter = 2 OTHERS = 3 ). CASE sy-subrc. WHEN 1. zcx_abapgit_exception=>raise( |Check variant { iv_variant } doesn't exist| ). WHEN 2. zcx_abapgit_exception=>raise( |Parameter missing for check variant { iv_variant }| ). ENDCASE. ENDMETHOD. METHOD decide_run_mode. DATA lo_settings TYPE REF TO zcl_abapgit_settings. lo_settings = zcl_abapgit_persist_factory=>get_settings( )->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. METHOD filter_inspection. " Remove findings in LSVIM* includes which are part of generated maintenance screens DELETE ct_list WHERE sobjtype = 'PROG' AND sobjname CP 'LSVIM*'. ENDMETHOD. METHOD run_inspection. io_inspection->run( EXPORTING p_howtorun = mv_run_mode EXCEPTIONS invalid_check_version = 1 OTHERS = 2 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |Code inspector run failed. Subrc = { sy-subrc }| ). ENDIF. io_inspection->plain_list( IMPORTING p_list = rt_list ). filter_inspection( CHANGING ct_list = rt_list ). SORT rt_list BY objtype objname test code sobjtype sobjname line col. DELETE ADJACENT DUPLICATES FROM rt_list. ENDMETHOD. METHOD skip_object. DATA ls_program_type TYPE subc. CASE is_obj-objtype. WHEN 'PROG'. SELECT SINGLE subc INTO ls_program_type FROM trdir WHERE name = is_obj-objname. rv_skip = boolc( ls_program_type = 'I' ). " Include program. WHEN OTHERS. rv_skip = abap_false. ENDCASE. ENDMETHOD. METHOD zif_abapgit_code_inspector~get_summary. rv_summary = mv_summary. ENDMETHOD. METHOD zif_abapgit_code_inspector~is_successful. rv_success = mv_success. ENDMETHOD. METHOD zif_abapgit_code_inspector~list_global_variants. SELECT scichkv_hd~checkvname AS name scichkv_tx~text AS description INTO TABLE rt_list FROM scichkv_hd LEFT OUTER JOIN scichkv_tx ON scichkv_hd~checkvid = scichkv_tx~checkvid AND scichkv_hd~ciuser = scichkv_tx~ciuser AND scichkv_tx~language = sy-langu WHERE scichkv_hd~ciuser = space ORDER BY name. ENDMETHOD. METHOD zif_abapgit_code_inspector~run. DATA: lo_set TYPE REF TO cl_ci_objectset, lo_variant TYPE REF TO cl_ci_checkvariant, lv_count TYPE i, lt_list TYPE scit_alvlist, ls_list LIKE LINE OF lt_list, ls_result LIKE LINE OF rt_list, lo_timer TYPE REF TO zcl_abapgit_timer, lx_error TYPE REF TO zcx_abapgit_exception. TRY. lo_set = create_objectset( ). lv_count = lines( lo_set->iobjlst-objects ). IF lv_count = 0. " no objects, nothing to check RETURN. ENDIF. lo_timer = zcl_abapgit_timer=>create( iv_count = lv_count )->start( ). lo_variant = create_variant( iv_variant ). mo_inspection = create_inspection( io_set = lo_set io_variant = lo_variant ). lt_list = run_inspection( mo_inspection ). cleanup( lo_set ). LOOP AT lt_list INTO ls_list. MOVE-CORRESPONDING ls_list TO ls_result. INSERT ls_result INTO TABLE rt_list. ENDLOOP. IF iv_save = abap_true. READ TABLE rt_list TRANSPORTING NO FIELDS WITH KEY kind = 'E'. mv_success = boolc( sy-subrc <> 0 ). ENDIF. CATCH zcx_abapgit_exception INTO lx_error. " ensure cleanup cleanup( lo_set ). zcx_abapgit_exception=>raise_with_text( lx_error ). ENDTRY. mv_summary = lo_timer->end( ). ENDMETHOD. METHOD zif_abapgit_code_inspector~validate_check_variant. cl_ci_checkvariant=>get_ref( EXPORTING p_user = '' p_name = iv_check_variant_name EXCEPTIONS chkv_not_exists = 1 missing_parameter = 2 OTHERS = 3 ). IF sy-subrc <> 0. zcx_abapgit_exception=>raise( |No valid check variant { iv_check_variant_name }| ). ENDIF. ENDMETHOD. ENDCLASS. |