Skip to content

Commit

Permalink
Change the default level of the DivisionByZero lint to "error" (#1445)
Browse files Browse the repository at this point in the history
It is confusing that a division by zero causes a runtime error, but its
default lint level is "warning." So, this PR changes the default level
of DivisionByZero to "error."
  • Loading branch information
orpuente-MS authored May 1, 2024
1 parent 505e27a commit ce5bcf9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion compiler/qsc_linter/src/lints/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use qsc_ast::ast::{BinOp, ExprKind, Lit, StmtKind};
use qsc_data_structures::span::Span;

declare_ast_lints! {
(DivisionByZero, LintLevel::Warn, "attempt to divide by zero", "division by zero is not allowed"),
(DivisionByZero, LintLevel::Error, "attempt to divide by zero", "division by zero will fail at runtime"),
(NeedlessParens, LintLevel::Allow, "unnecessary parentheses", "remove the extra parentheses for clarity"),
(RedundantSemicolons, LintLevel::Warn, "redundant semicolons", "remove the redundant semicolons"),
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/qsc_linter/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ fn multiple_lints() {
},
SrcLint {
source: "((1 + 2)) / 0",
level: Warn,
level: Error,
message: "attempt to divide by zero",
help: "division by zero is not allowed",
help: "division by zero will fail at runtime",
},
SrcLint {
source: "((1 + 2))",
Expand Down Expand Up @@ -64,9 +64,9 @@ fn division_by_zero() {
[
SrcLint {
source: "2 / 0",
level: Warn,
level: Error,
message: "attempt to divide by zero",
help: "division by zero is not allowed",
help: "division by zero will fail at runtime",
},
]
"#]],
Expand Down
8 changes: 4 additions & 4 deletions language_service/src/state/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,9 @@ fn notebook_document_lints() {
lo: 74,
hi: 79,
},
level: Warn,
level: Error,
message: "attempt to divide by zero",
help: "division by zero is not allowed",
help: "division by zero will fail at runtime",
},
),
],
Expand Down Expand Up @@ -1474,7 +1474,7 @@ async fn lints_update_after_manifest_change() {
},
level: Error,
message: "attempt to divide by zero",
help: "division by zero is not allowed",
help: "division by zero will fail at runtime",
},
),
]"#]],
Expand Down Expand Up @@ -1516,7 +1516,7 @@ async fn lints_update_after_manifest_change() {
},
level: Warn,
message: "attempt to divide by zero",
help: "division by zero is not allowed",
help: "division by zero will fail at runtime",
},
),
]"#]],
Expand Down

0 comments on commit ce5bcf9

Please sign in to comment.