seaofvoices / darklua

A command line tool that transforms Lua code
https://darklua.com/
MIT License
71 stars 9 forks source link

Fix `remove_unused_variable` rule #192

Closed jeparlefrancais closed 3 months ago

jeparlefrancais commented 3 months ago

Closes #182 Closes #186 Closes #187

These changes fixes the remove_unused_variable rule by removing the variables in the right order and fixing the scoping issue with repeat statements.

github-actions[bot] commented 3 months ago

Coverage after merging fix-remove-unused-variable into main will be

86.98%

Coverage Report for Changed Files
FileStmtsBranchesFuncsLinesUncovered Lines
src/nodes/expressions
   type_cast.rs84.62%100%81.82%85.37%23–25, 35–37
src/nodes/statements
   repeat_statement.rs100%100%100%100%
src/process
   node_processor.rs97.92%100%97.92%97.92%43
   scope_visitor.rs86.01%100%91.89%85.16%109–111, 114, 118, 144–146, 149, 153, 182–184, 198, 202, 255–265, 270, 63–65, 78–80, 83, 87
   visitors.rs99.08%100%100%99%92–97
src/process/processors
   find_usage.rs100%100%100%100%
src/rules
   remove_unused_variable.rs96.88%100%100%96.53%138, 161–164, 166–167
src/utils
   expressions_as_statement.rs34.33%100%40%33.87%24–36, 44, 51–62, 64–73, 75