1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00
vcmi/test
Alexander Wilms 1b85abb508 Use auto instead of redundant type in initializations using new
grep -r --include \*.h --include \*.cpp "=" * | grep -v "auto\|int\|char\|bool\|float|\double\|for\|if\|googletest\|fuzzylite\|size_t\|using\|return\|{\|}\|= \"\|= tr(\|virtual\|void" | grep -Po ".*[^ ]+ [^ ]+ [^ ]*[ ]*=.*;" | grep -v "float\|nullptr" | grep "new" | grep -v "AI/FuzzyLite" | grep \( | grep "= new" > 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 = line.split(":")[1].strip()
        if "new " in original_code:

            cpp_type = original_code.split(" ")[0]
            if original_code.count(cpp_type) == 2:
                print()
                print(path)
                print(original_code)
                new_code = "auto "+" ".join(original_code.split(" ")[1:])
                print(new_code)

                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-16 21:40:53 +00:00
..
battle Use auto instead of redundant type in initializations using new 2024-01-16 21:40:53 +00:00
entity Disable broken tests so the working ones don't rot 2024-01-08 19:13:44 +00:00
erm vcmi: split bonus to enumerator and HeroBonus.h 2023-05-03 18:01:06 +03:00
events Fix Lua and test building 2023-10-23 16:05:38 +03: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 Disable broken tests so the working ones don't rot 2024-01-08 19:13:44 +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 Redone RMG template serialization using JSON serializer, added tests 2018-03-10 19:36:19 +03: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 Disable broken tests so the working ones don't rot 2024-01-08 19:13:44 +00:00
testdata Fix JSON files 2023-09-17 12:36:57 +00:00
vcai Define each identifier in a dedicated statement 2024-01-10 00:22:23 +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