-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
clang-tidy fixes & clang-tidy integration into CI #1382
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hawkfish
added a commit
to hawkfish/duckdb
that referenced
this pull request
Feb 17, 2024
Prevent overflow when the window statistics are larger than the frame. Did a bit of code refactoring to avoid copying and pasting the fixes.
Mytherin
added a commit
that referenced
this pull request
Feb 19, 2024
Fuzzer #1382: Window Stats Overflow
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes many problems detected by clang-tidy in the codebase, and integrates clang-tidy into the CI. What this means is that future PRs will now cause the CI to fail if clang-tidy finds problems with their code. This will be used to enforce, amongst others, the style of the codebase (i.e. it will not be a CI error to create a variable called
isSelected
, rather thanis_selected
) and avoid common performance pitfalls (i.e. it will be a CI error to write a function that takes as input avector<int>
but only reads from it, rather than aconst vector<int> &
).Code Changes
Some style changes as a result of this PR are that functions should always be written in CamelCase, even if they are non-member functions, i.e.:
Parameter names (and variable names in general) can no longer have trailing underscores.
When non-trivial objects are used in constructs (e.g. strings, vectors, unordered_maps, LogicalType) they need to be passed as
const &
if not modified:When non-trivial objects are used in constructs (e.g. strings, vectors, unordered_maps, LogicalType, shared_ptr) they need to be passed as
const &
if not modified:When non-trivial objects are copied only once, they should be moved instead, i.e.:
.empty()
needs to be used instead of.size() == 0
:using namespace X
is now forbidden:Running clang-tidy
Clang-tidy has been integrated into the makefile, and can be run using the command
make tidy-check
, ormake tidy-check-parallel
(with optional thread countTIDY_THREADS=16 make tidy-check-parallel
). This uses the cmake file to get a list of sources to compile (with the flag-DCLANG_TIDY
). Currently only thesrc
directory and theparquet
extension are checked using clang-tidy.Fixing errors
In general it is preferable to fix errors manually. There is also a
make tidy-fix
command that instructs clang-tidy to automatically fix errors, but be careful when using this, as it will break the code in certain cases (specifically when changing names, as it does not check for potential name conflicts/collisions).Disabling clang-tidy for specific lines
If required, clang-tidy can be disabled for individual lines by appending a
// NOLINT
comment, i.e.:In general you would need a good reason for this, though.