Ошибка SonarQube во время сканирования CPD из-за обнаружения ошибки дублирования в проекте Java ant в конвейере GitLab CI - PullRequest
0 голосов
/ 16 апреля 2020

Я работаю над миграцией этого java муравейного проекта на GitLab. Я настроил ci pipe (сборка и сонарное сканирование). В первый раз сборка прошла успешно, даже несмотря на то, что было выдано несколько предупреждений об обнаружении дублирования во время сканирования CPD. Отладочные сообщения приведены ниже:

18:23:05.754 INFO: 60/60 files analyzed
18:23:05.783 INFO: 5 files had no CPD blocks
18:23:05.784 INFO: Calculating CPD for 28 files
18:23:05.784 DEBUG: Detection of duplications for path/to/common/handler/CommonFileReader.java
18:23:05.800 DEBUG: Detection of duplications for path/to/common/utility/NKBeePluginStatisticsUtil.java
18:23:05.801 DEBUG: Detection of duplications for path/to/common/exception/ValidationException.java
18:23:05.803 DEBUG: Detection of duplications for path/to/dbextractpaging/dao/DBExtractDao.java
18:23:05.805 DEBUG: Detection of duplications for path/to/dbextractpaging/handler/CustomItemWriter.java
18:23:05.808 DEBUG: Detection of duplications for path/to/dbextractpaging/businessobject/DBExtractDataHolder.java
18:23:05.827 DEBUG: Detection of duplications for path/to/common/apicall/SoiCall.java
18:23:05.828 DEBUG: Detection of duplications for path/to/dbextractpaging/handler/CloseActionDBExecutor.java
18:23:05.829 DEBUG: Detection of duplications for path/to/dbextractpaging/config/DBExtractConstants.java
18:23:05.831 DEBUG: Detection of duplications for path/to/dbextractpaging/handler/CustomJobListener.java
18:23:05.832 DEBUG: Detection of duplications for path/to/dbextractpaging/handler/CustomStepListener.java
18:23:05.834 DEBUG: Detection of duplications for path/to/dbextractpaging/utility/DBExtractCommonUtility.java
18:23:05.839 DEBUG: Detection of duplications for path/to/common/dto/DummyBuIdDTO.java
18:23:05.840 DEBUG: Detection of duplications for path/to/common/handler/CommonFileWriter.java
18:23:05.842 DEBUG: Detection of duplications for path/to/common/fix_sequence_values.sql
18:23:05.846 DEBUG: Detection of duplications for path/to/common/dao/NKBeePluginStatisticsDao.java
18:23:05.847 DEBUG: Detection of duplications for path/to/common/config/CommonApplicationConstants.java
18:23:05.848 DEBUG: Detection of duplications for path/to/dbextractpaging/dto/DBEXTRACTCONFIG.java
18:23:05.850 DEBUG: Detection of duplications for path/to/common/dto/ThufitabDTO.java
18:23:05.851 DEBUG: Detection of duplications for path/to/dbextractpaging/handler/CustomItemReader.java
18:23:05.855 DEBUG: Detection of duplications for path/to/common/dao/ThufiTabDao.java
18:23:05.856 DEBUG: Detection of duplications for path/to/common/tasklet/FileRenamingTasklet.java
18:23:05.856 DEBUG: Detection of duplications for path/to/common/dao/CommonDao.java
18:23:05.870 DEBUG: Detection of duplications for path/to/common/dto/NKBeePluginStatisticsDTO.java
18:23:05.872 DEBUG: Detection of duplications for path/to/dbextractpaging/utility/LoggerClass.java
18:23:05.872 DEBUG: Detection of duplications for path/to/database/sql/CA49_Rollback.sql
18:23:05.873 DEBUG: Detection of duplications for path/to/common/utility/CMSInterfaceImpl.java
18:23:05.875 DEBUG: Detection of duplications for path/to/database/sql/CA49_Insert.sql
18:23:05.876 INFO: CPD calculation finished
18:23:06.127 INFO: Analysis report generated in 239ms, dir size=819 KB
18:23:06.301 INFO: Analysis report compressed in 173ms, zip size=261 KB
18:23:06.302 INFO: Analysis report generated in project/path/.scannerwork/scanner-report
18:23:06.302 DEBUG: Upload report
18:23:07.604 DEBUG: POST 200 http://<sonarqube_instance>.com/api/ce/submit?projectKey=generic_batch_tool | time=1301ms
18:23:07.614 INFO: Analysis report uploaded in 1311ms
18:23:07.622 INFO: ANALYSIS SUCCESSFUL, you can browse http://<sonarqube_instance>.com/api/ce/submit?projectKey=generic_batch_tool
18:23:07.622 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
18:23:07.623 INFO: More about the report processing at http://<sonarqube_instance>/api/ce/task?id=AXF_FJhe6M49p5TDE7ib
18:23:07.627 DEBUG: Report metadata written to project/path/.scannerwork/report-task.txt
18:23:07.641 DEBUG: Post-jobs : Final report -> Final report
18:23:07.641 INFO: Executing post-job 'Final report'
18:23:07.659 INFO: Executing post-job 'Final report'
18:23:07.674 INFO: Analysis total time: 48.758 s
18:23:07.685 INFO: ------------------------------------------------------------------------
18:23:07.685 INFO: EXECUTION SUCCESS
18:23:07.685 INFO: ------------------------------------------------------------------------
18:23:07.686 INFO: Total time: 1:11.283s
18:23:07.968 INFO: Final Memory: 16M/160M
18:23:07.968 INFO: ------------------------------------------------------------------------

Сборка прошла успешно, как упоминалось ранее. Однако дальнейшая сборка не удалась из-за этой проблемы. Я продолжаю добавлять соответствующие файлы в исключения, и в следующем файле происходит сбой. Один за другим, каждый файл, с которым он столкнулся, находится в сообщении об ошибке, как показано ниже:

Первый запуск:

07:14:09.564 DEBUG: Detection of duplications for path/to/DBExtractCommonUtility.java
07:14:09.566 INFO: 
07:14:09.575 INFO: ------------------------------------------------------------------------
07:14:09.575 INFO: EXECUTION FAILURE
07:14:09.576 INFO: ------------------------------------------------------------------------
07:14:09.576 INFO: Total time: 37.847s
07:14:09.659 INFO: Final Memory: 16M/60M
07:14:09.659 INFO: ------------------------------------------------------------------------
07:14:09.659 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Fail during detection of duplication for path/to/DBExtractCommonUtility.java

Второй запуск:

06:47:04.898 DEBUG: Detection of duplications for path/to/CommonApplicationConstants.java
06:47:04.904 INFO: 
06:47:04.920 INFO: ------------------------------------------------------------------------
06:47:04.921 INFO: EXECUTION FAILURE
06:47:04.921 INFO: ------------------------------------------------------------------------
06:47:04.922 INFO: Total time: 45.768s
06:47:05.049 INFO: Final Memory: 7M/30M
06:47:05.049 INFO: ------------------------------------------------------------------------
06:47:05.049 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: Fail during detection of duplication for path/to/CommonApplicationConstants.java

Третий запустить:

06:51:59.266 DEBUG: Detection of duplications for path/to/CustomItemReader.java
06:51:59.269 INFO: 
06:51:59.302 INFO: ------------------------------------------------------------------------
06:51:59.303 INFO: EXECUTION FAILURE
06:51:59.303 INFO: ------------------------------------------------------------------------
06:51:59.304 INFO: Total time: 47.877s
06:51:59.457 ERROR: Error during SonarScanner execution
06:51:59.456 INFO: Final Memory: 16M/60M
06:51:59.457 INFO: ------------------------------------------------------------------------
java.lang.IllegalStateException: Fail during detection of duplication for path/to/CustomItemReader.java

Как обойти эту проблему? Что вызывает это? Я использую следующую конфигурацию ci для этой работы:

code-scan-sonarqube:
  stage: codescan
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
  script:
    - sonar-scanner -X -Dsonar.host.url="$SONARQUBE_BASE_URL" 
      -Dsonar.login="$SONARQUBE_TOKEN" 
      -Dsonar.projectKey="$SONARQUBE_PROJECT_KEY" 
      -Dsonar.projectName="$CI_PROJECT_NAME" 
      -Dsonar.projectVersion="$PROJECT_VERSION" 
      -Dsonar.exclusions=**/*.h,**/*.c,**/CommonApplicationConstants.java,**/CustomItemReader.java,**/DBExtractCommonUtility.java 
      -Dsonar.java.binaries="$CI_PROJECT_DIR"/build/build/classes
    - .devops/sonarqube_build_breaker.sh "$SONARQUBE_BASE_URL" "$SONARQUBE_TOKEN" "$SONARQUBE_PROJECT_KEY"
  tags:
    - maven
...