Skip to content

Commit

Permalink
Update (and pin) full-moon version, which supports Typed Lua
Browse files Browse the repository at this point in the history
  • Loading branch information
Kampfkarren committed Jan 19, 2020
1 parent b50991d commit 1b81a70
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 32 deletions.
70 changes: 55 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions selene-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "selene-lib"
version = "0.5.0"
version = "0.5.1"
license = "MPL-2.0"
authors = ["Kampfkarren <[email protected]>"]
description = "A library for linting Lua code. You probably want selene instead."
Expand All @@ -12,7 +12,7 @@ edition = "2018"
[dependencies]
codespan = "0.4"
codespan-reporting = "0.4"
full_moon = "0.4.0-rc.12"
full_moon = "=0.4.0-rc.13"
id-arena = "2.2"
if_chain = "1.0"
lazy_static = "1.4"
Expand Down
2 changes: 1 addition & 1 deletion selene-lib/src/ast_util/scopes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl ScopeVisitor {
self.read_expression(expression);
}

ast::Expression::Value { value, binop } => {
ast::Expression::Value { value, binop, .. } => {
if let Some(binop) = binop {
self.read_expression(binop.rhs());
}
Expand Down
2 changes: 1 addition & 1 deletion selene-lib/src/rules/divide_by_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn value_is_zero(value: &ast::Value) -> bool {
impl Visitor<'_> for DivideByZeroVisitor {
fn visit_expression(&mut self, node: &ast::Expression) {
if_chain::if_chain! {
if let ast::Expression::Value { value, binop } = node;
if let ast::Expression::Value { value, binop, .. } = node;
if let Some(rhs) = binop;
if let ast::BinOp::Slash(_) = rhs.bin_op();
if let ast::Expression::Value {
Expand Down
2 changes: 1 addition & 1 deletion selene-lib/src/rules/parenthese_conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl ParentheseConditionsVisitor {
fn lint_condition(&mut self, condition: &ast::Expression) {
let is_parentheses = match condition {
ast::Expression::Parentheses { .. } => true,
ast::Expression::Value { value, binop } => {
ast::Expression::Value { value, binop, .. } => {
if let ast::Value::ParseExpression(_) = &**value {
binop.is_none()
} else {
Expand Down
2 changes: 1 addition & 1 deletion selene-lib/src/rules/roblox_incorrect_color3_new_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Visitor<'_> for Color3BoundsVisitor {
for argument in arguments {
// Check if the argument is a constant number
if_chain::if_chain! {
if let ast::Expression::Value { value, binop } = argument;
if let ast::Expression::Value { value, binop, .. } = argument;
if binop.is_none();
if let ast::Value::Number(value) = &**value;
if let Ok(number) = value.to_string().parse::<f32>();
Expand Down
6 changes: 3 additions & 3 deletions selene-lib/src/rules/roblox_incorrect_roact_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ impl Visitor<'_> for IncorrectRoactUsageVisitor {

// Get first argument, check if it is a Roblox class
let name_arg = iter.next().unwrap();
if let ast::Expression::Value { value, binop } = name_arg;
if let ast::Expression::Value { value, binop, .. } = name_arg;
if binop.is_none();
if let ast::Value::String(token) = &**value;
if let Some(class) = self.check_class_name(&token);

// Get second argument, check if it is a table
let arg = iter.next().unwrap();
if let ast::Expression::Value { value, binop } = arg;
if let ast::Expression::Value { value, binop, .. } = arg;
if binop.is_none();
if let ast::Value::TableConstructor(table) = &**value;

Expand Down Expand Up @@ -210,7 +210,7 @@ impl Visitor<'_> for IncorrectRoactUsageVisitor {
fn visit_local_assignment(&mut self, node: &ast::LocalAssignment) {
for (name, expr) in node.name_list().iter().zip(node.expr_list().iter()) {
if_chain! {
if let ast::Expression::Value { value, binop } = expr;
if let ast::Expression::Value { value, binop, .. } = expr;
if binop.is_none();
if let ast::Value::Var(var) = &**value;
if let ast::Var::Expression(var_expr) = var;
Expand Down
4 changes: 3 additions & 1 deletion selene-lib/src/rules/standard_library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ fn get_argument_type(expression: &ast::Expression) -> Option<PassedArgumentType>
}
}

ast::Expression::Value { binop: rhs, value } => {
ast::Expression::Value {
binop: rhs, value, ..
} => {
let base = match &**value {
ast::Value::Function(_) => Some(ArgumentType::Function.into()),
ast::Value::FunctionCall(_) => None,
Expand Down
2 changes: 1 addition & 1 deletion selene-lib/src/rules/suspicious_reverse_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl Visitor<'_> for SuspiciousReverseLoopVisitor {
if node.step().is_none();
if let ast::Expression::UnaryOperator { unop, .. } = node.start();
if let ast::UnOp::Hash(_) = unop;
if let ast::Expression::Value { value, binop } = node.end();
if let ast::Expression::Value { value, binop, .. } = node.end();
if binop.is_none();
if let ast::Value::Number(number) = &**value;
if str::parse::<f32>(&number.to_string()).unwrap() <= 1.0;
Expand Down
2 changes: 1 addition & 1 deletion selene-lib/src/rules/type_check_inside_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Visitor<'_> for TypeCheckInsideCallVisitor {
if let ast::BinOp::TwoEqual(_) = rhs.bin_op();

// Check that rhs is a constant string
if let ast::Expression::Value { binop: rhs, value } = rhs.rhs();
if let ast::Expression::Value { binop: rhs, value, .. } = rhs.rhs();
if rhs.is_none();
if let ast::Value::String(_) = &**value;

Expand Down
4 changes: 2 additions & 2 deletions selene-lib/src/rules/unbalanced_assignments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct UnbalancedAssignmentsVisitor {
fn expression_is_call(expression: &ast::Expression) -> bool {
match expression {
ast::Expression::Parentheses { expression, .. } => expression_is_call(expression),
ast::Expression::Value { value, binop } => {
ast::Expression::Value { value, binop, .. } => {
if binop.is_none() {
if let ast::Value::FunctionCall(_) = &**value {
true
Expand All @@ -94,7 +94,7 @@ fn expression_is_call(expression: &ast::Expression) -> bool {
fn expression_is_nil(expression: &ast::Expression) -> bool {
match expression {
ast::Expression::Parentheses { expression, .. } => expression_is_call(expression),
ast::Expression::Value { value, binop } => {
ast::Expression::Value { value, binop, .. } => {
if binop.is_none() {
if let ast::Value::Symbol(symbol) = &**value {
*symbol.token_type()
Expand Down
Loading

0 comments on commit 1b81a70

Please sign in to comment.