mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Rust: remove clippy warnings
This commit is contained in:
6
.github/workflows/rust.yml
vendored
6
.github/workflows/rust.yml
vendored
@@ -45,8 +45,7 @@ jobs:
|
||||
- name: Clippy
|
||||
shell: bash
|
||||
run: |
|
||||
cargo clippy --fix
|
||||
git diff --exit-code
|
||||
cargo clippy -- -D warnings
|
||||
rust-code:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
@@ -65,8 +64,7 @@ jobs:
|
||||
- name: Clippy
|
||||
shell: bash
|
||||
run: |
|
||||
cargo clippy --fix
|
||||
git diff --exit-code
|
||||
cargo clippy -- -D warnings
|
||||
rust-codegen:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
@@ -75,7 +75,7 @@ write_file(
|
||||
'DST_DIR="$(dirname "$(rlocation "$1")")"',
|
||||
'mkdir -p "$DST_DIR/src/codegen/grammar"',
|
||||
] + [
|
||||
'cp "$(rlocation "$%s")" "$DST_DIR/%s"' % item
|
||||
'cp -f --no-preserve=mode "$(rlocation "$%s")" "$DST_DIR/%s"' % item
|
||||
for item in enumerate(_codegen_outs, 2)
|
||||
],
|
||||
is_executable = True,
|
||||
|
||||
@@ -9,8 +9,7 @@ use std::env;
|
||||
use ungrammar::Grammar;
|
||||
|
||||
fn project_root() -> PathBuf {
|
||||
let dir =
|
||||
env::var("CARGO_MANIFEST_DIR").unwrap().to_owned();
|
||||
let dir = env::var("CARGO_MANIFEST_DIR").unwrap().to_owned();
|
||||
PathBuf::from(dir).parent().unwrap().to_owned()
|
||||
}
|
||||
|
||||
@@ -593,7 +592,7 @@ impl Translator<'_> {{
|
||||
fn main() -> std::io::Result<()> {
|
||||
let grammar = PathBuf::from("..").join(env::args().nth(1).expect("grammar file path required"));
|
||||
let grammar: Grammar = fs::read_to_string(&grammar)
|
||||
.expect(&format!("Failed to parse grammar file: {}", grammar.display()))
|
||||
.unwrap_or_else(|_| panic!("Failed to parse grammar file: {}", grammar.display()))
|
||||
.parse()
|
||||
.expect("Failed to parse grammar");
|
||||
let mut grammar = codegen::grammar::lower(&grammar);
|
||||
|
||||
10
rust/lint.py
10
rust/lint.py
@@ -10,9 +10,11 @@ this_dir = pathlib.Path(__file__).resolve().parent
|
||||
cargo = shutil.which("cargo")
|
||||
assert cargo, "no cargo binary found on `PATH`"
|
||||
|
||||
fmt = subprocess.run([cargo, "fmt", "--all", "--quiet"], cwd=this_dir)
|
||||
runs = []
|
||||
runs.append(subprocess.run([cargo, "fmt", "--all", "--quiet"], cwd=this_dir))
|
||||
|
||||
for manifest in this_dir.rglob("Cargo.toml"):
|
||||
if not manifest.is_relative_to(this_dir / "ql") and not manifest.is_relative_to(this_dir / "integration-tests"):
|
||||
clippy = subprocess.run([cargo, "clippy", "--fix", "--allow-dirty", "--allow-staged", "--quiet"],
|
||||
cwd=manifest.parent)
|
||||
sys.exit(fmt.returncode or clippy.returncode)
|
||||
runs.append(subprocess.run([cargo, "clippy", "--fix", "--allow-dirty", "--allow-staged", "--quiet", "--", "-D", "warnings"],
|
||||
cwd=manifest.parent))
|
||||
sys.exit(max(r.returncode for r in runs))
|
||||
|
||||
Reference in New Issue
Block a user