Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial SonarQube improvements #69

Merged
merged 1 commit into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/sonarcloud_analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# SPDX-FileCopyrightText: © 2025 Team CharLS
# SPDX-License-Identifier: BSD-3-Clause

name: SonarCloud Analysis
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: windows-latest
env:
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed

steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up msbuild
uses: microsoft/setup-msbuild@v2

- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v3

- name: Restore NuGet packages
working-directory: ${{env.GITHUB_WORKSPACE}}
run: nuget restore ${{env.SOLUTION_FILE_PATH}}

- name: Run build-wrapper
run: |
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

- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Put the name of your token here
run: |
sonar-scanner --define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}"
2 changes: 1 addition & 1 deletion setup/shell-change-notify-custom-action/dll_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: BSD-3-Clause

#include <Windows.h>
#include <msiquery.h>
#include <MsiQuery.h>
#include <ShlObj.h>

unsigned int __stdcall SHChangeNotifyCustomAction(const MSIHANDLE install)
Expand Down
15 changes: 15 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: © 2025 Team CharLS
# SPDX-License-Identifier: BSD-3-Clause

sonar.projectKey = team-charls_netpbm-wic-codec
sonar.organization = team-charls

# This is the name and version displayed in the SonarCloud UI.
sonar.projectVersion = 1.0

# Define the source code to scan (only scan files that are part of the NetPbm-WIC codec)
sonar.sources = src/
sonar.tests = test/

# Encoding of the source code files. Default is the default system encoding, which is not correct.
sonar.sourceEncoding=UTF-8
4 changes: 2 additions & 2 deletions src/dll_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ void register_property_store()
// ReSharper disable CppInconsistentNaming
// ReSharper disable CppParameterNamesMismatch

BOOL __stdcall DllMain(const HMODULE module, const DWORD reason_for_call, void* /*reserved*/) noexcept
BOOL __stdcall DllMain(const HMODULE dll_module, const DWORD reason_for_call, void* /*reserved*/) noexcept
{
switch (reason_for_call)
{
case DLL_PROCESS_ATTACH:
TRACE("netpbm-wic-codec::DllMain DLL_PROCESS_ATTACH \n");
VERIFY(DisableThreadLibraryCalls(module));
VERIFY(DisableThreadLibraryCalls(dll_module));
break;

case DLL_THREAD_ATTACH:
Expand Down
6 changes: 3 additions & 3 deletions src/util.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ namespace {

[[nodiscard]] HMODULE get_current_module() noexcept
{
HMODULE module;
HMODULE current_module;
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<PCWSTR>(get_current_module), &module);
reinterpret_cast<PCWSTR>(get_current_module), &current_module);

return module;
return current_module;
}

} // namespace
Expand Down
Loading