SonarQubeの静的解析で検出されたFileNameSepExtのバグを修正する(その2) #1797
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にバグだと言われているコードを修正し、見た目の品質を上げます。
カテゴリ
※検知されたのは「nullチェック漏れによるクラッシュの可能性」ですが、
実態として実害はないと考えられるためリファクタリングとします。
PR の背景
SonarCloudにより以下の不具合が検出されています。
https://sonarcloud.io/project/issues?id=sakura-editor_sakura&issues=AXhxfE2dTNlLrH0R7vj9&open=AXhxfE2dTNlLrH0R7vj9
utif/file.cpp
内のローカル関数FileNameSepExt
の第一引数file
にnullptr
が渡された場合の考慮がないよ(≒渡ってきたら落ちるよ)という指摘です。PR のメリット
PR のデメリット (トレードオフとかあれば)
仕様・動作説明
アプリの仕様・機能に変更はありません。
file
にnullptr
を渡せないようにします。file1
とfile2
にnullptr
を渡せないようにします。WCHAR[260]
からstd::wstring
に変更します。PR の影響範囲
Diffダイアログに表示するファイル名比較に使われる関数です。
テスト内容
このPRは、修正部分のテストを含んでいます。
テスト1
手順
関連 issue, PR
参考資料