SonarCloud解析の対象をReleaseからDebugに変更する #1515
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR の目的
SonarCloudの解析対象をデバッグビルドに変えることによりテストカバレッジを採れるようにします。
カテゴリ
PR の背景
#1504 (comment) のコメントで報告された問題に対処します。
PR のメリット
*インライン関数のカバレッジが取れるようになると考えられます。
PR のデメリット (トレードオフとかあれば)
仕様・動作説明
アプリ(=サクラエディタ)の仕様・動作に変更はありません。
SonarCloud静的解析の解析対象をReleaseビルドからDebugビルドに変更します。
そもそもDebugビルドはモジュールにデバッグ情報を含めることで開発中プログラムに潜む問題を検出しやすくするためのものです。Visual C++はモジュール内の特定のアドレス範囲がどのソースコードから作られたかを記録しておくプログラムデータベース(PDB)というものを生成できます。PDBからデバッグ情報を読み取るためのAPIは公開されていて、正しく扱えばReleaseビルドのプログラムのデバッグを行うことも可能です。
静的解析のカバレッジ計測にはOpenCppCoverageを使っています。
このツールもPDBを利用しているんですが、最適化されたビルドへの対応が十分でないようです。(vs2013に特化した最適化対応機能がありますけど現在も使えるかどうかは不明です)
サクラエディタのReleaseビルドは最適化を有効にしているので、OpenCppCoverageでは正しくカバレッジを採れません。
別のツールを探すってのも面倒なので、Debugビルドに切り替えることでカバレッジを採れるようにします。
PR の影響範囲
テスト内容
事前に別ブランチで解析を実行し、インライン化されたコードの分カバレッジが向上することを確認しました。
https://github.com/berryzplus/sakura/runs/1756303561
11.2% ⇒ 11.7%
関連 issue, PR
#1504
参考資料