1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00
vcmi/test
Alexander Wilms 73019c204d Replace redundant types with auto for the lvalues of template factory functions for smart pointers
grep -r --include \*.h --include \*.cpp "= std::" * | grep -v auto | grep -Po ".*[^ ]+ [^ ]+ [^ ]*[ ]*=.*;" | grep -v "auto\|int\|char\|bool\|float|\double\|for\|if\|googletest\|fuzzylite\|size_t\|using\|return" | grep -v double | grep -v si64 | grep -v si32 | grep -v ui32 | grep \< | grep -v float | tr -d '\t' | grep -v assert > redundant_types.txt

import re

with open("redundant_types.txt") as f:
    for line in f:
        line = line.strip()
        path = line.split(":", 1)[0]
        original_code = ":".join(line.split(":")[1:]).strip()

        print()
        print(path)
        print(original_code)
        prefix = "auto "
        if original_code.startswith("static"):
            static = True
        else:
            static = False

        cpp_type = " ".join(original_code.split("=")[0].strip().split(" ")[0:-1])
        print(cpp_type)

        if static:
            new_code = "static auto "+ " ".join(original_code.split(" ")[2:])
        else:
            new_code = "auto "+ " ".join(original_code.split(" ")[1:])
        print(new_code)

        if True:
            with open(path, "r") as f:
                filedata = f.read()

            filedata = filedata.replace(original_code, new_code)

            with open(path, "w") as f:
                f.write(filedata)
2024-01-17 12:50:00 +00:00
..
battle Use auto instead of redundant type in initializations using new 2024-01-16 21:40:53 +00:00
entity Replace redundant types with auto for the lvalues of template factory functions for smart pointers 2024-01-17 12:50:00 +00:00
erm Replace redundant types with auto for the lvalues of template factory functions for smart pointers 2024-01-17 12:50:00 +00:00
events Replace redundant types with auto for the lvalues of template factory functions for smart pointers 2024-01-17 12:50:00 +00:00
game Disable broken tests so the working ones don't rot 2024-01-08 19:13:44 +00:00
googletest@b796f7d446 vcmi: use std::optional 2023-04-17 00:43:13 +03:00
map Replace redundant types with auto for the lvalues of template factory functions for smart pointers 2024-01-17 12:50:00 +00:00
mock Use auto instead of redundant type in initializations using new 2024-01-16 21:40:53 +00:00
netpacks Fix Lua and test building 2023-10-23 16:05:38 +03:00
rmg Replace redundant types with auto for the lvalues of template factory functions for smart pointers 2024-01-17 12:50:00 +00:00
scripting Disable broken tests so the working ones don't rot 2024-01-08 19:13:44 +00:00
serializer vcmi: use std::optional 2023-04-17 00:43:13 +03:00
spells Replace redundant types with auto for the lvalues of template factory functions for smart pointers 2024-01-17 12:50:00 +00:00
testdata Fix JSON files 2023-09-17 12:36:57 +00:00
vcai Remove duplicate semicolons 2024-01-16 19:02:39 +00:00
CMakeLists.txt Replaced boost::thread_specific_ptr with thread_local 2023-08-23 16:32:29 +03:00
CMemoryBufferTest.cpp Migrating from boost test to google test. 2017-07-18 16:49:05 +02:00
CVcmiTestConfig.cpp tests: disable settings.init() 2023-04-27 20:59:55 +03:00
CVcmiTestConfig.h CMake: unittest improvements (#447) 2018-04-15 18:02:31 +07:00
JsonComparer.cpp Use API identical to std classes where possible 2023-08-23 16:32:29 +03:00
JsonComparer.h [tests] Moved JsonComparer to own file 2018-03-05 21:26:00 +03:00
main.cpp CMake: unittest improvements (#447) 2018-04-15 18:02:31 +07:00
StdInc.cpp convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
StdInc.h convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
Test.cbp Fixed build 2021-04-10 02:04:07 +03:00
Test.vcxproj Update VS files to 2019, partially fix test project 2019-06-09 17:28:55 +02:00
Test.vcxproj.filters Update VS files to 2019, partially fix test project 2019-06-09 17:28:55 +02:00