Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SonarCloud解析の対象をReleaseからDebugに変更する #1515

Merged

Conversation

berryzplus
Copy link
Contributor

@berryzplus berryzplus commented Jan 24, 2021

PR の目的

SonarCloudの解析対象をデバッグビルドに変えることによりテストカバレッジを採れるようにします。

カテゴリ

  • ビルド関連
    • GitHub Actions

PR の背景

#1504 (comment) のコメントで報告された問題に対処します。

インライン関数やテンプレート関数のカバレッジが取れていないかもしれません。int2deccharcode.h の判定関数 などです。

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

参考資料

ReleaseビルドではOpenCppCoverageがインラインされたコードのカバレッジを採れないため。
@sonarcloud
Copy link

sonarcloud bot commented Jan 24, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@berryzplus
Copy link
Contributor Author

レビューありがとうございます。
マージしちゃいます。

@berryzplus berryzplus merged commit 57dad64 into sakura-editor:master Jan 24, 2021
@berryzplus berryzplus deleted the feature/change_analysis_target branch January 24, 2021 10:01
@beru beru added the GitHub Actions GitHub Actions関連 label Mar 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GitHub Actions GitHub Actions関連
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants