Skip to content

Commit

Permalink
Add deprecated fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscerie committed Oct 14, 2023
1 parent 1c519dc commit 47afa03
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion selene-lib/src/lints/deprecated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,11 @@ impl<'a> DeprecatedVisitor<'a> {

let mut notes = vec![deprecated.message.to_owned()];

let mut fixed_code = None;

if let Some(replace_with) = deprecated.try_instead(parameters) {
notes.push(format!("try: {replace_with}"));
fixed_code = Some(replace_with);
}

self.diagnostics.push(Diagnostic::new_complete(
Expand All @@ -128,7 +131,7 @@ impl<'a> DeprecatedVisitor<'a> {
Label::from_node(node, None),
notes,
Vec::new(),
None,
fixed_code,
));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
local _ = this.is_deprecated
local _ = all_of_this.is_deprecated
local _ = all_of_this.even.deeper.is_deprecated
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
table.foreach({}, function(k, v) end)
-print(table.getn(x))
+print(#x)

table.foreach({}, 3)
7 changes: 7 additions & 0 deletions selene-lib/tests/lints/deprecated/specific_allow.fixed.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
deprecated_allowed()
deprecated_blocked()

more.deprecated_allowed()
wow.extra.deprecated_allowed()

deprecated_allowed.more()
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Tests that the old TOML format is unchanged
print(this_is.deprecated)

0 comments on commit 47afa03

Please sign in to comment.