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

Add rule to remove unused variable #172

Merged
merged 12 commits into from
Feb 23, 2024
Merged

Conversation

jeparlefrancais
Copy link
Contributor

@jeparlefrancais jeparlefrancais commented Jan 2, 2024

Closes #26

Add a new remove_unused_variable rule 🚀

  • add entry to the changelog
  • add rule documentation

@jeparlefrancais jeparlefrancais changed the title Remove unused identifiers Add rule to remove unused variable Jan 2, 2024
"local a, b, c = ... return b"
) => "local a, b = ... return b",
remove_variable_before_tuple_extract(
"local a, b, c = true, ... return b"

Choose a reason for hiding this comment

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

is this correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to think about it for a moment again but yes 😄Equivalent to:

local a = true
local b, c = ...
return b

So you can get rid of a and c

Copy link

Coverage after merging remove-unused-identifiers into main will be

86.88%

Coverage Report for Changed Files
FileStmtsBranchesFuncsLinesUncovered Lines
src/nodes
   block.rs95.86%100%97.75%95.50%16, 19, 214–216, 25, 251–256, 26, 28, 31, 40, 49–50, 52, 55
src/nodes/statements
   function.rs92.36%100%88.73%93.13%128–130, 183–184, 186, 38, 388–389, 39, 390, 41, 410, 423, 446–447, 449
src/process
   scope_visitor.rs81.47%100%82.50%81.30%107–109, 112, 116, 140–142, 145, 149, 176–178, 190, 194, 242–252, 257, 281–283, 315–317, 63–65, 78–80, 83, 87
   visitors.rs99.08%100%100%98.99%92–97
src/process/processors
   find_identifier.rs96.30%100%100%95.45%68
   find_usage.rs100%100%100%100%
src/rules
   group_local.rs89.29%100%78.95%91.40%38–40, 44
   inject_value.rs86.54%100%89.47%86.04%14, 150, 163, 165–177, 180–181, 187, 223–226, 229, 232, 74, 78–79, 87
   mod.rs89.25%100%77.78%90.70%112–114, 118, 128–130, 148–150, 152, 183–185, 278, 319–320, 355–357, 420–422, 73
   no_local_function.rs95.24%100%86.67%97.10%
   remove_call_match.rs52.22%100%70%50%11, 125–130, 132, 134, 33–35, 56–57, 59–65, 67–76, 78–81, 86, 88, 96–98
   remove_unused_variable.rs94.86%100%92.59%95.19%119, 142–145, 147–148
src/rules/rename_variables
   rename_processor.rs98.86%100%97.92%99.07%10, 95
src/utils
   expressions_as_statement.rs24.14%100%25%24.07%14–26, 34, 40–51, 53–62, 64
   mod.rs97.18%100%97.56%97.06%56–57, 64

@jeparlefrancais jeparlefrancais merged commit 2ce89d9 into main Feb 23, 2024
6 checks passed
@jeparlefrancais jeparlefrancais deleted the remove-unused-identifiers branch February 23, 2024 23:52
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.

Remove unused variables
2 participants