Skip to content

Commit

Permalink
feat(CI/Codestyle); Check for double semicolons (azerothcore#20996)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kitzunu authored Dec 21, 2024
1 parent 08d5861 commit d2b88bd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions apps/codestyle/codestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ def misc_codestyle_check(file: io, file_path: str) -> None:

# used to check for "if/else (...) {" "} else" ignores "if/else (...) {...}" "#define ... if/else (...) {"
ifelse_curlyregex = r"^[^#define].*\s+(if|else)(\s*\(.*\))?\s*{[^}]*$|}\s*else(\s*{[^}]*$)"
# used to catch double semicolons ";;" ignores "(;;)"
double_semiregex = r"[^(];;[^)]"

# Parse all the file
for line_number, line in enumerate(file, start = 1):
if 'const auto&' in line:
Expand All @@ -240,6 +243,11 @@ def misc_codestyle_check(file: io, file_path: str) -> None:
print(
f"Curly brackets are not allowed to be leading or trailing if/else statements. Place it on a new line: {file_path} at line {line_number}")
check_failed = True
if re.match(double_semiregex, line):
print(
f"Double semicolon (;;) found in {file_path} at line {line_number}")
check_failed = True

# Handle the script error and update the result output
if check_failed:
error_handler = True
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Entities/Player/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ struct Runes

struct EnchantDuration
{
EnchantDuration() = default;;
EnchantDuration() = default;
EnchantDuration(Item* _item, EnchantmentSlot _slot, uint32 _leftduration) : item(_item), slot(_slot),
leftduration(_leftduration) { ASSERT(item); };

Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Entities/Player/PlayerSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void Player::_LoadCharacterSettings(PreparedQueryResult result)
{
Field* fields = result->Fetch();

std::string source = fields[0].Get<std::string>();;
std::string source = fields[0].Get<std::string>();
std::string data = fields[1].Get<std::string>();

std::vector<std::string_view> tokens = Acore::Tokenize(data, ' ', false);
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Handlers/MiscHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket& recvData)
return;

wstrToLower(wpacketPlayerName);
wstrToLower(wpacketGuildName);;
wstrToLower(wpacketGuildName);

// client send in case not set max level value 100 but Acore supports 255 max level,
// update it to show GMs with characters after 100 level
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Instances/InstanceSaveMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class InstanceSaveMgr
friend class InstanceSave;

private:
InstanceSaveMgr() = default;;
InstanceSaveMgr() = default;
~InstanceSaveMgr();

public:
Expand Down

0 comments on commit d2b88bd

Please sign in to comment.