sonar-next / sonar-swift

sonar-swift.SonarQube iOS Plugin, Support Objective-C/Swift/Java, Support import Infer Issue (SonarQube iOS 代码扫描插件,支持 Objective-C 和 Swift / Java,支持 Infer 结果导入 ) base on https://github.com/Idean/sonar-swift
Other
221 stars 39 forks source link

不使用infer, 只使用swiftlint和oclint, sonarqube上面显示了oc的结果, 但没有显示swift的结果 #22

Closed mzF414 closed 2 years ago

mzF414 commented 2 years ago

现象:

  1. 如题

环境:

  1. 使用了1.6.0和1.6.1版本插件;

  2. 工程下sonar-project.properties 内容如下:

sonar.projectKey=Douyin sonar.projectName=Douyin sonar.objectivec.project=Douyin.xcodeproj sonar.objectivec.workspace=Douyin.xcworkspace sonar.objectivec.simulator=platform=iOS Simulator,name=iPhone 12 mini,OS=latest sonar.objectivec.appScheme=Douyin sonar.language=ObjC sonar.sources=Douyin sonar.sourceEncoding=UTF-8 sonar.objectivec.oclint.report=sonar-reports/oclint.xml sonar.swift.swiftlint.report=sonar-reports/swiftlint.txt sonar.host.url=http://localhost:9090 sonar.login=4801e8054c3eed95d5914057b6a75be964851bff # sh -x run-sonar.sh -v -nounittests -usesonarscanner -nofauxpas

  1. 修改了run-sonar.sh文件, 会执行swiftlint
  2. 工程下的.swiftlint.yml 设置了reporter: "sonarqube"
  3. 运行完后有生成对应的oclint.xml文件和swiftlint.txt文件
  4. sonar-scanner执行成功, 日志如下:

+ sonar-scanner INFO: Scanner configuration file: /usr/local/Cellar/sonar-scanner/4.7.0.2747/libexec/conf/sonar-scanner.properties INFO: Project root configuration file: /Users/Project/mobile/douyin-ios-objectc/sonar-project.properties INFO: SonarScanner 4.7.0.2747 INFO: Java 11.0.12 Homebrew (64-bit) INFO: Mac OS X 12.2.1 x86_64 INFO: User cache: /Users/.sonar/cache INFO: Scanner configuration file: /usr/local/Cellar/sonar-scanner/4.7.0.2747/libexec/conf/sonar-scanner.properties INFO: Project root configuration file: /Users/Project/mobile/douyin-ios-objectc/sonar-project.properties INFO: Analyzing on SonarQube server 8.9.7 INFO: Default locale: "zhCN#Hans", source code encoding: "UTF-8" INFO: Load global settings INFO: Load global settings (done) | time=125ms INFO: Server id: BF41A1F2-AX-qLdTue6_SkrNxznMH INFO: User cache: /Users/.sonar/cache INFO: Load/download plugins INFO: Load plugins index INFO: Load plugins index (done) | time=80ms INFO: Load/download plugins (done) | time=344ms INFO: Process project properties INFO: Process project properties (done) | time=9ms INFO: Execute project builders INFO: Execute project builders (done) | time=1ms INFO: Project key: Douyin INFO: Base dir: /Users/Project/mobile/douyin-ios-objectc INFO: Working dir: /Users/Project/mobile/douyin-ios-objectc/.scannerwork INFO: Load project settings for component key: 'Douyin' INFO: Load project settings for component key: 'Douyin' (done) | time=31ms INFO: Load quality profiles INFO: Load quality profiles (done) | time=101ms INFO: Load active rules INFO: Load active rules (done) | time=2051ms INFO: Indexing files... INFO: Project configuration: INFO: 672 files indexed INFO: Quality profile for objc: OCLint INFO: Quality profile for swift: SwiftLint INFO: ------------- Run sensors on module Douyin INFO: Load metrics repository INFO: Load metrics repository (done) | time=29ms INFO: Sensor CSS Rules [cssfamily] INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped. INFO: Sensor CSS Rules [cssfamily] (done) | time=2ms INFO: Sensor JaCoCo XML Report Importer [jacoco] INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=6ms INFO: Sensor C# Project Type Information [csharp] INFO: Sensor C# Project Type Information [csharp] (done) | time=2ms INFO: Sensor C# Properties [csharp] INFO: Sensor C# Properties [csharp] (done) | time=0ms INFO: Sensor JavaXmlSensor [java] INFO: Sensor JavaXmlSensor [java] (done) | time=8ms INFO: Sensor HTML [web] INFO: Sensor HTML [web] (done) | time=6ms INFO: Sensor VB.NET Project Type Information [vbnet] INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=0ms INFO: Sensor VB.NET Properties [vbnet] INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms INFO: Sensor SwiftLint [swift] INFO: Processing SwiftLint report sonar-reports/Douyin-swiftlint.txt INFO: Sensor SwiftLint [swift] (done) | time=54ms INFO: Sensor Tailor [swift] INFO: Sensor Tailor [swift] (done) | time=1ms INFO: Sensor OCLint [swift] INFO: Processing OCLint report sonar-reports/Douyin-oclint.xml INFO: Load project repositories INFO: Load project repositories (done) | time=34ms INFO: Sensor OCLint [swift] (done) | time=859ms INFO: Sensor Infer [swift] INFO: Sensor Infer [swift] (done) | time=0ms INFO: Sensor FauxPas [swift] INFO: Sensor FauxPas [swift] (done) | time=1ms INFO: Sensor Swift Squid [swift] WARN: Metric 'lines' is an internal metric computed by SonarQube/SonarCloud. Provided value is ignored. INFO: Sensor Swift Squid [swift] (done) | time=69ms INFO: Sensor Objective-C Squid [swift] INFO: Sensor Objective-C Squid [swift] (done) | time=442ms INFO: Sensor Surefire [swift] INFO: Processing Surefire report TEST-report.xml INFO: Sensor Surefire [swift] (done) | time=70ms INFO: Sensor Cobertura [swift] INFO: Processing Cobertura report sonar-reports/coverage.xml INFO: Sensor Cobertura [swift] (done) | time=702ms INFO: Sensor Lizard [swift] INFO: Processing complexity report: /Users/Project/mobile/douyin-ios-objectc/sonar-reports/lizard-report.xml INFO: Sensor Lizard [swift] (done) | time=242ms INFO: ------------- Run sensors on project INFO: Sensor Dependency-Check [dependencycheck] INFO: Process Dependency-Check report INFO: Using JSON-Reportparser INFO: Dependency-Check JSON report does not exists. Please check property sonar.dependencyCheck.jsonReportPath:/Users/Project/mobile/douyin-ios-objectc/${WORKSPACE}/dependency-check-report.json INFO: JSON-Analysis skipped/aborted due to missing report file INFO: Using XML-Reportparser INFO: Dependency-Check XML report does not exists. Please check property sonar.dependencyCheck.xmlReportPath:/Users/Project/mobile/douyin-ios-objectc/${WORKSPACE}/dependency-check-report.xml INFO: XML-Analysis skipped/aborted due to missing report file INFO: Dependency-Check HTML report does not exists. Please check property sonar.dependencyCheck.htmlReportPath:/Users/Project/mobile/douyin-ios-objectc/${WORKSPACE}/dependency-check-report.html INFO: HTML-Dependency-Check report does not exist. INFO: Process Dependency-Check report (done) | time=4ms INFO: Sensor Dependency-Check [dependencycheck] (done) | time=4ms INFO: Sensor Zero Coverage Sensor INFO: Sensor Zero Coverage Sensor (done) | time=8ms INFO: SCM Publisher is disabled INFO: CPD Executor 26 files had no CPD blocks INFO: CPD Executor Calculating CPD for 55 files INFO: CPD Executor CPD calculation finished (done) | time=54ms INFO: Analysis report generated in 160ms, dir size=589 KB INFO: Analysis report compressed in 349ms, zip size=241 KB INFO: Analysis report uploaded in 51ms INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9090/dashboard?id=Douyin INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report INFO: More about the report processing at http://localhost:9090/api/ce/task?id=AX-xE2CDRl4vUnR3evP4 INFO: Analysis total time: 7.670 s INFO: ------------------------------------------------------------------------ INFO: EXECUTION SUCCESS INFO: ------------------------------------------------------------------------ INFO: Total time: 9.530s INFO: Final Memory: 7M/30M INFO: --


  1. sonarqube上只有oc相关的结果, 没有swift的
  2. 用这个工程做的代码扫描: https://github.com/sshiqiao/douyin-ios-objectc, 在里面加了swift代码
mzF414 commented 2 years ago

解决了:

  1. oclint-json-compilation-database -report-type 设置成pmd, 解决不显示oc扫描结果问题;
  2. 项目下.swiftlint.yml文件中, reporter 字段设置成 "xcode", 解决不显示swift扫描结果问题;