Skip to content

Commit

Permalink
Enable InsertBraces in clang-format (#1851)
Browse files Browse the repository at this point in the history
Co-authored-by: Mauro Ezequiel Moltrasio <[email protected]>
  • Loading branch information
SimonBaeumer and Molter73 authored Sep 20, 2024
1 parent 7479943 commit 0fed6de
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ PointerAlignment: Left

IndentPPDirectives: AfterHash

InsertBraces: true

IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^((\"|<)(api|internalapi|storage)/)'
Expand Down
31 changes: 28 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,43 @@ on: [pull_request]

jobs:
lint:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
container:
image: fedora:40
steps:
- name: dnf install dependencies
run: |
dnf install -y \
git \
golang \
shellcheck \
clang-tools-extra
echo "PATH=${HOME}/bin:${PATH}" >> "${GITHUB_ENV}"
- uses: actions/checkout@v4
with:
# fetch all to allow linting of differences between branches
fetch-depth: 0

- name: Mark repo as safe
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- uses: actions/setup-python@v5
- uses: mfinelli/setup-shfmt@v2

- name: Install shfmt
run: |
GOBIN="${HOME}/bin/" go install mvdan.cc/sh/v3/cmd/shfmt@latest
- name: Install actionlint
run: |
# Install actionlint to ~/bin/, otherwise pre-commit won't be able to find the executable.
GOBIN="${HOME}/bin/" go install github.com/rhysd/actionlint/cmd/actionlint@latest
- uses: pre-commit/[email protected]
- name: Run pre-commit
run: |
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install pre-commit
pre-commit run --show-diff-on-failure --color=always --all-files
2 changes: 1 addition & 1 deletion collector/lib/CollectorStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class CollectorStats {

std::array<std::atomic<int64_t>, counter_type_max> counter_ = {{}};

CollectorStats(){};
CollectorStats() {};
};

template <typename T>
Expand Down
3 changes: 1 addition & 2 deletions collector/lib/DuplexGRPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,7 @@ class DuplexClientReaderWriter : public DuplexClientWriter<W> {
// Shutdown the client and drain the queue.
this->Shutdown(); // ignore errors
auto now = ToDeadline(time_point::min());
while (ProcessSingle(nullptr, now, nullptr))
;
while (ProcessSingle(nullptr, now, nullptr));
}

template <typename TS = time_point>
Expand Down
3 changes: 1 addition & 2 deletions collector/lib/ProcfsScraper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ const char* nextfield(const char* p, const char* endp) {
while (p < endp && *p && !std::isspace(*p)) {
p++;
}
while (p < endp && *p && std::isspace(*++p))
;
while (p < endp && *p && std::isspace(*++p));
return (p < endp && *p) ? p : nullptr;
}

Expand Down
3 changes: 1 addition & 2 deletions collector/lib/SignalServiceClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ bool SignalServiceClient::EstablishGRPCStreamSingle() {
}

void SignalServiceClient::EstablishGRPCStream() {
while (EstablishGRPCStreamSingle())
;
while (EstablishGRPCStreamSingle());
CLOG(INFO) << "Signal service client terminating.";
}

Expand Down
4 changes: 2 additions & 2 deletions collector/lib/SignalServiceClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class StdoutSignalServiceClient : public ISignalServiceClient {

explicit StdoutSignalServiceClient() {}

void Start(){};
void Stop(){};
void Start() {};
void Stop() {};

SignalHandler::Result PushSignals(const SignalStreamMessage& msg);
};
Expand Down
2 changes: 1 addition & 1 deletion collector/test/HostHeuristicsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MockHostInfoHeuristics : public HostInfo {
class MockCollectorConfig : public CollectorConfig {
public:
MockCollectorConfig()
: CollectorConfig(){};
: CollectorConfig() {};

void SetCollectionMethod(CollectionMethod cm) {
if (host_config_.HasCollectionMethod()) {
Expand Down
10 changes: 5 additions & 5 deletions integration-tests/container/perf/scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ check_headers() {
return 0
}

if [[ "$(sysctl -n kernel.kptr_restrict)" != "0" ]]; then
# If this is not zero, it can interfere with most of the tools
sysctl -w kernel.kptr_restrict=0
fi

if [[ ! -e "/lib/modules/.installed" ]]; then
if check_headers "${HOST_MODULES_DIR}"; then
HEADERS_TARGET="${HOST_MODULES_DIR}/source"
Expand All @@ -139,8 +144,3 @@ else
echo "Headers already installed"
exit 0
fi

if [[ "$(sysctl -n kernel.kptr_restrict)" != "0" ]]; then
# If this is not zero, it can interfere with most of the tools
sysctl -w kernel.kptr_restrict=0
fi

0 comments on commit 0fed6de

Please sign in to comment.