[chore](clang-tidy): add bugprone linters (#29521)
This PR introduces 4 bugprone linter rules to .clang-tidy, these linters found some bugs in #28965. This PR also add some comments to mute false positive reports.
This commit is contained in:
15
.clang-tidy
15
.clang-tidy
@ -4,6 +4,10 @@ Checks: |
|
||||
clang-diagnostic-*,
|
||||
clang-analyzer-*,
|
||||
bugprone-redundant-branch-condition,
|
||||
bugprone-use-after-move,
|
||||
bugprone-bool-pointer-implicit-conversion,
|
||||
bugprone-unused-raii,
|
||||
bugprone-fold-init-type,
|
||||
modernize-*,
|
||||
-modernize-use-trailing-return-type,
|
||||
-modernize-use-nodiscard,
|
||||
@ -24,10 +28,9 @@ Checks: |
|
||||
performance-faster-string-find,
|
||||
performance-inefficient-algorithm,
|
||||
performance-move-const-arg
|
||||
WarningsAsErrors: '*'
|
||||
WarningsAsErrors: "*"
|
||||
CheckOptions:
|
||||
- key: readability-function-size.LineThreshold
|
||||
value: '80'
|
||||
- key: readability-function-cognitive-complexity.Threshold
|
||||
value: '50'
|
||||
|
||||
- key: readability-function-size.LineThreshold
|
||||
value: "80"
|
||||
- key: readability-function-cognitive-complexity.Threshold
|
||||
value: "50"
|
||||
|
||||
@ -218,7 +218,7 @@ Status SegmentFlusher::_expand_variant_to_subcolumns(vectorized::Block& block,
|
||||
VLOG_DEBUG << "dump rs schema: " << _context->tablet_schema->dump_structure();
|
||||
}
|
||||
|
||||
block.swap(flush_block);
|
||||
block.swap(flush_block); // NOLINT(bugprone-use-after-move)
|
||||
VLOG_DEBUG << "dump block: " << block.dump_data();
|
||||
VLOG_DEBUG << "dump flush schema: " << flush_schema->dump_structure();
|
||||
return Status::OK();
|
||||
|
||||
@ -224,7 +224,8 @@ void _ingest_binlog(IngestBinlogArg* arg) {
|
||||
}
|
||||
|
||||
// Step 5.2: check data capacity
|
||||
uint64_t total_size = std::accumulate(segment_file_sizes.begin(), segment_file_sizes.end(), 0);
|
||||
uint64_t total_size = std::accumulate(segment_file_sizes.begin(), segment_file_sizes.end(),
|
||||
0); // NOLINT(bugprone-fold-init-type)
|
||||
if (!local_tablet->can_add_binlog(total_size)) {
|
||||
LOG(WARNING) << "failed to add binlog, no enough space, total_size=" << total_size
|
||||
<< ", tablet=" << local_tablet->tablet_id();
|
||||
|
||||
@ -611,10 +611,11 @@ public:
|
||||
std::swap(_need_partition, rhs._need_partition);
|
||||
std::swap(_partitioned_threshold, rhs._partitioned_threshold);
|
||||
|
||||
Hash::operator=(std::move(rhs));
|
||||
Allocator::operator=(std::move(rhs));
|
||||
Cell::State::operator=(std::move(rhs));
|
||||
ZeroValueStorage<Cell::need_zero_value_storage, Cell>::operator=(std::move(rhs));
|
||||
Hash::operator=(std::move(rhs)); // NOLINT(bugprone-use-after-move)
|
||||
Allocator::operator=(std::move(rhs)); // NOLINT(bugprone-use-after-move)
|
||||
Cell::State::operator=(std::move(rhs)); // NOLINT(bugprone-use-after-move)
|
||||
ZeroValueStorage<Cell::need_zero_value_storage, Cell>::operator=(
|
||||
std::move(rhs)); // NOLINT(bugprone-use-after-move)
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -1938,8 +1938,10 @@ Status OrcReader::on_string_dicts_loaded(
|
||||
auto data_type = slot_desc->get_data_type_ptr();
|
||||
if (data_type->is_nullable()) {
|
||||
temp_block.insert(
|
||||
{ColumnNullable::create(std::move(dict_value_column),
|
||||
ColumnUInt8::create(dict_value_column_size, 0)),
|
||||
{ColumnNullable::create(
|
||||
std::move(
|
||||
dict_value_column), // NOLINT(bugprone-use-after-move)
|
||||
ColumnUInt8::create(dict_value_column_size, 0)),
|
||||
std::make_shared<DataTypeNullable>(std::make_shared<DataTypeString>()),
|
||||
""});
|
||||
} else {
|
||||
|
||||
@ -800,8 +800,10 @@ Status RowGroupReader::_rewrite_dict_predicates() {
|
||||
auto data_type = slot_desc->get_data_type_ptr();
|
||||
if (data_type->is_nullable()) {
|
||||
temp_block.insert(
|
||||
{ColumnNullable::create(std::move(dict_value_column),
|
||||
ColumnUInt8::create(dict_value_column_size, 0)),
|
||||
{ColumnNullable::create(
|
||||
std::move(
|
||||
dict_value_column), // NOLINT(bugprone-use-after-move)
|
||||
ColumnUInt8::create(dict_value_column_size, 0)),
|
||||
std::make_shared<DataTypeNullable>(std::make_shared<DataTypeString>()),
|
||||
""});
|
||||
} else {
|
||||
|
||||
@ -648,7 +648,7 @@ Status NewOlapScanNode::_init_scanners(std::list<VScannerSPtr>* scanners) {
|
||||
}
|
||||
|
||||
const auto max_add_seg_nums = rs_seg_count[rowset_idx] - segment_idx_to_scan;
|
||||
auto& split = rs_splits.emplace_back();
|
||||
auto& split = rs_splits.emplace_back(); // NOLINT(bugprone-use-after-move)
|
||||
split.rs_reader = read_source.rs_splits[rowset_idx].rs_reader->clone();
|
||||
|
||||
// if segments assigned to current scanner are already more than the average count,
|
||||
|
||||
@ -62,7 +62,7 @@ ColumnPtr wrap_in_nullable(const ColumnPtr& src, const Block& block, const Colum
|
||||
if (const auto* nullable = assert_cast<const ColumnNullable*>(elem.column.get());
|
||||
nullable->has_null()) {
|
||||
const ColumnPtr& null_map_column = nullable->get_null_map_column_ptr();
|
||||
if (!result_null_map_column) {
|
||||
if (!result_null_map_column) { // NOLINT(bugprone-use-after-move)
|
||||
result_null_map_column = null_map_column->clone_resized(input_rows_count);
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user