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

CMacro.cppでのconst_castをやめる #1949

Conversation

suconbu
Copy link
Member

@suconbu suconbu commented May 1, 2024

PR対象

  • アプリ(サクラエディタ本体)

カテゴリ

  • リファクタリング

PR の背景

#1948 の修正を行った時にSonarCloudで指摘が出た箇所 (下記リンク) に関する修正になります。
https://sonarcloud.io/project/issues?resolved=false&sinceLeakPeriod=true&pullRequest=1948&id=sakura-editor_sakura

修正方法としては、

  • CMacro::HandleFunction とそれに関連する関数の引数 (Arguments) から const を取り除いた上で、
  • CMacro.cpp で VariantChangeType を呼び出している箇所の const_cast をすべて削除します。

既存コードの VariantChangeType の呼び出し箇所に const_cast が付いているのは、同じ VariantChangeType でもMinGW環境では第2引数に const が付かないプロトタイプとなっているためのようでした。

Msvc (oleauto.h)

WINOLEAUTAPI VariantChangeType(_Inout_ VARIANTARG * pvargDest,
               _In_ const VARIANTARG * pvarSrc, _In_ USHORT wFlags, _In_ VARTYPE vt);

MinGW (oleauto.h)

WINOLEAUTAPI VariantChangeType(VARIANTARG *pvargDest,VARIANTARG *pvarSrc,USHORT wFlags,VARTYPE vt);

仕様・動作説明

静的解析の指摘修正のみのため省略します。

PR の影響範囲

特にないと思います。

テスト内容

SonarCloudの指摘がなくなることを確認します。

関連 issue, PR

#1948

参考資料

Copy link

sonarcloud bot commented May 1, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
2.8% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

@AppVeyorBot
Copy link

Build sakura 1.0.4339 completed (commit b11ab9df93 by @suconbu)

@suconbu
Copy link
Member Author

suconbu commented May 4, 2024

レビューありがとうございます。
先に本PRからマージしてしまおうと思います。

@suconbu suconbu marked this pull request as ready for review May 4, 2024 07:27
@suconbu suconbu merged commit 2547a04 into sakura-editor:master May 4, 2024
20 of 24 checks passed
@suconbu suconbu added the refactoring リファクタリング 【ChangeLog除外】 label May 4, 2024
@suconbu suconbu deleted the feature/remove_constcast_in_handlefunction branch May 8, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring リファクタリング 【ChangeLog除外】
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants