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 variables to avoid shadowing outer function #1102

Merged
merged 1 commit into from Feb 4, 2023

Conversation

ma8ma
Copy link
Collaborator

@ma8ma ma8ma commented Feb 4, 2023

ローカル変数の名前を変更して関数をシャドーイングしないように修正します。

cppcheck 2.10のレポート

src/cache.cpp:535:17: style: Local variable 'path_root' shadows outer function [shadowFunction]
    std::string path_root = CACHE::path_root();
                ^
src/cache.cpp:554:17: style: Local variable 'path_img_root' shadows outer function [shadowFunction]
    std::string path_img_root = CACHE::path_img_root();
                ^
src/cache.cpp:584:17: style: Local variable 'path_img_root' shadows outer function [shadowFunction]
    std::string path_img_root = CACHE::path_img_protect_root();
                ^
src/cache.cpp:633:17: style: Local variable 'path_board_root' shadows outer function [shadowFunction]
    std::string path_board_root = CACHE::path_board_root( url );
                ^
src/cache.cpp:656:17: style: Local variable 'path_logroot' shadows outer function [shadowFunction]
    std::string path_logroot = CACHE::path_logroot();
                ^
src/core.cpp:3336:24: style: Local variable 'slot_timeout' shadows outer function [shadowFunction]
    sigc::slot< bool > slot_timeout = sigc::bind( sigc::mem_fun(*this, &Core::slot_timeout), 0 );
                       ^

ローカル変数の名前を変更して関数をシャドーイングしないように修正します。

cppcheck 2.10のレポート
```
src/cache.cpp:535:17: style: Local variable 'path_root' shadows outer function [shadowFunction]
    std::string path_root = CACHE::path_root();
                ^
src/cache.cpp:554:17: style: Local variable 'path_img_root' shadows outer function [shadowFunction]
    std::string path_img_root = CACHE::path_img_root();
                ^
src/cache.cpp:584:17: style: Local variable 'path_img_root' shadows outer function [shadowFunction]
    std::string path_img_root = CACHE::path_img_protect_root();
                ^
src/cache.cpp:633:17: style: Local variable 'path_board_root' shadows outer function [shadowFunction]
    std::string path_board_root = CACHE::path_board_root( url );
                ^
src/cache.cpp:656:17: style: Local variable 'path_logroot' shadows outer function [shadowFunction]
    std::string path_logroot = CACHE::path_logroot();
                ^
src/core.cpp:3336:24: style: Local variable 'slot_timeout' shadows outer function [shadowFunction]
    sigc::slot< bool > slot_timeout = sigc::bind( sigc::mem_fun(*this, &Core::slot_timeout), 0 );
                       ^
```
@ma8ma ma8ma added the refactoring コードの整理 (バグ修正でも機能変更でもない) label Feb 4, 2023
@ma8ma ma8ma merged commit 9227d97 into master Feb 4, 2023
@ma8ma ma8ma deleted the rename-local-var-to-avoid-shadow-fucntion branch February 4, 2023 13:53
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