1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00
vcmi/launcher/lobby
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
..
chat_moc.cpp Fix compiling 2023-09-03 18:28:22 +04:00
chat_moc.h Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
chat_moc.ui Move chat logic to separate class 2023-09-03 03:05:48 +04:00
lobby_moc.cpp Use auto instead of redundant type in initializations using new 2024-01-16 21:40:53 +00:00
lobby_moc.h Minor fixes for lobby 2023-09-09 10:59:29 +02:00
lobby_moc.ui Move chat logic to separate class 2023-09-03 03:05:48 +04:00
lobby.cpp Support mod list 2022-11-17 03:15:26 +04:00
lobby.h Use the "nullptr" literal. 2023-10-27 18:18:59 +00:00
lobbyroomrequest_moc.cpp Formatting 2022-12-29 16:37:38 +02:00
lobbyroomrequest_moc.h Launcher translation upgrade, still WIP: 2022-12-25 13:19:16 +02:00
lobbyroomrequest_moc.ui Increased default width of lobby room creation window 2022-12-28 12:28:59 +02:00