Skip to content

Commit

Permalink
remove unused trkey values
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpoelen committed Apr 4, 2024
1 parent 24b6fb9 commit 1e0a0fb
Show file tree
Hide file tree
Showing 7 changed files with 345 additions and 415 deletions.
8 changes: 0 additions & 8 deletions src/utils/trkeys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,13 @@ namespace trkeys
TR_KV(diagnostic, "Diagnostic");
TR_KV(connection_closed, "Connection closed");
TR_KV(OK, "OK");
TR_KV(cancel, "Cancel");
TR_KV(help, "Help");
TR_KV(close, "Close");
TR_KV(refused, "Refused");
TR_KV(username, "Username");
TR_KV(password_expire, "Your Bastion password will expire soon. Please change it.");
TR_KV(protocol, "Protocol");
TR_KV(authorization, "Authorization");
TR_KV(target, "Target");
TR_KV(description, "Description");
TR_KV(close_time, "Close Time");
TR_KV(logout, "Logout");
TR_KV(apply, "Apply");
TR_KV(filter, "Filter");
TR_KV(connect, "Connect");
TR_KV(timeleft, "Time left");
Expand Down Expand Up @@ -82,7 +76,6 @@ namespace trkeys
TR_KV(target_shadow_fail, "Failed to connect to remote host. Maybe the session invitation has expired.");
TR_KV(authentification_rdp_fail, "Failed to authenticate with remote RDP host.");
TR_KV(authentification_vnc_fail, "Failed to authenticate with remote VNC host.");
TR_KV(authentification_x_fail, "Failed to authenticate with remote X host.");
TR_KV(connection_ended, "Connection to server ended.");
TR_KV(no_results, "No results found");
TR_KV(back_selector, "Back to Selector");
Expand All @@ -100,7 +93,6 @@ namespace trkeys
TR_KV_FMT(fmt_invalid_format, "Error: %s invalid format.");
TR_KV_FMT(fmt_toohigh_duration, "Error: %s is too high (max: %d minutes).");
TR_KV(information, "Information");
TR_KV(authentication_required, "Authentication Required");
TR_KV(target_info_required, "Target Information Required");
TR_KV(device, "Device");

Expand Down
5 changes: 0 additions & 5 deletions tests/utils/test_translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,12 @@ RED_AUTO_TEST_CASE(TestTranslation)
RED_CHECK_EQUAL(TR(trkeys::diagnostic, lang), "Diagnostic");
RED_CHECK_EQUAL(TR(trkeys::connection_closed, lang), "Connection closed");
RED_CHECK_EQUAL(TR(trkeys::OK, lang), "OK");
RED_CHECK_EQUAL(TR(trkeys::cancel, lang), "Cancel");
RED_CHECK_EQUAL(TR(trkeys::help, lang), "Help");
RED_CHECK_EQUAL(TR(trkeys::close, lang), "Close");
RED_CHECK_EQUAL(TR(trkeys::refused, lang), "Refused");
RED_CHECK_EQUAL(TR(trkeys::username, lang), "Username");
RED_CHECK_EQUAL(TR(trkeys::password_expire, lang), "Your Bastion password will expire soon. Please change it.");
RED_CHECK_EQUAL(TR(trkeys::protocol, lang), "Protocol");
RED_CHECK_EQUAL(TR(trkeys::target, lang), "Target");
RED_CHECK_EQUAL(TR(trkeys::close_time, lang), "Close Time");
RED_CHECK_EQUAL(TR(trkeys::logout, lang), "Logout");
RED_CHECK_EQUAL(TR(trkeys::apply, lang), "Apply");
RED_CHECK_EQUAL(TR(trkeys::connect, lang), "Connect");
RED_CHECK_EQUAL(TR(trkeys::timeleft, lang), "Time left");
RED_CHECK_EQUAL(TR(trkeys::second, lang), "second");
Expand Down
38 changes: 38 additions & 0 deletions tools/c++-analyzer/lua-checker/checkers/trkeys.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
local utils = require'utils'

local pattern_trkey
do
local peg = utils.peg
local C = peg.C
local P = peg.P
local Ct = peg.Ct
local After = peg.After

pattern_trkey_def = Ct(After(
P' TR_KV' * P'_FMT'^-1 * '(' * C(peg.word)
)^0)

pattern_trkey = Ct(After(
P'trkeys::' * C(peg.word)
)^0)
end

local trkeys_path = 'src/utils/trkeys.hpp'

local match_and_setk = utils.match_and_setk

local keys

function init(args)
keys = match_and_setk(pattern_trkey_def, utils.readall(trkeys_path), false)
end

function file(content)
match_and_setk(pattern_trkey, content, true, keys)
end

function terminate()
return utils.count_error(keys, "trkeys::%s not used")
end

return {init=init, file=file, terminate=terminate}
1 change: 1 addition & 0 deletions tools/c++-analyzer/lua-checker/lua-checker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ local list_checkers = {
error = true,
vcfg = true,
printf = true,
trkeys = true,
}

local utils = require'utils'
Expand Down
Loading

0 comments on commit 1e0a0fb

Please sign in to comment.