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

chore(falco): apply code formatting #3350

Merged
merged 1 commit into from
Sep 30, 2024
Merged

Conversation

poiana
Copy link
Contributor

@poiana poiana commented Sep 27, 2024

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind cleanup

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area build

/area engine

/area tests

/area CI

What this PR does / why we need it:

As per title and linting files in the repo.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Copy link
Contributor

@sgaist sgaist left a comment

Choose a reason for hiding this comment

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

Might be a silly question but is the code formatter configured with the correct definition ?
Many of the changes are moving the opening curly bracket to the end of the line rather than to a new line as is the usual in the code base.

Comment on lines 37 to 47
add_custom_target(
cppcheck
COMMAND
${CPPCHECK} "--enable=all" "--force" "--inconclusive" "--inline-suppr" # allows to
# specify
# suppressions
# directly in
# source code
"--xml" # we want to generate a report
"--output-file=${CMAKE_CURRENT_BINARY_DIR}/static-analysis-reports/cppcheck/cppcheck.xml" # generate
# the report
# under the
# reports
# folder in
# the build
# folder
"-i${CMAKE_CURRENT_BINARY_DIR}" # exclude the build folder
"${CMAKE_SOURCE_DIR}"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This block would require better formatting than what is suggested.

message(STATUS "cppcheck command not found, static code analysis using cppcheck will not be available.")
message(
STATUS
"cppcheck command not found, static code analysis using cppcheck will not be available."
Copy link
Contributor

Choose a reason for hiding this comment

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

I would align it to STATUS

Suggested change
"cppcheck command not found, static code analysis using cppcheck will not be available."
"cppcheck command not found, static code analysis using cppcheck will not be available."

add_definitions(-DHAVE_STRLCAT)
message(
STATUS
"Existing strlcpy and strlcat found, will *not* use local definition by setting -DHAVE_STRLCPY and -DHAVE_STRLCAT."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"Existing strlcpy and strlcat found, will *not* use local definition by setting -DHAVE_STRLCPY and -DHAVE_STRLCAT."
"Existing strlcpy and strlcat found, will *not* use local definition by setting -DHAVE_STRLCPY and -DHAVE_STRLCAT."

_HAS_STD_BYTE=0
_CRT_SECURE_NO_WARNINGS
WIN32
MINIMAL_BUILD
WIN32_LEAN_AND_MEAN
NOMINMAX
_HAS_STD_BYTE=0 _CRT_SECURE_NO_WARNINGS WIN32 MINIMAL_BUILD WIN32_LEAN_AND_MEAN NOMINMAX
Copy link
Contributor

Choose a reason for hiding this comment

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

If possible, I'd rather keep the column variant.

Comment on lines +62 to +63
falco/app/actions/test_configure_interesting_sets.cpp
falco/app/actions/test_configure_syscall_buffer_num.cpp
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
falco/app/actions/test_configure_interesting_sets.cpp
falco/app/actions/test_configure_syscall_buffer_num.cpp
falco/app/actions/test_configure_interesting_sets.cpp
falco/app/actions/test_configure_syscall_buffer_num.cpp

Comment on lines 70 to 74
${CMAKE_BINARY_DIR}/userspace/falco # we need it to include indirectly `config_falco.h`
# file
${CMAKE_SOURCE_DIR}/userspace/engine # we need it to include indirectly `falco_common.h`
# file
${CMAKE_CURRENT_BINARY_DIR} # we need it to include `falco_test_var.h`
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we put the comments above each line ?

Suggested change
${CMAKE_BINARY_DIR}/userspace/falco # we need it to include indirectly `config_falco.h`
# file
${CMAKE_SOURCE_DIR}/userspace/engine # we need it to include indirectly `falco_common.h`
# file
${CMAKE_CURRENT_BINARY_DIR} # we need it to include `falco_test_var.h`
# we need it to include indirectly `config_falco.h` file
${CMAKE_BINARY_DIR}/userspace/falco
# we need it to include indirectly `falco_common.h` file
${CMAKE_SOURCE_DIR}/userspace/engine
# we need it to include `falco_test_var.h`
${CMAKE_CURRENT_BINARY_DIR}

Comment on lines +26 to +29
#define FALCO_ENGINE_VERSION \
__FALCO_ENGINE_STRINGIFY(FALCO_ENGINE_VERSION_MAJOR) \
"." __FALCO_ENGINE_STRINGIFY(FALCO_ENGINE_VERSION_MINOR) "." __FALCO_ENGINE_STRINGIFY( \
FALCO_ENGINE_VERSION_PATCH)
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this one less clear to parse. I would rather keep the original.

@poiana poiana force-pushed the chore/falco-code-formatting branch from 15eaa13 to 6a1a33b Compare September 27, 2024 12:36
@FedeDP
Copy link
Contributor

FedeDP commented Sep 27, 2024

@sgaist yep there might be something wrong with this PR since the format code job is still failing 🤣

@LucaGuerra
Copy link
Contributor

Some lint was not applied correctly, and also it looks like CI is still failing. Will probably need some tweaking 🤔

@Andreagit97
Copy link
Member

Andreagit97 commented Sep 27, 2024

Some lint was not applied correctly, and also it looks like CI is still failing. Will probably need some tweaking 🤔

Yep I've done the same for libs. There are usually 2/3 places where clang format cannot converge without your help, so probably you need to change these lines manually... Moreover probably is better to run it more than once to be sure a convergence is reached (maybe just run the CI jobs some times before merging the PR)

For what concern the style I would keep the same we used in libs, with the same clang-format, cmake-format, but of course this is just my opinion

@sgaist
Copy link
Contributor

sgaist commented Sep 27, 2024

Some lint was not applied correctly, and also it looks like CI is still failing. Will probably need some tweaking 🤔

Yep I've done the same for libs. There are usually 2/3 places where clang format cannot converge without your help, so probably you need to change these lines manually... Moreover probably is better to run it more than once to be sure a convergence is reached (maybe just run the CI jobs some times before merging the PR)

For what concern the style I would keep the same we used in libs, with the same clang-format, cmake-format, but of course this is just my opinion

This would make a big change in Falco but I am all for a consistent code style across repositories.
Does anyone have an objection regarding that ?

@FedeDP
Copy link
Contributor

FedeDP commented Sep 30, 2024

Does anyone have an objection regarding that ?

I don't, since it is the same formatting we now follow in libs, it's ok for me.

@poiana poiana force-pushed the chore/falco-code-formatting branch from 6a1a33b to 36078f4 Compare September 30, 2024 08:54
@LucaGuerra
Copy link
Contributor

Ok for me. It's a start to have a code style :)

Signed-off-by: Poiana <poiana.bot@gmail.com>
@poiana poiana force-pushed the chore/falco-code-formatting branch from 36078f4 to b671a6f Compare September 30, 2024 10:06
Copy link
Contributor

@FedeDP FedeDP left a comment

Choose a reason for hiding this comment

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

/approve

@poiana
Copy link
Contributor Author

poiana commented Sep 30, 2024

LGTM label has been added.

Git tree hash: 355da5b3177a66870377abbc4d30b7ebadc37d6a

@poiana
Copy link
Contributor Author

poiana commented Sep 30, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FedeDP, poiana

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@FedeDP
Copy link
Contributor

FedeDP commented Sep 30, 2024

/milestone 0.39.0

@poiana poiana added this to the 0.39.0 milestone Sep 30, 2024
Copy link
Contributor

@sgaist sgaist left a comment

Choose a reason for hiding this comment

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

Approving as most the concerns have been fixed by an actual run of the linter.

Details will be fixed in followup work.

@poiana poiana merged commit 50b98b3 into master Sep 30, 2024
36 checks passed
@poiana poiana deleted the chore/falco-code-formatting branch September 30, 2024 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants