Skip to content

Commit

Permalink
Update mixed_table warning message (#586)
Browse files Browse the repository at this point in the history
Closes: #572 

It makes the error message for mixed tables more descriptive and
explains why they're bad and should be _avoided_.

---------

Co-authored-by: boyned//Kampfkarren <boynedmaster@gmail.com>
Co-authored-by: Chris Chang <51393127+chriscerie@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 24, 2024
1 parent 231ad62 commit e73cccc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Added
- Added `CFrame.lookAlong` to the Roblox standard library

### Changed
- Updated the warning message for the `mixed_table` lint to include why mixed tables should be avoided

## [0.26.1](https://github.com/Kampfkarren/selene/releases/tag/0.26.1) - 2023-11-11
### Fixed
- Fixed `UDim2.new()` firing the [`roblox_suspicious_udim2_new` lint](https://kampfkarren.github.io/selene/lints/roblox_suspicious_udim2_new.html).
Expand Down
2 changes: 1 addition & 1 deletion selene-lib/src/lints/mixed_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Lint for MixedTableLint {
for mixed_table in visitor.mixed_tables {
diagnostics.push(Diagnostic::new_complete(
"mixed_table",
"mixed tables are not allowed".to_owned(),
"mixed tables should be avoided, as they can cause confusing and hard to debug issues such as during iteration or encoding".to_owned(),
Label::new(mixed_table.range),
vec!["help: change this table to either an array or dictionary".to_owned()],
Vec::new(),
Expand Down
2 changes: 1 addition & 1 deletion selene-lib/src/lints/roblox_incorrect_roact_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use if_chain::if_chain;
pub struct IncorrectRoactUsageLint;

// Assumes string includes quotes at start and end
fn is_lua_valid_table_key_identifier(string: &String) -> bool {
fn is_lua_valid_table_key_identifier(string: &str) -> bool {
// Valid identifier cannot start with numbers
let first_char = string.chars().nth(1).unwrap();
if !first_char.is_alphabetic() && first_char != '_' {
Expand Down
12 changes: 6 additions & 6 deletions selene-lib/tests/lints/mixed_table/mixed_table.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[mixed_table]: mixed tables are not allowed
error[mixed_table]: mixed tables should be avoided, as they can cause confusing and hard to debug issues such as during iteration or encoding
┌─ mixed_table.lua:2:5
2 │ ╭ "",
Expand All @@ -7,7 +7,7 @@ error[mixed_table]: mixed tables are not allowed
= help: change this table to either an array or dictionary

error[mixed_table]: mixed tables are not allowed
error[mixed_table]: mixed tables should be avoided, as they can cause confusing and hard to debug issues such as during iteration or encoding
┌─ mixed_table.lua:7:5
7 │ ╭ {},
Expand All @@ -16,7 +16,7 @@ error[mixed_table]: mixed tables are not allowed
= help: change this table to either an array or dictionary

error[mixed_table]: mixed tables are not allowed
error[mixed_table]: mixed tables should be avoided, as they can cause confusing and hard to debug issues such as during iteration or encoding
┌─ mixed_table.lua:12:5
12 │ ╭ a,
Expand All @@ -25,7 +25,7 @@ error[mixed_table]: mixed tables are not allowed
= help: change this table to either an array or dictionary

error[mixed_table]: mixed tables are not allowed
error[mixed_table]: mixed tables should be avoided, as they can cause confusing and hard to debug issues such as during iteration or encoding
┌─ mixed_table.lua:19:5
19 │ ╭ 1,
Expand All @@ -34,7 +34,7 @@ error[mixed_table]: mixed tables are not allowed
= help: change this table to either an array or dictionary

error[mixed_table]: mixed tables are not allowed
error[mixed_table]: mixed tables should be avoided, as they can cause confusing and hard to debug issues such as during iteration or encoding
┌─ mixed_table.lua:25:5
25 │ ╭ [c] = d,
Expand All @@ -43,7 +43,7 @@ error[mixed_table]: mixed tables are not allowed
= help: change this table to either an array or dictionary

error[mixed_table]: mixed tables are not allowed
error[mixed_table]: mixed tables should be avoided, as they can cause confusing and hard to debug issues such as during iteration or encoding
┌─ mixed_table.lua:30:5
30 │ ╭ a = b,
Expand Down

0 comments on commit e73cccc

Please sign in to comment.