cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.28k stars 7.05k forks source link

Unneeded consecutive return statements #16855

Open Rubonnek opened 8 years ago

Rubonnek commented 8 years ago

For the following files, cppcheck is reporting duplicate consecutive return statements:

cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_audioengine_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_cocosbuilder_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_cocosdenshion_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_controller_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_csloader_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_video_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_experimental_webview_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_extension_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_navmesh_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_physics_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_spine_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_studio_auto.cpp
cocos/scripting/lua-bindings/auto/lua_cocos2dx_ui_auto.cpp
cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp
cocos/scripting/lua-bindings/manual/audioengine/lua_cocos2dx_audioengine_manual.cpp
cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_deprecated.cpp
cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_experimental_manual.cpp
cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_manual.cpp
cocos/scripting/lua-bindings/manual/cocos2d/lua_cocos2dx_physics_manual.cpp
cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_coco_studio_manual.cpp
cocos/scripting/lua-bindings/manual/cocostudio/lua_cocos2dx_csloader_manual.cpp
cocos/scripting/lua-bindings/manual/extension/lua_cocos2dx_extension_manual.cpp
cocos/scripting/lua-bindings/manual/navmesh/lua_cocos2dx_navmesh_manual.cpp
cocos/scripting/lua-bindings/manual/spine/lua_cocos2dx_spine_manual.cpp
cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_video_manual.cpp
cocos/scripting/lua-bindings/manual/ui/lua_cocos2dx_experimental_webview_manual.cpp
cocos/scripting/lua-bindings/manual/video/lua_cocos2dx_experimental_video_manual.cpp
plugin/luabindings/auto/lua_cocos2dx_pluginx_auto.cpp
plugin/luabindings/manual/lua_pluginx_manual_callback.cpp
plugin/luabindings/manual/lua_pluginx_manual_protocols.cpp

Some of the consecutive return statements pointed by cppcheck could be false positives due to them being in the body of an if-else branch, but for the most part it seems like the automatic update of the lua bindings generated many unneeded return statements.

See attached file for more details: cppcheck_consecutive_statements.txt

minggo commented 8 years ago

We can improve manual binding codes. About auto generated binding codes, we should improve the binding generator, which is not so easy.