-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use cairo_lang_defs::plugin::PluginDiagnostic; | ||
use cairo_lang_diagnostics::Severity; | ||
use cairo_lang_syntax::node::db::SyntaxGroup; | ||
use cairo_lang_syntax::node::SyntaxNode; | ||
|
||
pub const BREAK_UNIT: &str = "unnecessary double parentheses found after break. Consider removing them."; | ||
|
||
pub fn check_break(db: &dyn SyntaxGroup, node: SyntaxNode, diagnostics: &mut Vec<PluginDiagnostic>) { | ||
if node.clone().get_text_without_trivia(db).ends_with("();") { | ||
diagnostics.push(PluginDiagnostic { | ||
stable_ptr: node.stable_ptr(), | ||
message: BREAK_UNIT.to_string(), | ||
severity: Severity::Warning, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod breaks; | ||
pub mod double_parens; | ||
pub mod single_match; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//! > Simple break | ||
|
||
//! > cairo_code | ||
fn main() { | ||
loop { | ||
break (); | ||
} | ||
} | ||
|
||
//! > diagnostics | ||
warning: Plugin diagnostic: unnecessary double parentheses found after break. Consider removing them. | ||
--> lib.cairo:3:9 | ||
break (); | ||
^*******^ | ||
|
||
//! > fixed | ||
fn main() { | ||
loop { | ||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters