diff --git a/.clang-tidy b/.clang-tidy index 1cb4f15..ffc574a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -7,11 +7,11 @@ Checks: modernize-*, performance-*, portability-*, - readability-* - -HeaderFilterRegex: 'src' -FormatStyle: file - + readability-*, + -readability-function-cognitive-complexity, + -bugprone-suspicious-stringview-data-usage +WarningsAsErrors: '' +HeaderFilterRegex: '' CheckOptions: - key: readability-identifier-naming.StaticVariableCase value: lower_case @@ -52,9 +52,9 @@ CheckOptions: - key: readability-identifier-naming.PrivateMethodCase value: lower_case - key: readability-identifier-naming.PublicMethodCase - value: camelCase + value: camelBack - key: readability-identifier-naming.ProtectedMethodCase - value: camelCase + value: camelBack - key: readability-identifier-naming.ConstexprVariableCase value: UPPER_CASE @@ -66,3 +66,4 @@ CheckOptions: - key: readability-identifier-naming.NamespaceCase value: CamelCase +... diff --git a/.github/workflows/check-code-formatting.yml b/.github/workflows/check-code-formatting.yml deleted file mode 100644 index 6eab6d9..0000000 --- a/.github/workflows/check-code-formatting.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: clang-format Check - -on: [pull_request] - -jobs: - formatting-check: - name: Formatting Check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Run clang-format style check for C/C++/Protobuf programs. - uses: jidicula/clang-format-action@v4.14.0 - with: - clang-format-version: "15" diff --git a/.github/workflows/code-format.yml b/.github/workflows/code-format.yml deleted file mode 100644 index b007929..0000000 --- a/.github/workflows/code-format.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Code Format and Auto PR - -on: - pull_request_target: - types: [closed] - branches: [develop] - -jobs: - format-and-pr: - if: ${{ github.event.pull_request.merged == true && startsWith(github.base_ref, 'develop') }} - runs-on: ubuntu-latest - permissions: - contents: write - pull-requests: write - - steps: - - name: Checkout target repo - uses: actions/checkout@v4 - - # --- C/C++ --- - - name: Format C/C++ with clang-format - run: | - sudo apt-get update - sudo apt-get install -y clang-format - find . -regex '.*\.\(cpp\|hpp\|cu\|cuh\|c\|h\)' -exec clang-format -style=file -i {} \; - - # --- CMake --- - - name: Format CMake files - run: | - sudo apt-get update - sudo apt-get install -y pipx - pipx install cmakelang - find . -regex '.*\.\(cmake\)' -exec cmake-format -i {} \; - find . -name 'CMakeLists.txt' -exec cmake-format -i {} \; - - # --- JSON --- - - name: Format JSON files - run: | - sudo apt-get update - sudo apt-get install -y jq - find . -regex '.*\.\(json\)' -exec bash -c "jq . {} > {}.tmp && mv {}.tmp {}" \; - - # --- Create Pull Request --- - - name: Create PR with formatted code - uses: peter-evans/create-pull-request@v6.0.4 - with: - commit-message: C/C++/QML formatted code - branch: formatted_code - author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> - title: Fix the format of your nice code - body: Every time you change the format, I am here to fix your mess. - diff --git a/.github/workflows/conf-build-test.yml b/.github/workflows/conf-build-test.yml index 1aee068..6fc9c8e 100644 --- a/.github/workflows/conf-build-test.yml +++ b/.github/workflows/conf-build-test.yml @@ -5,8 +5,8 @@ on: push: tags: - 'v*' - pull_request: - branches: [main, develop] + # pull_request: + # branches: [main, develop] jobs: build_test_package: @@ -128,4 +128,3 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 - diff --git a/.github/workflows/cpp-linter.yml b/.github/workflows/cpp-linter.yml new file mode 100644 index 0000000..25ec585 --- /dev/null +++ b/.github/workflows/cpp-linter.yml @@ -0,0 +1,38 @@ +name: cpp-linter + +on: [pull_request] + +jobs: + cpp-linter: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + - uses: actions/setup-python@v6 + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y cmake ninja-build doxygen clang-tidy libglib2.0-dev + + - name: Configure, build and test + run: cmake --workflow --preset default-develop + + - uses: cpp-linter/cpp-linter-action@v2 + id: linter + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + database: 'build/default-develop' + style: 'file' + tidy-checks: '' + files-changed-only: "true" + step-summary: true + file-annotations: "true" + version: 20 + + - if: steps.linter.outputs.checks-failed > 0 + run: exit 1 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 6c52648..0000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Lint and Comment on PR - -on: - workflow_run: - workflows: [push-build-test-lint-release] - types: - - completed - -jobs: - lint-and-comment: - if: ${{ github.event.workflow_run.conclusion == 'success' }} - runs-on: ubuntu-latest - permissions: - actions: read - pull-requests: write - - steps: - - name: 'Download artifact' - uses: actions/download-artifact@v4 - with: - name: common - github-token: ${{ secrets.GITHUB_TOKEN }} - run-id: ${{ github.event.workflow_run.id }} - path: ${{ runner.temp }} - - - name: Read PR variables - id: getprv - working-directory: ${{ runner.temp }} - run: | - echo "prn=$(cat pr_number)" >> $GITHUB_OUTPUT - echo "prhr=$(cat pr-head-repo)" >> $GITHUB_OUTPUT - echo "prhs=$(cat pr-head-sha)" >> $GITHUB_OUTPUT - if [ -f "clang-fixes.yml" ]; then - echo "exists=true" >> $GITHUB_OUTPUT - else - echo "exists=false" >> $GITHUB_OUTPUT - fi - - - uses: actions/checkout@v4 - if: steps.getprv.outputs.exists == 'true' - with: - repository: ${{ steps.getprv.outputs.prhr }} - ref: ${{ steps.getprv.outputs.prhs }} - persist-credentials: false - - - name: Run clang-tidy-pr-comments - if: steps.getprv.outputs.exists == 'true' - continue-on-error: true - uses: platisd/clang-tidy-pr-comments@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - clang_tidy_fixes: ${{ runner.temp }}/clang-fixes.yml - pull_request_id: ${{ steps.getprv.outputs.prn }} - request_changes: false - diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..c68cca3 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,13 @@ +name: build-and-checks + +on: [pull_request] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v6 + - uses: pre-commit/action@v3.0.1 + with: + extra_args: --all-files --show-diff-on-failure diff --git a/.github/workflows/recreate-develop.yml b/.github/workflows/recreate-develop.yml deleted file mode 100644 index fd9ddfa..0000000 --- a/.github/workflows/recreate-develop.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Auto-Create Develop Branch -run-name: Recreating develop branch - -on: - pull_request_target: - types: [closed] - branches: [main] - -jobs: - create-develop-branch: - if: ${{ github.event.pull_request.merged == true && startsWith(github.base_ref, 'main') && startsWith(github.head_ref, 'develop') }} - runs-on: ubuntu-latest - permissions: - contents: write - - steps: - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Set Up Git - run: | - git config --global user.name "${{ github.actor }}" - git config --global user.email "${{ github.actor }}@users.noreply.github.com" - - - name: Delete existing 'develop' branch (if exists) - run: | - git fetch origin - git push origin --delete develop || echo "Branch 'develop' does not exist on remote." - - - name: Create new 'develop' branch from main - run: | - git checkout main - git checkout -b develop - git push origin develop - diff --git a/.gitignore b/.gitignore index 37bf44f..eabf9c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,239 @@ -.vscode -build* doc tags -CMakeUserPresets.json + +*build*/ +*.cache* dbus_xml/net.connman/*.h dbus_xml/net.connman/*.c + +# Created by https://www.toptal.com/developers/gitignore/api/clion+all,visualstudiocode,qtcreator,cmake,c,c++ +# Edit at https://www.toptal.com/developers/gitignore?templates=clion+all,visualstudiocode,qtcreator,cmake,c,c++ + +### C ### +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +### C++ ### +# Prerequisites + +# Compiled Object files +*.slo + +# Precompiled Headers + +# Compiled Dynamic libraries + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai + +# Executables + +### CLion+all ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### CLion+all Patch ### +# Ignore everything but code style settings and run configurations +# that are supposed to be shared within teams. + +.idea/* + +!.idea/codeStyles +!.idea/runConfigurations + +### CMake ### +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +### CMake Patch ### +CMakeUserPresets.json + +# External projects +*-prefix/ + +### QtCreator ### +# gitignore for Qt Creator like IDE for pure C/C++ project without Qt +# +# Reference: http://doc.qt.io/qtcreator/creator-project-generic.html + + + +# Qt Creator autogenerated files + + +# A listing of all the files included in the project +*.files + +# Include directories +*.includes + +# Project configuration settings like predefined Macros +*.config + +# Qt Creator settings +*.creator + +# User project settings +*.creator.user* + +# Qt Creator backups +*.autosave + +# Flags for Clang Code Model +*.cxxflags +*.cflags + + +### VisualStudioCode ### +.vscode/* + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# End of https://www.toptal.com/developers/gitignore/api/clion+all,visualstudiocode,qtcreator,cmake,c,c++ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..4364672 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,10 @@ +fail_fast: false + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-json + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace diff --git a/CMakePresets.json b/CMakePresets.json index 8dad0f2..ba9acae 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -131,4 +131,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/README.md b/README.md index 3115101..4ffae6e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# gdbus-cpp +# gdbus-cpp [TOC] -This repository should provide easy to use C++ API to communicate with the DBus using GDBus. +This repository should provide easy to use C++ API to communicate with the DBus using GDBus. ## Configure, build, test, package ... @@ -15,9 +15,9 @@ Refer to [cmake](https://cmake.org/cmake/help/latest/manual/cmake.1.html), [ctes ```CMake include(FetchContent) FetchContent_Declare( - GDbusCpp - GIT_REPOSITORY https://github.com/amarula/libcppconnman.git - GIT_TAG vMAJOR.MINOR.PATCH + GDbusCpp + GIT_REPOSITORY https://github.com/amarula/libcppconnman.git + GIT_TAG vMAJOR.MINOR.PATCH FIND_PACKAGE_ARGS MAJOR.MINOR CONFIG ) FetchContent_MakeAvailable(GDbusCpp) @@ -31,4 +31,3 @@ You can read the [API reference](https://amarula.github.io/libcppconnman/), or g ``` cmake --workflow --preset default-documentation ``` - diff --git a/cmake/VersionFromGit.cmake b/cmake/VersionFromGit.cmake index 9120b63..0083503 100644 --- a/cmake/VersionFromGit.cmake +++ b/cmake/VersionFromGit.cmake @@ -165,5 +165,3 @@ function( version_from_git ) set( VERSION_PATCH ${version_patch} PARENT_SCOPE ) endfunction( version_from_git ) - - diff --git a/examples/connmanctl.cpp b/examples/connmanctl.cpp index 0f36325..0a71dc9 100644 --- a/examples/connmanctl.cpp +++ b/examples/connmanctl.cpp @@ -286,4 +286,4 @@ auto main() -> int { } std::cout << "Exiting.\n"; return 0; -} \ No newline at end of file +} diff --git a/src/dbus/gdbus.cpp b/src/dbus/gdbus.cpp index 80e16e4..d9add16 100644 --- a/src/dbus/gdbus.cpp +++ b/src/dbus/gdbus.cpp @@ -100,4 +100,4 @@ void DBus::start() { } } -} // namespace Amarula::DBus::G \ No newline at end of file +} // namespace Amarula::DBus::G diff --git a/tests/gconnman_serv_test.cpp b/tests/gconnman_serv_test.cpp index 197315b..c01637e 100644 --- a/tests/gconnman_serv_test.cpp +++ b/tests/gconnman_serv_test.cpp @@ -144,4 +144,4 @@ TEST(Connman, ConnectWifi) { ASSERT_TRUE(called) << "ServicesChanged callback was never called"; ASSERT_TRUE(called_request_input) << "Did not requested user input"; -} \ No newline at end of file +} diff --git a/tests/gconnman_tech_test.cpp b/tests/gconnman_tech_test.cpp index 47c84c4..48bd3fc 100644 --- a/tests/gconnman_tech_test.cpp +++ b/tests/gconnman_tech_test.cpp @@ -130,4 +130,4 @@ TEST(Connman, PowerOffAllTechnologies) { }); } ASSERT_TRUE(called) << "setPowered callback was never called"; -} \ No newline at end of file +}