-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor linting CLI to use direct paths and improve output fo…
…rmatting
- Loading branch information
1 parent
2dd32d9
commit 6094408
Showing
10 changed files
with
99 additions
and
74 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
== [<string input>] FAIL | ||
== [tests/ui/LT01_LT012.sql] FAIL | ||
L: 1 | P: 7 | LT01 | Expected only single space before "1". Found " ". [layout.spacing] | ||
L: 1 | P: 11 | LT12 | Files must end with a single trailing newline. [layout.end_of_file] | ||
|
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,7 +1,6 @@ | ||
== [<string input>] FAIL | ||
== [tests/ui/test_fail_whitespace_before_comma.sql] FAIL | ||
L: 1 | P: 1 | LT09 | Select targets should be on a new line unless there is only one select target. | ||
| [layout.select_targets] | ||
L: 1 | P: 9 | LT01 | Unexpected whitespace before ",". [layout.spacing] | ||
L: 1 | P: 11 | LT01 | Expected single whitespace between "," and "4". [layout.spacing] | ||
L: 1 | P: 11 | LT12 | Files must end with a single trailing newline. [layout.end_of_file] | ||
|
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ pub mod linted_dir; | |
pub mod linted_file; | ||
pub mod linter; | ||
pub mod linting_result; | ||
mod runner; |
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,33 @@ | ||
use super::linter::Linter; | ||
|
||
pub trait Runner: Sized { | ||
fn run(&mut self, paths: Vec<String>, linter: &mut Linter); | ||
} | ||
|
||
pub struct RunnerContext<'me, R> { | ||
linter: &'me mut Linter, | ||
runner: R, | ||
} | ||
|
||
impl<'me> RunnerContext<'me, SequentialRunner> { | ||
pub fn sequential(linter: &'me mut Linter) -> Self { | ||
Self { linter, runner: SequentialRunner } | ||
} | ||
} | ||
|
||
impl<R: Runner> RunnerContext<'_, R> { | ||
pub fn run(&mut self, paths: Vec<String>) { | ||
self.runner.run(paths, &mut self.linter); | ||
} | ||
} | ||
|
||
pub struct SequentialRunner; | ||
|
||
impl Runner for SequentialRunner { | ||
fn run(&mut self, paths: Vec<String>, linter: &mut Linter) { | ||
for path in paths { | ||
let rendered = linter.render_file(path); | ||
linter.lint_rendered(rendered); | ||
} | ||
} | ||
} |