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

利用できないコマンドラインオプション「-WQ(INIファイルを出力して即終了)」を削除したことにより可能となったコード整理を実施する #1435

Conversation

berryzplus
Copy link
Contributor

PR の目的

利用できないコマンドラインオプション「-WQ(INIファイルを出力して即終了)」を削除したことにより可能となったコード整理を実施します。

カテゴリ

  • リファクタリング

PR の背景

#1432 で一度出した 14c8faf の出し直しです。

修正内容が挙動を変えないことを目視確認できるようにコミットを分けただけの代物です。
(といいつつ、内容は少し変えていますが:smiley:)

変更は個々のコミットを見たら自明となるように作ってあります。

緒tt迷った感じのコミットもいくつかあります。

  • 3a7aa9f 本質的には CProfile::WriteProfile でやるべきことなので、移動するならそっちじゃね?とか。それやるとリファクタリングじゃなくなるので、とりあえずメソッドの外に移動しています。
  • 6738182 この変更いらなくね?というのがあるかも知れません。もう一歩進めて IsPrivateSettings() というグローバル関数を作っても良いかも知れません。

PR のメリット

コードが多少分かりやすくなります。

PR のデメリット (トレードオフとかあれば)

とくにないと思います。

仕様・動作説明

仕様・動作に変更はありません。

このPRは不要となった共有メモリの構造体メンバーを削除するため、共有メモリバージョンを変更します。

-- 共有メモリバージョン
変更前 176
変更後 177

テスト内容

このPRは外部仕様を一切変更しないため、エディタの起動を確認できれば十分です。

PR の影響範囲

コントロールプロセスの初期化に影響する変更です。
sakura.exe.ini を使ってマルチユーザー設定にした場合の動作に影響します。

関連 issue, PR

#1432

参考資料

@AppVeyorBot
Copy link

Copy link
Contributor

@sanomari sanomari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あえて不完全な変更で止めてあるように見えました。

修正量や影響範囲が多くなってしまうとしても、修正をやり切ってしまったほうが良さそうに思います。

sakura_core/env/CShareData_IO.cpp Show resolved Hide resolved
@@ -39,9 +39,6 @@ struct EditInfo;

//! iniフォルダ設定 // 2007.05.31 ryoji
struct IniFolder {
bool m_bInit; // 初期化済フラグ
bool m_bReadPrivate; // マルチユーザ用iniからの読み出しフラグ
bool m_bWritePrivate; // マルチユーザ用iniへの書き込みフラグ
WCHAR m_szIniFile[_MAX_PATH]; // EXE基準のiniファイルパス
WCHAR m_szPrivateIniFile[_MAX_PATH]; // マルチユーザ用のiniファイルパス
}; /* iniフォルダ設定 */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この構造体を削ってしまってはいかかがでしょう。

この構造体を残しておくことのメリデメ

説明
メリット INIフォルダ判定結果をキャッシュできる。
デメリット 共有メモリに依存するので単体テストが書けない。

判定のオーバーヘッドも変数サイズもたいしたことないので、廃止して単体テストを書けるコードを増やしたほうがよさそうに思います。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PRの一部を分割したので一旦閉じて出し直します。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

う~ん、無理かも。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なんでですか?
具体的な理由を説明できますか?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なんでですか?
具体的な理由を説明できますか?

PRを出してもレビュアーが理解できないだろう、という意味で「無理かも」と書きました。

現在の単体テスト tests1.exe には4種類のテストが含まれています。

  1. 本物の単体テスト (コード+スタブ等でコードそのものの良し悪しを判断するテスト)
  2. 単体といいつつ、モジュールレベルの結合動作を確認するテスト (test-loadstring.cppなど)
  3. 単体といいつつ、システムレベルの結合動作を確認するテスト (test-winmain.cpp
  4. gtest の使用例サンプル

・・・。この情報だけでもお腹一杯になれると思います。

普通に考えて、目的の異なる複数の種類のテストが1モジュールに詰まっていることは問題だと思います。
たぶん先に、テストモジュールを分割する対応が要って、そこだけで20手(≒20PR)くらい要りそうです。

事前の変更を行っている間に、ここの変更のことを覚えている自信がないので閉じずに放置してある次第です。

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なんでですか?
具体的な理由を説明できますか?

PRを出してもレビュアーが理解できないだろう、という意味で「無理かも」と書きました。

誰でも理解できるようには説明できない、と解釈しました。

それは当然だと思います。

ここの実装をテスト可能にする話と単体テストの種類が混在している話は別じゃないかと思いました、テストを混在させたままでもテスト可能にする変更はできると思います。

もちろん、gmockを使うテストは不可能でしょうけど、必要なんですか?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これ、やりましょうか?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

どうぞ。

どの範囲を?って疑問はありますが、自分がレビュー側にまわったほうがマージが早い傾向にあると思います。
(まー、レビューが適当だからなんですけども 😄 )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

どうぞ。

どの範囲を?って疑問はありますが、自分がレビュー側にまわったほうがマージが早い傾向にあると思います。
(まー、レビューが適当だからなんですけども 😄 )

GetInidirをプロセスがない状態でも呼び出せるように変更する修正です。
このPRよりも一回り広い範囲の修正になると思います。

@berryzplus berryzplus marked this pull request as draft October 23, 2020 07:45
@beru beru added the refactoring リファクタリング 【ChangeLog除外】 label Nov 9, 2020
sanomari added a commit to sanomari/sakura-editor that referenced this pull request Jan 22, 2021
…ditor#1435

利用できないコマンドラインオプション「-WQ(INIファイルを出力して即終了)」を削除したことにより可能となったコード整理を実施する
@berryzplus
Copy link
Contributor Author

#1512 に完全に取り込まれるようなのでこちらは閉じてしまいます。

@berryzplus berryzplus closed this Jan 23, 2021
@berryzplus berryzplus deleted the feature/remove_write_quit_take2 branch January 23, 2021 05:17
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.

4 participants