Skip to content

Commit

Permalink
Use clippy and fmt from rules_rust
Browse files Browse the repository at this point in the history
  • Loading branch information
kiron1 committed Dec 9, 2024
1 parent 4ba5205 commit 562b8f1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 35 deletions.
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ build --incompatible_merge_fixed_and_default_shell_env

build --enable_platform_specific_config

build:clippy --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
build:clippy --output_groups=+clippy_checks

build:format --aspects=@rules_rust//rust:defs.bzl%rustfmt_aspect
build:format --output_groups=+rustfmt_checks

build:macos --apple_crosstool_top=@local_config_apple_cc//:toolchain
build:macos --crosstool_top=@local_config_apple_cc//:toolchain
build:macos --host_crosstool_top=@local_config_apple_cc//:toolchain
Expand Down
28 changes: 2 additions & 26 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ jobs:
bazel
test
--config=ci
--config=clippy
--config=format
--//:version=${{ needs.version.outputs.version }}
--//:rev=${{ needs.version.outputs.rev }}
${{ matrix.buildflags }}
Expand Down Expand Up @@ -295,31 +297,6 @@ jobs:
REPO: ${{ github.repository }}
VERSION: v${{ needs.version.outputs.version }}

format_check:
name: Rust lint
runs-on: ubuntu-20.04

strategy:
matrix:
lint: [clippy, fmt]
include:
- lint: clippy
flags: --all
- lint: fmt
flags: --all -- --check

steps:
- uses: actions/checkout@v4
- name: Rustup
run: |
rustup update --no-self-update stable
rustup component add clippy rustfmt
- name: Install Linux dependency
run: sudo apt-get install libkrb5-dev
if: ${{ matrix.lint == 'clippy' }}
- name: Lint check
run: cargo ${{ matrix.lint }} ${{ matrix.flags }}

# The success job is here to consolidate the total success/failure state of
# all other jobs. This job is then included in the GitHub branch protection
# rule which prevents merges unless all other jobs are passing. This makes
Expand All @@ -331,7 +308,6 @@ jobs:
needs:
- bazel_build
- cargo_build_and_test
- format_check
runs-on: ubuntu-latest
steps:
- run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
Expand Down
8 changes: 4 additions & 4 deletions proxydetox/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ mod tests {
#[test]
fn test_default() {
let args = Options::parse_args(&["proxydetox".into()]);
assert_eq!(args.direct_fallback, false);
assert_eq!(args.always_use_connect, false);
assert!(!args.direct_fallback);
assert!(!args.always_use_connect);
}

#[test]
Expand All @@ -449,8 +449,8 @@ mod tests {
"--direct-fallback".into(),
"--always-use-connect".into(),
]);
assert_eq!(args.direct_fallback, true);
assert_eq!(args.always_use_connect, true);
assert!(args.direct_fallback);
assert!(args.always_use_connect);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion proxydetoxlib/tests/environment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl Environment {
assert!(h.is_none());

let (response, connection) = tokio::join!(request_sender.send_request(request), connection);
let _ = connection.unwrap();
connection.unwrap();
response.unwrap()
}

Expand Down
8 changes: 4 additions & 4 deletions tools/toml_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
};
}
let value = match value {
Value::String(v) => format!("{v}"),
Value::Integer(v) => format!("{v}"),
Value::Float(v) => format!("{v}"),
Value::Boolean(v) => format!("{v}"),
Value::String(v) => v.to_string(),
Value::Integer(v) => v.to_string(),
Value::Float(v) => v.to_string(),
Value::Boolean(v) => v.to_string(),
x => format!("{x}"),
};
let stdout = std::io::stdout();
Expand Down

0 comments on commit 562b8f1

Please sign in to comment.