Skip to content

Commit 816eba6

Browse files
committed
ci: enforce clippy lints
1 parent 3279150 commit 816eba6

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,34 @@ jobs:
139139
name: version
140140
path: VERSION
141141

142+
lints:
143+
name: lints [${{ matrix.os }}]
144+
needs: [preflight]
145+
runs-on: ${{ matrix.runner }}
146+
strategy:
147+
matrix:
148+
os: [windows, linux]
149+
include:
150+
- os: windows
151+
runner: windows-2022
152+
- os: linux
153+
runner: ubuntu-latest
154+
155+
steps:
156+
- name: Checkout ${{ github.repository }}
157+
uses: actions/checkout@v4
158+
with:
159+
ref: ${{ needs.preflight.outputs.ref }}
160+
161+
- name: Check clippy
162+
shell: pwsh
163+
run: |
164+
cargo clippy --workspace --tests -- -D warnings
165+
if ($LASTEXITCODE -ne 0) {
166+
Write-Output "::error::Clippy warnings detected, please run 'cargo clippy --workspace --tests' and fix all warnings"
167+
exit 1
168+
}
169+
142170
tests:
143171
name: tests [${{ matrix.os }} ${{ matrix.arch }}]
144172
needs: [preflight]
@@ -1058,7 +1086,7 @@ jobs:
10581086
success:
10591087
name: Success
10601088
if: ${{ always() }}
1061-
needs: [tests, check-dependencies, jetsocat-lipo, devolutions-gateway-powershell, devolutions-gateway, devolutions-gateway-merge, devolutions-pedm-desktop, devolutions-agent, devolutions-agent-merge, devolutions-pedm-client, dotnet-utils-tests, winapi-sanitizer-tests, winapi-miri, pedm-simulator]
1089+
needs: [tests, lints, check-dependencies, jetsocat-lipo, devolutions-gateway-powershell, devolutions-gateway, devolutions-gateway-merge, devolutions-pedm-desktop, devolutions-agent, devolutions-agent-merge, devolutions-pedm-client, dotnet-utils-tests, winapi-sanitizer-tests, winapi-miri, pedm-simulator]
10621090
runs-on: ubuntu-latest
10631091

10641092
steps:

crates/sysevent-winevent/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ impl WinEvent {
2020
/// The source name should match a registered event source in the Windows Registry
2121
/// for proper message formatting and categorization.
2222
pub fn new(source_name: &str) -> Result<Self, SysEventError> {
23-
let source_name_utf16 = to_null_terminated_utf16(source_name.as_ref());
23+
let source_name_utf16 = to_null_terminated_utf16(source_name);
2424

2525
// SAFETY: Proper UTF-16, null-terminated string.
2626
let handle = unsafe { EventLog::RegisterEventSourceW(std::ptr::null(), source_name_utf16.as_ptr()) };
@@ -70,6 +70,10 @@ impl WinEvent {
7070

7171
// Prepare strings for structured logging.
7272
let mut string_ptrs = Vec::new(); // Will be actually used as the parameter of the FFI function.
73+
#[expect(
74+
clippy::collection_is_never_read,
75+
reason = "string_ptrs hold pointers to the string we store inside this Vec"
76+
)]
7377
let mut utf16_strings = Vec::new(); // Keep the UTF-16 strings alive.
7478

7579
// Add the English message as the first parameter for debugging context.

devolutions-gateway/build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::unwrap_used, reason = "panics are build script errors")]
2+
13
fn main() {
24
#[cfg(target_os = "windows")]
35
win::embed_version_rc();
@@ -27,7 +29,7 @@ mod win {
2729
let company_name = "Devolutions Inc.";
2830
let legal_copyright = format!("Copyright 2020-2023 {}", company_name);
2931

30-
let version_number = env::var("CARGO_PKG_VERSION").unwrap() + ".0";
32+
let version_number = format!("{}.0", env::var("CARGO_PKG_VERSION").unwrap());
3133
let version_commas = version_number.replace('.', ",");
3234
let file_description = output_name;
3335
let file_version = version_number.clone();

0 commit comments

Comments
 (0)