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

Enabled more clang-tidy checks #302

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Source/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ Checks: >
performance-implicit-conversion-in-loop,
performance-inefficient-algorithm,
performance-inefficient-string-concatenation,
performance-inefficient-vector-operation
performance-inefficient-vector-operation,
performance-move-const-arg,
performance-move-constructor-init,
performance-no-automatic-move

CheckOptions:
- key: modernize-loop-convert.MinConfidence
Expand Down
2 changes: 1 addition & 1 deletion Source/Config/source/ConfigImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ void ConfigImpl::InsertObserver(std::string_view _path, base::intrusive_ptr<cons
// it's the first request to observe this path
auto new_observers = base::intrusive_ptr{new Observers};
new_observers->observers.emplace_back(std::move(_observer));
m_Observers.emplace(std::move(path), std::move(new_observers));
m_Observers.emplace(path, std::move(new_observers));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
if( !all_of(begin(items), end(items), [=](auto &i) { return i.Host() == host; }) )
return; // currently BatchRenameOperation supports only single host for items

const auto sheet = [[NCOpsBatchRenamingDialog alloc] initWithItems:std::move(items)];
const auto sheet = [[NCOpsBatchRenamingDialog alloc] initWithItems:items];
sheet.renamePatternDataSource =
[[SimpleComboBoxPersistentDataSource alloc] initWithStateConfigPath:g_ConfigPatternsPath];
sheet.searchForDataSource =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
if( !host || path.empty() )
return; // ui invariant is broken

const auto op = std::make_shared<nc::ops::Copying>(std::move(entries), path, host, opts);
const auto op = std::make_shared<nc::ops::Copying>(entries, path, host, opts);

const auto update_both_panels = RefreshBothCurrentControllersLambda(_target);
op->ObserveUnticketed(nc::ops::Operation::NotifyAboutFinish, update_both_panels);
Expand Down Expand Up @@ -237,7 +237,7 @@
if( !host || path.empty() )
return; // ui invariant is broken

const auto op = std::make_shared<nc::ops::Copying>(std::move(entries), path, host, opts);
const auto op = std::make_shared<nc::ops::Copying>(entries, path, host, opts);

const auto update_both_panels = RefreshBothCurrentControllersLambda(_target);
op->ObserveUnticketed(nc::ops::Operation::NotifyAboutFinish, update_both_panels);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,14 @@
const auto operation = BuildOperationForLocal(_source, _destination);
if( operation == NSDragOperationCopy ) {
const auto opts = MakeDefaultFileCopyOptions();
const auto op =
std::make_shared<ops::Copying>(std::move(files), _destination.Path(), _destination.Host(), opts);
const auto op = std::make_shared<ops::Copying>(files, _destination.Path(), _destination.Host(), opts);
AddPanelRefreshIfNecessary(m_Target, *op);
[m_Target.mainWindowController enqueueOperation:op];
return true;
}
else if( operation == NSDragOperationMove ) {
const auto opts = MakeDefaultFileMoveOptions();
const auto op =
std::make_shared<ops::Copying>(std::move(files), _destination.Path(), _destination.Host(), opts);
const auto op = std::make_shared<ops::Copying>(files, _destination.Path(), _destination.Host(), opts);
AddPanelRefreshIfNecessary(m_Target, _source.sourceController, *op);
[m_Target.mainWindowController enqueueOperation:op];
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ - (IBAction)onSearchSettingsUIChanged:(id) [[maybe_unused]] sender

const auto search_fied_value = self.maskSearchField.stringValue;

const auto query = search_fied_value != nil ? std::string(search_fied_value.UTF8String) : std::string{};
auto query = search_fied_value != nil ? std::string(search_fied_value.UTF8String) : std::string{};
if( query.empty() )
return {};
if( m_RegexSearch ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2017-2019 Michael Kazakov. Subject to GNU General Public License version 3.
// Copyright (C) 2017-2024 Michael Kazakov. Subject to GNU General Public License version 3.
#pragma once

#include <VFS/VFS.h>
Expand All @@ -19,7 +19,7 @@ class FileOpener;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithFileOpener:(nc::panel::FileOpener &)_file_opener utiDB:(const nc::utility::UTIDB &)_uti_db;

- (void)setContextSource:(const std::vector<VFSListingItem>)_items;
- (void)setContextSource:(const std::vector<VFSListingItem>&)_items;
- (void)addManagedMenu:(NSMenu *)_menu;

@property(weak, nonatomic) PanelController *target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ + (NSString *)alwaysOpenWithMenuIdentifier
return @"always";
}

- (void)setContextSource:(const std::vector<VFSListingItem>)_items
- (void)setContextSource:(const std::vector<VFSListingItem>&)_items
{
m_ContextItems = std::move(_items);
m_ContextItems = _items;
}

- (BOOL)menuHasKeyEquivalent:(NSMenu *) [[maybe_unused]] _menu
Expand Down
8 changes: 4 additions & 4 deletions Source/Panel/source/ExternalTools.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
void ExternalToolsParameters::InsertCurrentItem(CurrentItem _ci, bool _partial)
{
m_Steps.emplace_back(ActionType::CurrentItem, m_CurrentItems.size(), _partial);
m_CurrentItems.emplace_back(std::move(_ci));
m_CurrentItems.emplace_back(_ci);
}

void ExternalToolsParameters::InsertSelectedItem(SelectedItems _si, bool _partial)
{
m_Steps.emplace_back(ActionType::SelectedItems, m_SelectedItems.size(), _partial);
m_SelectedItems.emplace_back(std::move(_si));
m_SelectedItems.emplace_back(_si);
}

std::span<const ExternalToolsParameters::Step> ExternalToolsParameters::Steps() const noexcept
Expand Down Expand Up @@ -344,10 +344,10 @@
result.InsertValueRequirement(std::move(*val), partial);
}
if( auto val = std::get_if<ExternalToolsParameters::CurrentItem>(&param) ) {
result.InsertCurrentItem(std::move(*val), partial);
result.InsertCurrentItem(*val, partial);
}
if( auto val = std::get_if<ExternalToolsParameters::SelectedItems>(&param) ) {
result.InsertSelectedItem(std::move(*val), partial);
result.InsertSelectedItem(*val, partial);
}
if( auto val = std::get_if<SetMaximumFilesFlag>(&param) ) {
result.m_MaximumTotalFiles = val->maximum;
Expand Down
2 changes: 1 addition & 1 deletion Source/Panel/source/PanelData.mm
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ static void UpdateWithExisingVD(ItemVolatileData &_new_vd, const ItemVolatileDat
throw std::invalid_argument("PanelData::ReLoad: incompatible listing type!");

// put a new data in a place
m_Listing = std::move(_listing);
m_Listing = _listing;
m_VolatileData = std::move(new_vd);
m_EntriesByRawName = std::move(dirbyrawcname);

Expand Down
2 changes: 1 addition & 1 deletion Source/Panel/tests/PanelData_UT.mm
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static VFSListingPtr ProduceDummyListing(const std::vector<std::tuple<std::strin
sorting.sort = data::SortMode::SortByName;
sorting.case_sens = false;
data.SetSortMode(sorting);
data.Load(std::move(listing), data::Model::PanelType::Directory);
data.Load(listing, data::Model::PanelType::Directory);

CHECK(data.SortedIndexForName(listing->Item(0).FilenameC()) == 0);
CHECK(data.SortedIndexForName(listing->Item(2).FilenameC()) == 1);
Expand Down
2 changes: 1 addition & 1 deletion Source/Term/source/ShellTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static std::optional<std::filesystem::path> TryToResolve(const std::filesystem::
if( ec == std::error_code{} && exists ) {
const bool is_symlink = std::filesystem::is_symlink(_path, ec);
if( ec == std::error_code{} && is_symlink ) {
const auto symlink = std::filesystem::read_symlink(_path, ec);
auto symlink = std::filesystem::read_symlink(_path, ec);
if( ec != std::error_code{} )
return {};
if( symlink.is_absolute() )
Expand Down
7 changes: 4 additions & 3 deletions Source/Utility/source/FSEventsFileUpdateImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2021-2023 Michael Kazakov. Subject to GNU General Public License version 3.
// Copyright (C) 2021-2024 Michael Kazakov. Subject to GNU General Public License version 3.
#include "FSEventsFileUpdateImpl.h"
#include <Utility/StringExtras.h>
#include <Utility/Log.h>
Expand Down Expand Up @@ -235,8 +235,9 @@ void FSEventsFileUpdateImpl::KickstartBackgroundScanner()
}
}

dispatch_to_background(
[paths = std::move(paths), context = m_WeakAsyncContext] { BackgroundScanner(std::move(paths), context); });
dispatch_to_background([paths = std::move(paths), context = m_WeakAsyncContext] mutable {
BackgroundScanner(std::move(paths), context);
});
}

void FSEventsFileUpdateImpl::AcceptScannedStats(const std::vector<std::filesystem::path> &_paths,
Expand Down
4 changes: 2 additions & 2 deletions Source/VFS/source/Host.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2013-2023 Michael Kazakov. Subject to GNU General Public License version 3.
// Copyright (C) 2013-2024 Michael Kazakov. Subject to GNU General Public License version 3.
#include <Utility/PathManip.h>
#include "ListingInput.h"
#include "../include/VFS/Host.h"
Expand Down Expand Up @@ -68,7 +68,7 @@ FileObservationToken::FileObservationToken(unsigned long _token, std::weak_ptr<H
}

FileObservationToken::FileObservationToken(FileObservationToken &&_rhs) noexcept
: m_Token{_rhs.m_Token}, m_Host{_rhs.m_Host}
: m_Token{_rhs.m_Token}, m_Host{std::move(_rhs.m_Host)}
{
_rhs.m_Token = 0;
_rhs.m_Host.reset();
Expand Down
2 changes: 1 addition & 1 deletion Source/VFS/source/PS/Host.mm
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ static void print_argv_of_pid(int pid, std::string &_out)
auto procs = GetProcs();
if( !m_UpdateQ.IsStopped() ) {
auto me = weak_this;
dispatch_to_main_queue([=, procs = std::move(procs)] {
dispatch_to_main_queue([=, procs = std::move(procs)] mutable {
if( !me.expired() )
me.lock()->CommitProcs(std::move(procs));
});
Expand Down
6 changes: 3 additions & 3 deletions Source/Viewer/source/Highlighting/Client.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (C) 2024 Michael Kazakov. Subject to GNU General Public License version 3.
#include <Base/algo.h>
#include <Viewer/Highlighting/Client.h>
#include <Viewer/Log.h>
#include <Base/algo.h>
#include <xpc/xpc.h>
#include <assert.h>
#include <cassert>
#include <thread>
#include <xpc/xpc.h>

namespace nc::viewer::hl {

Expand Down
4 changes: 2 additions & 2 deletions Source/Viewer/source/Highlighting/Document.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (C) 2024 Michael Kazakov. Subject to GNU General Public License version 3.
#include <Viewer/Highlighting/Document.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cstdlib>
#include <iostream>
#include <assert.h>

namespace nc::viewer::hl {

Expand Down
21 changes: 11 additions & 10 deletions Source/Viewer/source/Highlighting/Highlighter.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// Copyright (C) 2024 Michael Kazakov. Subject to GNU General Public License version 3.
#include <Viewer/Highlighting/Highlighter.h>
#include <Viewer/Highlighting/Document.h>
#include <assert.h>
#include <lexilla/Lexilla.h>
#include <lexilla/WordList.h>
#include <lexilla/LexAccessor.h>
#include <lexilla/Accessor.h>
#include <lexilla/CharacterSet.h>
#include <lexilla/LexerModule.h>
#include <lexilla/CatalogueModules.h>
#include <lexilla/SciLexer.h>
#include <Viewer/Highlighting/Highlighter.h>
#include <cassert>
#include <fmt/format.h>

#include <lexilla/Lexilla.h> // NOLINT
#include <lexilla/WordList.h> // NOLINT
#include <lexilla/LexAccessor.h> // NOLINT
#include <lexilla/Accessor.h> // NOLINT
#include <lexilla/CharacterSet.h> // NOLINT
#include <lexilla/LexerModule.h> // NOLINT
#include <lexilla/CatalogueModules.h> // NOLINT
#include <lexilla/SciLexer.h> // NOLINT

namespace nc::viewer::hl {

Highlighter::Highlighter(LexerSettings _settings) : m_Settings(std::move(_settings))
Expand Down
11 changes: 6 additions & 5 deletions Source/Viewer/source/Highlighting/Service.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
// Copyright (C) 2024 Michael Kazakov. Subject to GNU General Public License version 3.
#include <Viewer/Highlighting/LexerSettings.h>
#include <Viewer/Highlighting/Highlighter.h>
#include <span>
#include <optional>
#include <Viewer/Highlighting/LexerSettings.h> // NOLINT
#include <Viewer/Highlighting/Highlighter.h> // NOLINT

#include <cstdio>
#include <fmt/format.h>
#include <stdio.h>
#include <optional>
#include <span>
#include <xpc/xpc.h>

static void send_reply_error(xpc_connection_t _peer, xpc_object_t _from_event, const std::string &_error_msg) noexcept
Expand Down
6 changes: 3 additions & 3 deletions Source/Viewer/source/TextModeWorkingSetHighlighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#include "TextModeWorkingSetHighlighting.h"
#include "Highlighting/Client.h"
#include "Log.h"
#include <fmt/chrono.h>
#include <Utility/Encodings.h>
#include <Base/dispatch_cpp.h>
#include <Utility/Encodings.h>
#include <cassert>
#include <fmt/chrono.h>
#include <stdexcept>
#include <assert.h>

namespace nc::viewer {

Expand Down
4 changes: 2 additions & 2 deletions Source/Viewer/tests/hlHighlighter_UT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ TEST_CASE(PREFIX "Regular use with C++ lexer")
{
LexerSettings set;
set.name = "cpp";
set.wordlists.push_back("int");
set.wordlists.emplace_back("int");
set.mapping.SetMapping(SCE_C_DEFAULT, Style::Default);
set.mapping.SetMapping(SCE_C_COMMENT, Style::Comment);
set.mapping.SetMapping(SCE_C_COMMENTLINE, Style::Comment);
Expand Down Expand Up @@ -95,7 +95,7 @@ TEST_CASE(PREFIX "Regular use with Bash lexer")
{
LexerSettings set;
set.name = "bash";
set.wordlists.push_back("set if command then echo exit fi export");
set.wordlists.emplace_back("set if command then echo exit fi export");
set.mapping.SetMapping(SCE_SH_DEFAULT, Style::Default);
set.mapping.SetMapping(SCE_SH_ERROR, Style::Default);
set.mapping.SetMapping(SCE_SH_COMMENTLINE, Style::Comment);
Expand Down
Loading