我第一次尝试在本地系统上的测试iOS项目上集成SonarQube。我已经下载并成功安装了SonarQube和SonarScanner。我还从here下载了最新的(0.4.6)胶木Sonar Swift插件。
以下是我的Sonar Scanner文件内容:
sonar.host.url=http://localhost:9000
sonar.login=admin
sonar.password=Vivy@123
sonar.projectKey=testSonar1
sonar.projectName=testSonar
# Number version (can be found automatically in plist, just comment this line)
sonar.projectVersion=1.0
# Comment if you have a project with mixed ObjC / Swift
sonar.language=swift
# Project description
sonar.projectDescription=Project Description
# Path to source directories
sonar.sources=.
# Path to test directories (comment if no test)
sonar.tests=testSonarTests,testSonarUITests
sonar.test.inclusions=**/*Test*/**
sonar.test.inclusions=*.swift
sonar.exclusions=**/*.xml,Pods/**/*,Reports/**/*
# Destination Simulator to run surefire
# As string expected in destination argument of xcodebuild command
# Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2
sonar.swift.simulator=platform=iOS Simulator,name=iPhone 8,OS=latest
# Xcode project configuration (.xcodeproj)
# and use the later to specify which project(s) to include in the analysis (comma separated list)
# Specify either xcodeproj or xcodeproj + xcworkspace
sonar.swift.project=testSonar.xcodeproj
#sonar.swift.workspace=testSonar.xcworkspace
# Specify your appname.
# This will be something like "myApp"
# Use when basename is different from targeted scheme.
# Or when slather fails with 'No product binary found'
sonar.swift.appName=testSonar
# Scheme to build your application
sonar.swift.appScheme=testSonar
# Configuration to use for your scheme. if you do not specify that the default will be Debug
sonar.swift.appConfiguration=Debug
##########################
# Optional configuration #
##########################
# Encoding of the source code
sonar.sourceEncoding=UTF-8
# SCM
# sonar.scm.enabled=true
# sonar.scm.url=scm:git:http://xxx
# JUnit report generated by run-sonar.sh is stored in sonar-reports/TEST-report.xml
# Change it only if you generate the file on your own
# The XML files have to be prefixed by TEST- otherwise they are not processed
sonar.junit.reportsPath=sonar-reports/
# Lizard report generated by run-sonar.sh is stored in sonar-reports/lizard-report.xml
# Change it only if you generate the file on your own
sonar.swift.lizard.report=sonar-reports/lizard-report.xml
# Cobertura report generated by run-sonar.sh is stored in sonar-reports/coverage-swift.xml
# Change it only if you generate the file on your own
sonar.swift.coverage.reportPattern=sonar-reports/cobertura.xml
# OCLint report generated by run-sonar.sh is stored in sonar-reports/oclint.xml
# Change it only if you generate the file on your own
sonar.swift.swiftlint.report=sonar-reports/swiftlint.txt
# Change it only if you generate the file on your own
#sonar.swift.tailor.report=sonar-reports/*tailor.txt
# Paths to exclude from coverage report (surefire, 3rd party libraries etc.)
sonar.swift.excludedPathsFromCoverage=build,DerivedData,fastlane,Pods,reports,testSonarTests,testSonarUITests,xcov_output
sonar.swift.excludedPathsFromCoverage=.*Tests.*
##########################
# Tailor configuration #
##########################
# Tailor configuration
# -l,--max-line-length=<0-999> maximum Line length (in characters)
# --list-files display Swift source files to be analyzed
# --max-class-length=<0-999> maximum Class length (in lines)
# --max-closure-length=<0-999> maximum Closure length (in lines)
# --max-file-length=<0-999> maximum File length (in lines)
# --max-function-length=<0-999> maximum Function length (in lines)
# --max-name-length=<0-999> maximum Identifier name length (in characters)
# --max-severity=<error|warning (default)> maximum severity
# --max-struct-length=<0-999> maximum Struct length (in lines)
# --min-name-length=<1-999> minimum Identifier name length (in characters)
sonar.swift.tailor.config=--no-color --max-line-length=100 --max-file-length=500 --max-name-length=40 --max-name-length=40 --min-name-length=4
当我执行我的sonar scanner时,我得到了Execution Success消息。但是当我去我的sonar控制台时,我得到了与一些html或python文件相关的bug。我没有得到任何与Swift相关的东西。请查看下面的截图:
我觉得不知何故声纳插件没有得到Map与SonarQube.此外,我可以看到生成的SonarFiles如下:
我如何修复它才能让我的SonarQube运行?
1条答案
按热度按时间ql3eal8s1#
脚本很好。除了安装上面提到的sonarqube,我还安装了另一个来自homebrew的版本。所以当我试图运行Sonar时,我实际上是从brew运行Sonar,而不是上面的那个。brew的Sonar不包含任何插件,所以我无法扫描我的Swift代码。