You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Progress(Open Edge)语言SonarCloud扫描咨询:工具、集成及格式转换

解决方案:Progress(Open Edge) 代码分析与SonarCloud集成(Azure Pipelines环境)

1. 可用的第三方代码分析工具

  • OpenEdge Code Analyzer (OECA):Progress官方出品的静态代码分析工具,专门适配Open Edge语言,可检测代码合规性、性能瓶颈、潜在逻辑bug,支持生成结构化XML报告。
  • Prolint:Open Edge生态中广泛使用的开源静态分析工具,社区维护活跃,支持自定义规则集,输出包含问题详情的文本或XML格式报告。
  • 自定义脚本:如果上述工具无法满足特定需求,可基于Progress提供的ABL解析API编写脚本,针对性提取代码中的问题点。

2. Azure Pipelines与SonarCloud集成第三方工具的步骤

步骤1:在Pipeline中执行第三方分析工具

以Prolint为例,添加Command Line任务执行分析:

# 假设Prolint已部署在代理机器上
prolint.bat -source "src/**/*.p" -output "prolint-results.xml" -ruleset "custom-rules.xml"

若使用OECA,调用官方命令行工具:

oeca-cli.exe analyze -project "my-openedge-project" -sourceDir "./src" -reportFile "oeca-results.xml"

步骤2:配置SonarCloud准备任务

在Azure Pipelines的SonarCloudPrepare任务中,指定后续要导入的通用报告路径:

- task: SonarCloudPrepare@1
  inputs:
    SonarCloud: 'SonarCloud-Service-Connection'
    organization: 'your-org'
    scannerMode: 'CLI'
    configMode: 'manual'
    cliProjectKey: 'your-project-key'
    cliProjectName: 'your-project-name'
    extraProperties: |
      sonar.externalIssuesReportPaths=$(Build.SourcesDirectory)/converted-sonar-issues.json

3. 将第三方报告转换为SonarCloud Generic Issues格式

SonarCloud的Generic Issues要求JSON格式,核心字段包括engineId、ruleId、primaryLocation(含message、filePath、textRange)等。

转换脚本示例(PowerShell)

以Prolint的XML报告为例,编写解析转换脚本:

# 读取Prolint结果XML
$prolintResults = [xml](Get-Content "prolint-results.xml")
$sonarIssues = @()

foreach ($issue in $prolintResults.ProLint.Issues.Issue) {
    $issueObj = [PSCustomObject]@{
        engineId = "prolint"
        ruleId = $issue.Rule
        primaryLocation = @{
            message = $issue.Description
            filePath = $issue.FilePath
            textRange = @{
                startLine = [int]$issue.Line
                endLine = [int]$issue.Line
            }
        }
        severity = switch ($issue.Severity) {
            "High" { "CRITICAL" }
            "Medium" { "MAJOR" }
            "Low" { "MINOR" }
            default { "INFO" }
        }
    }
    $sonarIssues += $issueObj
}

# 输出SonarCloud兼容的JSON文件
$sonarIssues | ConvertTo-Json -Depth 10 | Out-File "converted-sonar-issues.json" -Encoding utf8

关键注意事项

  • filePath必须是相对于SonarCloud项目根目录的路径,否则无法关联到代码文件。
  • 需将第三方工具的严重级别映射为SonarCloud标准级别:CRITICAL、MAJOR、MINOR、INFO。
  • 若工具报告无行号,可省略textRange字段,或设置startLine为1。

在Pipeline中添加转换任务

在第三方工具执行任务之后、SonarCloud准备任务之前,添加PowerShell任务运行转换脚本:

- task: PowerShell@2
  inputs:
    targetType: 'filePath'
    filePath: '$(Build.SourcesDirectory)/convert-prolint-to-sonar.ps1'

内容的提问来源于stack exchange,提问作者user22389296

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 21:38:28