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

Enable InsertBraces in clang-format #1851

Merged
merged 2 commits into from
Sep 20, 2024
Merged

Conversation

SimonBaeumer
Copy link
Member

@SimonBaeumer SimonBaeumer commented Sep 18, 2024

Description

Enable expand brackets clang-format for better readability.

#1851

@SimonBaeumer
Copy link
Member Author

Options to update clang-formater by @Molter73 in this comment: #1849 (comment)

@SimonBaeumer SimonBaeumer changed the title Enable expand ifs in clang Enable IntertBraces in clang-format Sep 18, 2024
@Molter73
Copy link
Collaborator

So the lint workflow is now broken because this line:

Is trying to install packages using pip on a system that has python managed by the OS (this is actually a good thing, a lot of systems have been broken by pip installing packages over the actual system ones).

Additionally, the pre-commit/action workflow is now in maintanance mode and they suggest using pre-commit-ci instead, but that looks like a tool that fixes commits and is not really what we want, we want to check PRs, we don't want to have additional commits pushed on us.

I suggest we change the pre-commit/action line for the following block instead:

      - name: Run pre-commit
        run: |
          python3 -m venv .venv
          source .venv/bin/activate
          python3 -m pip install pre-commit
          pre-commit run --all-files

Not as convenient as a prebuilt action, but it's only 4 lines of bash, so 🤷🏻‍♂️.

@SimonBaeumer
Copy link
Member Author

So the lint workflow is now broken because this line:

Is trying to install packages using pip on a system that has python managed by the OS (this is actually a good thing, a lot of systems have been broken by pip installing packages over the actual system ones).

Additionally, the pre-commit/action workflow is now in maintanance mode and they suggest using pre-commit-ci instead, but that looks like a tool that fixes commits and is not really what we want, we want to check PRs, we don't want to have additional commits pushed on us.

I suggest we change the pre-commit/action line for the following block instead:

      - name: Run pre-commit
        run: |
          python3 -m venv .venv
          source .venv/bin/activate
          python3 -m pip install pre-commit
          pre-commit run --all-files

Not as convenient as a prebuilt action, but it's only 4 lines of bash, so 🤷🏻‍♂️.

Let's try it.

@Molter73
Copy link
Collaborator

Let's try it.

Well it sorta worked, looks like the clang-format step failed, maybe we need to rebase this PR so the changes you did to the braces are picked up? Also, could you add --show-diff-on-failure --color=always to the pre-commit command in the lint workflow? That should help see what the differences actually are.

There's also a lint error I was not expecting here:

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

That block seems unreachable because the previous if block does exit 0 on both of its branches. @Stringy, can we remove the block or should we move it above the previous one?

@Molter73
Copy link
Collaborator

Discussed offline and decided I'll be taking over the PR, @SimonBaeumer sorry your small change got so out of hand 😅

@SimonBaeumer SimonBaeumer reopened this Sep 18, 2024
@Molter73 Molter73 changed the title Enable IntertBraces in clang-format Enable InsertBraces in clang-format Sep 18, 2024
@Molter73 Molter73 marked this pull request as ready for review September 19, 2024 09:13
@Molter73 Molter73 requested a review from a team as a code owner September 19, 2024 09:13
SimonBaeumer and others added 2 commits September 20, 2024 11:11
Additionaly, the lint job is now run in the ubuntu-24.04 runner. This
is needed to use a newer version of clang-format that supports the
InsertBraces check.
This should make the environment used for running the lint job closer to
what most of the team has as local dev environments.
Copy link
Collaborator

@Stringy Stringy left a comment

Choose a reason for hiding this comment

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

LGTM!

@Molter73
Copy link
Collaborator

Looks like konflux is gonna time out, but we don't really care about it, so I'm merging as is.

@Molter73 Molter73 merged commit 0fed6de into master Sep 20, 2024
35 of 37 checks passed
@Molter73 Molter73 deleted the sb/enable-expand-ifs-in-clang branch September 20, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants