Skip to content

Commit

Permalink
Modification de la CI (#8)
Browse files Browse the repository at this point in the history
* Fixed clippy::all and clippy::pedantic from v1.58.0 to v1.64.0

* Fixed CI for clippy

- Continuous integration was just warning about clippy defaults. We now deny them
- Applied a fix version of Rust by using an unmodified Github runner
  • Loading branch information
PierreGagelin committed Nov 1, 2022
1 parent 1e78606 commit 76499b7
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 22 deletions.
18 changes: 8 additions & 10 deletions .github/workflows/main.yml
Expand Up @@ -6,38 +6,36 @@ defaults:
shell: bash

jobs:
# Check Code style quickly by running `rustfmt` over all code

# Check coding style
rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: rustup update nightly && rustup default nightly
- run: rustup +nightly component add rustfmt
- uses: actions/checkout@v3
- run: |
for manifest in `find . ! -path '*/day*' -name Cargo.toml`
do
echo check fmt for $manifest
cargo fmt --all --manifest-path $manifest -- --check
done
# Check static analysis defaults
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: rustup update nightly && rustup default nightly
- run: rustup component add clippy
- uses: actions/checkout@v3
- run: |
for manifest in `find . ! -path '*/day*' -name Cargo.toml`
do
echo check clippy for $manifest
cargo clippy --manifest-path $manifest
cargo clippy --manifest-path $manifest -- -D clippy::all -D clippy::pedantic
done
# Check non-regression tests
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: rustup update stable && rustup default stable
- uses: actions/checkout@v3
- run: |
for manifest in `find . ! -path '*/day*' -name Cargo.toml`
do
Expand Down
2 changes: 1 addition & 1 deletion 2015/day7/day7.rs
Expand Up @@ -42,7 +42,7 @@ fn run(
reg: &str,
level: u32,
) -> u16 {
assert!(!(level > 70), "too deep");
assert!(level <= 70, "too deep");

if cache.contains_key(reg) {
return cache[reg];
Expand Down
6 changes: 3 additions & 3 deletions 2021/day13/day13.rs
Expand Up @@ -27,7 +27,7 @@ fn main() {
if line.is_empty() {
break;
}
let (x, y) = line.split_once(",").unwrap();
let (x, y) = line.split_once(',').unwrap();
let xx = x.parse::<usize>().unwrap();
let yy = y.parse::<usize>().unwrap();
grid[yy][xx] = 1;
Expand All @@ -39,7 +39,7 @@ fn main() {
}

if line.starts_with("fold along x=") {
let (_, s) = line.split_once("=").unwrap();
let (_, s) = line.split_once('=').unwrap();
let fold = s.parse::<usize>().unwrap();
for line in &mut grid {
for x in 0..fold {
Expand All @@ -52,7 +52,7 @@ fn main() {
line.resize(fold, 0);
}
} else if line.starts_with("fold along y=") {
let (_, s) = line.split_once("=").unwrap();
let (_, s) = line.split_once('=').unwrap();
let fold = s.parse::<usize>().unwrap();
for y in 0..fold {
for x in 0..grid[0].len() {
Expand Down
2 changes: 1 addition & 1 deletion 2021/day17/day17.rs
Expand Up @@ -23,7 +23,7 @@ fn main() {
ord_max = args[4].parse::<i32>().unwrap();
}
2 => {
let data = fs::read_to_string(args[1].to_string()).unwrap();
let data = fs::read_to_string(&args[1]).unwrap();
scan!(data.bytes() => "target area: x={}..{}, y={}..{}",
abs_min, abs_max, ord_min, ord_max);
}
Expand Down
2 changes: 1 addition & 1 deletion 2021/day19/day19.rs
Expand Up @@ -143,7 +143,7 @@ fn solve(scanners: &[Vec<Point>]) {
}
}

assert!(!(found == usize::MAX), "no beacon found");
assert!(found != usize::MAX, "no beacon found");

pending.remove(&found);
}
Expand Down
2 changes: 1 addition & 1 deletion 2021/day20/day20.rs
Expand Up @@ -34,7 +34,7 @@ fn main() {
})
.collect::<Vec<u8>>();

assert!(!(decoder.len() != 512), "invalid decoder length");
assert!(decoder.len() == 512, "invalid decoder length");

let mut grid: Grid = vec![vec![PIXEL_UNKNOWN; 1000]; 1000];

Expand Down
6 changes: 3 additions & 3 deletions 2021/day24/day24.rs
Expand Up @@ -133,7 +133,7 @@ fn run_program(program: &[Instruction], input: &[i64], z: i64, verbose: bool) ->
for instruction in program {
let src = match instruction.src {
Register::Input => {
assert!(!(input_ptr >= input.len()), "not enough input");
assert!(input_ptr < input.len(), "not enough input");
input_ptr += 1;
input[input_ptr - 1]
}
Expand All @@ -151,11 +151,11 @@ fn run_program(program: &[Instruction], input: &[i64], z: i64, verbose: bool) ->
OpCode::Add => dest_value + src,
OpCode::Mul => dest_value * src,
OpCode::Div => {
assert!(!(src <= 0), "Division by zero!");
assert!(src != 0, "Division by zero!");
dest_value / src
}
OpCode::Mod => {
assert!(!(src <= 0), "Division by zero!");
assert!(src != 0, "Division by zero!");
dest_value % src
}
OpCode::Eql => {
Expand Down
4 changes: 2 additions & 2 deletions 2021/day8/day8.rs
Expand Up @@ -40,8 +40,8 @@ fn part2(data: &[String]) {
for line in data {
let (notes1, code1) = line.split_once('|').unwrap();

let notes = notes1.trim().split_whitespace().collect::<Vec<&str>>();
let code = code1.trim().split_whitespace().collect::<Vec<&str>>();
let notes = notes1.split_whitespace().collect::<Vec<&str>>();
let code = code1.split_whitespace().collect::<Vec<&str>>();

let mut d: HashMap<usize, HashSet<String>> = HashMap::new();

Expand Down

0 comments on commit 76499b7

Please sign in to comment.