Skip to content

Commit

Permalink
chore: Added CI and fixed Clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Le0X8 committed Aug 2, 2024
1 parent 0070c2d commit 337b7c4
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 20 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Run CI
on: [push, pull_request]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
jobs:
ci:
runs-on: ubuntu-latest

steps:
- name: Set up Rust
uses: actions/checkout@v4
- name: Install cargo-audit
run: cargo install cargo-audit
- name: Build
run: cargo build --verbose
- name: Run clippy
run: cargo clippy --verbose -- -D warnings
- name: Run audit
run: cargo audit
16 changes: 16 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"recommendations": [
"github.vscode-github-actions",
"ms-vscode.hexeditor",
"wakatime.vscode-wakatime",
"github.vscode-pull-request-github",
"fill-labs.dependi",
"tamasfe.even-better-toml",
"github.remotehub",
"dustypomerleau.rust-syntax",
"rust-lang.rust-analyzer",
"vadimcn.vscode-lldb",
"usernamehw.errorlens",
"gruntfuggly.todo-tree"
]
}
11 changes: 10 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
{
"editor.tabSize": 4
"editor.tabSize": 4,
"errorLens.enabled": true,
"errorLens.gutterIconsEnabled": true,
"errorLens.gutterIconSet": "squareRounded",
"todo-tree.regex.regex": "(//|#|<!--|;|/\\*|^|^[ \\t]*(-|\\d+.))\\s*($TAGS)|todo!|unimplemented!",
"rust-analyzer.check.command": "clippy",
"[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.formatOnSave": true,
},
}
9 changes: 3 additions & 6 deletions src/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ pub fn create(format: String, input: String, output: String, buffer_size: u64) {
.split(';')
.map(|file| {
let file = file.split(':').collect::<Vec<&str>>();
let source_path = file.get(0).unwrap();
let source_path = file.first().unwrap();
let mut target_path = source_path;
match file.get(1) {
Some(path) => {
target_path = path;
}
None => {}
if let Some(path) = file.get(1) {
target_path = path;
}
EntrySource {
path: target_path.to_string(),
Expand Down
12 changes: 4 additions & 8 deletions src/commands/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ pub fn list(format_string: String, input: String, check_integrity: bool, buffer_

match format {
Formats::Zip => {
let metadata = match *metadata {
OriginalArchiveMetadata::Zip(metadata) => metadata,
};
let OriginalArchiveMetadata::Zip(metadata) = *metadata;

let mut i: u32 = 0;
println!("");
for file in &metadata.files {
println!();
for (i, file) in (0_u32..).zip(metadata.files.iter()) {
println!("{}", file.path);
println!("{}", "=".repeat(file.path.len()));
println!("Index: {}", i);
Expand All @@ -26,7 +23,7 @@ pub fn list(format_string: String, input: String, check_integrity: bool, buffer_
"Size: {} ({} compressed)",
byte_unit::Byte::from_u64(file.uncompressed_size.into())
.get_appropriate_unit(byte_unit::UnitType::Decimal),
byte_unit::Byte::from_u64(file.size.into())
byte_unit::Byte::from_u64(file.size)
.get_appropriate_unit(byte_unit::UnitType::Decimal)
);
println!(
Expand All @@ -36,7 +33,6 @@ pub fn list(format_string: String, input: String, check_integrity: bool, buffer_
println!("CRC-32 checksum: 0x{:x}", file.checksum);
println!("Compression method: {}\n", file.compression);
};
i += 1;
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/commands/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ pub fn metadata(format_string: String, input: String, check_integrity: bool, buf

match format {
Formats::Zip => {
let metadata = match *metadata {
OriginalArchiveMetadata::Zip(metadata) => metadata,
};
let OriginalArchiveMetadata::Zip(metadata) = *metadata;

println!("Type: {}", format_string);
let mut file_count: u32 = 0;
Expand All @@ -36,7 +34,7 @@ pub fn metadata(format_string: String, input: String, check_integrity: bool, buf
for file in &metadata.files {
total_size += file.size;
}
let total_size = byte_unit::Byte::from_u64(total_size.into())
let total_size = byte_unit::Byte::from_u64(total_size)
.get_appropriate_unit(byte_unit::UnitType::Decimal);
println!("Total size (compressed): {}", total_size);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//mod text;
#![allow(clippy::too_many_arguments)]

mod commands;

use clap::Parser;
Expand Down

0 comments on commit 337b7c4

Please sign in to comment.