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

Rename local variable to avoid shadowing #349

Merged
merged 6 commits into from Jun 20, 2020

Conversation

ma8ma
Copy link
Collaborator

@ma8ma ma8ma commented Jun 20, 2020

ローカル変数の名前がシャドウイングされているとcppcheckに指摘されたため重複している変数名を変更します。

cppcheckのレポートはコミットメッセージを参照してください。

ローカル変数の名前がシャドウイングされているとcppcheckに指摘されたため
外側のスコープの名前を変更します。

cppcheckのレポート
```
src/bbslist/bbslistviewbase.cpp:2539:23: style: Local variable 'path' shadows outer variable [shadowVariable]
        Gtk::TreePath path = GET_PATH( row );
                      ^
src/bbslist/bbslistviewbase.cpp:2526:19: note: Shadowed declaration
    Gtk::TreePath path = m_treeview.get_current_path();
                  ^
src/bbslist/bbslistviewbase.cpp:2539:23: note: Shadow variable
        Gtk::TreePath path = GET_PATH( row );
                      ^
```
ローカル変数の名前がシャドウイングされているとcppcheckに指摘されたため
内側のスコープの名前を変更します。

cppcheckのレポート
```
src/control/controlutil.cpp:214:29: style: Local variable 'label' shadows outer variable [shadowVariable]
                Gtk::Label *label = Gtk::manage( new Gtk::Label( str_label + ( str_motions.empty() ? "" : "  " ), true ) );
                            ^
src/control/controlutil.cpp:198:21: note: Shadowed declaration
        auto* const label = dynamic_cast< Gtk::Label* >( item->get_child() );
                    ^
src/control/controlutil.cpp:214:29: note: Shadow variable
                Gtk::Label *label = Gtk::manage( new Gtk::Label( str_label + ( str_motions.empty() ? "" : "  " ), true ) );
                            ^
```
ローカル変数の名前がシャドウイングされているとcppcheckに指摘されたため
内側のスコープの名前を変更します。

cppcheckのレポート
```
src/article/drawareabase.cpp:3619:24: style: Local variable 'caret_pos' shadows outer variable [shadowVariable]
        CARET_POSITION caret_pos;
                       ^
src/article/drawareabase.cpp:3441:20: note: Shadowed declaration
    CARET_POSITION caret_pos;
                   ^
src/article/drawareabase.cpp:3619:24: note: Shadow variable
        CARET_POSITION caret_pos;
                       ^
```
ローカル変数の名前がシャドウイングされているとcppcheckに指摘されたため
内側のスコープの名前を変更します。

cppcheckのレポート
```
src/history/historymanager.cpp:258:23: style: Local variable 'type' shadows outer variable [shadowVariable]
            const int type = XML::get_type( histitem->nodeName() );
                      ^
src/history/historymanager.cpp:234:19: note: Shadowed declaration
        const int type = XML::get_type( subdir->nodeName() );
                  ^
src/history/historymanager.cpp:258:23: note: Shadow variable
            const int type = XML::get_type( histitem->nodeName() );
                      ^
```
ローカル変数の名前がシャドウイングされているとcppcheckに指摘されたため
内側のスコープの名前を変更します。

cppcheckのレポート
```
src/message/post.cpp:434:23: style: Local variable 'ret' shadows outer variable [shadowVariable]
            const int ret = mdiag.run();
                      ^
src/message/post.cpp:283:10: note: Shadowed declaration
    bool ret;
         ^
src/message/post.cpp:434:23: note: Shadow variable
            const int ret = mdiag.run();
                      ^
```
ローカル変数の名前がシャドウイングされているとcppcheckに指摘されたため
名前を変更します。

cppcheckのレポート
```
src/skeleton/edittreeview.cpp:1210:20: style: Local variable 'dir' shadows outer variable [shadowVariable]
        const bool dir = false;
                   ^
src/skeleton/edittreeview.cpp:1195:16: note: Shadowed declaration
    const bool dir = true;
               ^
src/skeleton/edittreeview.cpp:1210:20: note: Shadow variable
        const bool dir = false;
                   ^
```
@ma8ma ma8ma added the refactoring コードの整理 (バグ修正でも機能変更でもない) label Jun 20, 2020
@ma8ma ma8ma merged commit fbe0b4c into JDimproved:master Jun 20, 2020
@ma8ma ma8ma added this to Done in State of JDim-v0.3.0+ via automation Jun 20, 2020
@ma8ma ma8ma deleted the rename-local-var-to-avoid-shadowing branch June 20, 2020 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring コードの整理 (バグ修正でも機能変更でもない)
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

1 participant