Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lints: Check if stringtable entries exist and rework lints (L02) #876

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

PabstMirror
Copy link
Collaborator

pass buildInfo as the project is being built
currently just stores seen string-table entries but I have other ideas for this as well
unfortunately requires changing function signatures for all lints

warning[L-C12]: invalid project stringtable entry for config
   ┌─ addons/explosives/TimerDialog.hpp:80:20
   │
80 │             text = CSTRING(Cancel);
   │                    ^^^^^^^^^^^^^^^
   │
   = help: [STR_ace_explosives_Cancel] not in project's stringtables

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 58.30346% with 349 lines in your changes missing coverage. Please review.

Project coverage is 59.4%. Comparing base (9a6c3de) to head (d9e318c).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ibs/stringtable/src/analyze/lints/l02_usage/mod.rs 51.1% 102 Missing ⚠️
libs/sqf/src/analyze/lints/s28_banned_macros.rs 72.7% 30 Missing ⚠️
...src/analyze/lints/l02_usage/code_duplicate_file.rs 0.0% 29 Missing ⚠️
...e/src/analyze/lints/l02_usage/code_missing_file.rs 0.0% 29 Missing ⚠️
libs/sqf/src/analyze/lints/collect_stringtables.rs 57.1% 18 Missing ⚠️
bin/src/modules/rapifier.rs 0.0% 16 Missing ⚠️
bin/src/modules/stringtables.rs 0.0% 14 Missing ⚠️
...s/config/src/analyze/lints/collect_stringtables.rs 75.8% 14 Missing ⚠️
bin/src/modules/sqf.rs 0.0% 12 Missing ⚠️
libs/workspace/src/lint/mod.rs 66.6% 10 Missing ⚠️
... and 20 more
Additional details and impacted files
Files with missing lines Coverage Δ
libs/config/src/analyze/mod.rs 99.2% <100.0%> (-0.1%) ⬇️
libs/sqf/src/analyze/lints/s02_event_handlers.rs 39.1% <100.0%> (-0.2%) ⬇️
libs/sqf/src/analyze/lints/s04_command_case.rs 65.7% <100.0%> (ø)
libs/sqf/src/analyze/lints/s09_banned_command.rs 61.7% <100.0%> (-0.9%) ⬇️
...le/src/analyze/lints/l02_usage/code_unused_file.rs 100.0% <100.0%> (ø)
libs/stringtable/src/analyze/mod.rs 90.0% <100.0%> (+0.7%) ⬆️
bin/src/commands/localization/coverage.rs 0.0% <0.0%> (ø)
bin/src/commands/localization/sort.rs 0.0% <0.0%> (ø)
...s/sqf/src/analyze/lints/s07_select_parse_number.rs 66.8% <66.6%> (-0.2%) ⬇️
libs/stringtable/src/analyze/lints/l01_sorted.rs 78.0% <80.0%> (ø)
... and 26 more

... and 50 files with indirect coverage changes

@PabstMirror PabstMirror changed the title lints: Check if stringtable entries exist and rework lints lints: Check if stringtable entries exist and rework lints (S27,S28,C12) Jan 23, 2025
@PabstMirror PabstMirror marked this pull request as ready for review January 24, 2025 05:47
@BrettMayson
Copy link
Owner

Due to #880, we need a different solution for is_pedantic, not sure what the best approach is yet, I'd prefer not passing more info around to the lints, and perhaps filtering out the pedantic lints either before / after they run, rather than within the lint and returning an empty vec

@PabstMirror
Copy link
Collaborator Author

  • ace false positives
str_ace_repair_hit - addons/repair/functions/fnc_getHitPointString.sqf:29:16
str_ace_repair_hit - addons/repair/functions/fnc_getHitPointString.sqf:80:13
str_assign_%1 - addons/interaction/functions/fnc_addSquadChildren.sqf:38:37
str_team_%1 - addons/interaction/functions/fnc_joinTeam.sqf:26:37

};
let cstring_value = cstring_data.value();

if cstring_value.to_lowercase().starts_with("str_") || cstring_value.to_lowercase().starts_with("$str_") {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more self notes

x1 = "str_ace_common_cancel";  // "str_ace_common_cancel"
x2 = "$str_ace_common_cancel"; // "$str_ace_common_cancel"
x3 = "$STR_ace_common_cancel"; // "Cancel"
x4 = "$STR_ace_coMMon_cancel"; // "Cancel"

localize "str_aCe_common_canCel" // "Cancel"
localize "$str_aCe_common_canCel" // "Cancel"

config needs cased "$STR" to start but then doesn't care about case
sqf doesn't care about case or if starting with a $
this might be newish - otherwise I don't know why we have CSTRING and LSTRING macros?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the wiki $ in localize was introduced in 2.04

@PabstMirror PabstMirror changed the title lints: Check if stringtable entries exist and rework lints (S27,S28,C12) lints: Check if stringtable entries exist and rework lints (L02) Jan 31, 2025
@PabstMirror
Copy link
Collaborator Author

Ace repair hit still is a false positive - ref https://github.com/acemod/ACE3/blob/master/addons/repair/functions/fnc_getHitPointString.sqf#L29

but I've added config options so it can be ignored

[stringtables.usage]
options.ignore = ["str_ace_repair_hit"]
options.ignore_unused = true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants