Skip to content

Commit 359567b

Browse files
committed
Initial SonarQube improvements
1 parent 5196104 commit 359567b

File tree

5 files changed

+64
-6
lines changed

5 files changed

+64
-6
lines changed
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# SPDX-FileCopyrightText: © 2025 Team CharLS
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
4+
name: SonarCloud Analysis
5+
on:
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
types: [opened, synchronize, reopened]
11+
jobs:
12+
build:
13+
name: Build
14+
runs-on: windows-latest
15+
env:
16+
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
with:
21+
submodules: true
22+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
23+
24+
- name: Set up msbuild
25+
uses: microsoft/setup-msbuild@v2
26+
27+
- name: Install sonar-scanner and build-wrapper
28+
uses: SonarSource/sonarcloud-github-c-cpp@v3
29+
30+
- name: Restore NuGet packages
31+
working-directory: ${{env.GITHUB_WORKSPACE}}
32+
run: nuget restore ${{env.SOLUTION_FILE_PATH}}
33+
34+
- name: Run build-wrapper
35+
run: |
36+
build-wrapper-win-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} msbuild netpbm-wic-codec.sln /t:netpbm-wic-codec:rebuild /p:Configuration="Release" /p:Platform="x64" /nodeReuse:false
37+
38+
- name: Run sonar-scanner
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Put the name of your token here
42+
run: |
43+
sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"

setup/shell-change-notify-custom-action/dll_main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: BSD-3-Clause
33

44
#include <Windows.h>
5-
#include <msiquery.h>
5+
#include <MsiQuery.h>
66
#include <ShlObj.h>
77

88
unsigned int __stdcall SHChangeNotifyCustomAction(const MSIHANDLE install)

sonar-project.properties

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SPDX-FileCopyrightText: © 2025 Team CharLS
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
4+
sonar.projectKey = team-charls_netpbm-wic-codec
5+
sonar.organization = team-charls
6+
7+
# This is the name and version displayed in the SonarCloud UI.
8+
sonar.projectVersion = 1.0
9+
10+
# Define the source code to scan (only scan files that are part of the NetPbm-WIC codec)
11+
sonar.sources = src/
12+
sonar.tests = test/
13+
14+
# Encoding of the source code files. Default is the default system encoding, which is not correct.
15+
sonar.sourceEncoding=UTF-8

src/dll_main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ void register_property_store()
167167
// ReSharper disable CppInconsistentNaming
168168
// ReSharper disable CppParameterNamesMismatch
169169

170-
BOOL __stdcall DllMain(const HMODULE module, const DWORD reason_for_call, void* /*reserved*/) noexcept
170+
BOOL __stdcall DllMain(const HMODULE dll_module, const DWORD reason_for_call, void* /*reserved*/) noexcept
171171
{
172172
switch (reason_for_call)
173173
{
174174
case DLL_PROCESS_ATTACH:
175175
TRACE("netpbm-wic-codec::DllMain DLL_PROCESS_ATTACH \n");
176-
VERIFY(DisableThreadLibraryCalls(module));
176+
VERIFY(DisableThreadLibraryCalls(dll_module));
177177
break;
178178

179179
case DLL_THREAD_ATTACH:

src/util.ixx

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ namespace {
1717

1818
[[nodiscard]] HMODULE get_current_module() noexcept
1919
{
20-
HMODULE module;
20+
HMODULE current_module;
2121
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
22-
reinterpret_cast<PCWSTR>(get_current_module), &module);
22+
reinterpret_cast<PCWSTR>(get_current_module), &current_module);
2323

24-
return module;
24+
return current_module;
2525
}
2626

2727
} // namespace

0 commit comments

Comments
 (0)