Skip to content
Open
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
17 changes: 12 additions & 5 deletions .github/workflows/clangtidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

- name: Install clang-tidy
run: |
sudo apt get install -y clang-tidy
sudo apt install -y clang-tidy

- name: Build and generate compile_commands.json
run: |
Expand All @@ -33,11 +33,18 @@ jobs:

- name: Run clang-tidy
run: |
git diff -U0 origin/${{ github.base_ref }}...HEAD \
git diff -U0 origin/${{ github.base_ref }}...HEAD | \
clang-tidy-diff -p1 -path build -export-fixes build/Release/clang-tidy-fixes.yml

- name: Post clang-tidy comments
uses: ZedThree/clang-tidy-review@v0.20.1
#uses: ZedThree/clang-tidy-review@v0.20.1
uses: stsoe/clang-tidy-review@6d2aee59f56cf41f32baa4123cc636fff8ef4eb7
with:
clang_tidy_fixes: build/Release/clang-tidy-fixes.yml
github_token: ${{ secrets.GITHUB_TOKEN }}
build_dir: build/Release
# disable default checks and rely on closest .clangtidy
clang_tidy_checks: ''
token: ${{ secrets.GITHUB_TOKEN }}

# If there are any comments, fail the check
- if: steps.review.outputs.total_comments > 0
run: exit 1
4 changes: 0 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@ if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()

find_package(Boost REQUIRED)
message("-- Boost_INCLUDE_DIRS=${Boost_INCLUDE_DIRS}")

add_executable(main hello.cpp)
target_include_directories(main PRIVATE ${Boost_INCLUDE_DIRS})
install(TARGETS main)
22 changes: 20 additions & 2 deletions src/hello.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
#include <iostream>
#include <string>

#include <boost/format.hpp>
class X
{
std::string m_string;
public:
X(const std::string& str) : m_string(str) {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: pass by value and use std::move [modernize-pass-by-value]

src/hello.cpp:2:

+ #include <utility>
Suggested change
X(const std::string& str) : m_string(str) {}
X(std::string str) : m_string(std::move(str)) {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: single-argument constructors must be marked explicit to avoid unintentional implicit conversions [hicpp-explicit-conversions]

Suggested change
X(const std::string& str) : m_string(str) {}
explicit X(const std::string& str) : m_string(str) {}


std::string
get_string()
{
return m_string;
}
};

std::string hello()
{
std::string const str = "hello";
X x(str);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable name 'x' is too short, expected at least 3 characters [readability-identifier-length]

  X x(str);
    ^

return x.get_string();
}

int main()
{
std::cout << "hello" << std::endl;
std::cout << hello() << '\n';
return 0;
}