Fix clang-tidy warnings

This commit is contained in:
IRBorisov 2024-05-06 18:13:24 +03:00
parent de81d4037f
commit 97614cc3bf
24 changed files with 108 additions and 91 deletions

View File

@ -1,40 +1,44 @@
Checks: "*,\
-altera-id-dependent-backward-branch,\
-altera-struct-pack-align,\
-altera-unroll-loops,\
-altera-id-dependent-backward-branch,\
-llvmlibc-callee-namespace,\
-llvmlibc-restrict-system-libc-headers,\
-llvmlibc-implementation-in-namespace,\
-llvmlibc-inline-function-decl,\
-bugprone-branch-clone,\
-bugprone-easily-swappable-parameters,\
-bugprone-suspicious-include,\
-bugprone-exception-escape,\
-cppcoreguidelines-avoid-const-or-ref-data-members,\
-cppcoreguidelines-avoid-do-while,\
-cppcoreguidelines-non-private-member-variables-in-classes,\
-cppcoreguidelines-prefer-member-initializer,\
-cppcoreguidelines-special-member-functions,\
-fuchsia-default-arguments,\
-fuchsia-default-arguments-calls,\
-fuchsia-default-arguments-declarations,\
-fuchsia-multiple-inheritance,\
-fuchsia-overloaded-operator,\
-fuchsia-statically-constructed-objects,\
-fuchsia-trailing-return,\
-google-global-names-in-headers,\
-google-readability-todo,\
-google-runtime-references,\
-hicpp-special-member-functions,\
-llvm-else-after-return,\
-llvm-header-guard,\
-llvm-include-order,\
-bugprone-branch-clone,\
-bugprone-suspicious-include,\
-bugprone-easily-swappable-parameters,\
-llvmlibc-callee-namespace,\
-llvmlibc-implementation-in-namespace,\
-llvmlibc-inline-function-decl,\
-llvmlibc-restrict-system-libc-headers,\
-misc-include-cleaner,\
-misc-no-recursion,\
-misc-non-private-member-variables-in-classes,\
-modernize-use-trailing-return-type,\
-hicpp-special-member-functions,\
-google-runtime-references,\
-fuchsia-overloaded-operator,\
-fuchsia-default-arguments,\
-google-readability-todo,\
-google-global-names-in-headers,\
-readability-redundant-access-specifiers,\
-readability-redundant-member-init,\
-readability-else-after-return,\
-readability-implicit-bool-conversion,\
-readability-use-anyofallof,\
-readability-identifier-length,\
-performance-inefficient-string-concatenation,\
-performance-unnecessary-value-param,\
-fuchsia-default-arguments-declarations,\
-fuchsia-trailing-return,\
-fuchsia-multiple-inheritance,\
-fuchsia-default-arguments-calls,\
-misc-non-private-member-variables-in-classes,\
-misc-no-recursion,\
-misc-include-cleaner,\
-cppcoreguidelines-special-member-functions,\
-cppcoreguidelines-prefer-member-initializer,\
-cppcoreguidelines-avoid-const-or-ref-data-members,\
-cppcoreguidelines-non-private-member-variables-in-classes"
-readability-else-after-return,\
-readability-function-cognitive-complexity,\
-readability-identifier-length,\
-readability-implicit-bool-conversion,\
-readability-redundant-access-specifiers,\
-readability-redundant-member-init,\
-readability-use-anyofallof"

View File

@ -1,9 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="VSCustom.ruleset" />
<None Include="Jenkinsfile.groovy" />
</ItemGroup>
<ItemGroup>
<Filter Include="Graph">
<UniqueIdentifier>{f0a3dd37-e5ae-4a37-ab65-d574c8dfe252}</UniqueIdentifier>
@ -20,7 +16,4 @@
<Filter>Graph</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
</Project>

View File

@ -298,7 +298,7 @@ CGraph::ItemsGroup CGraph::GetAllLoopsItems() const {
}
}
if (size(component) != 1 || HasEdge(index, index)) {
result.push_back({});
result.emplace_back();
result.back().reserve(size(component));
for (const auto item : component) {
result.back().emplace(graph[item].uid);

View File

@ -64,7 +64,8 @@ namespace {
[[nodiscard]] UTF8Iterator ReferenceStart(const std::string_view refStr, const StrPos start) noexcept {
for (auto iter = UTF8Iterator(refStr, start); iter != UTF8End(refStr); ++iter) {
if (*iter == '@') {
if (++iter == UTF8End(refStr) || *iter == '{') {
++iter;
if (iter == UTF8End(refStr) || *iter == '{') {
return iter;
}
}

View File

@ -160,7 +160,7 @@ std::string RefsManager::OutputRefs(const std::string& normStr, const StrRange s
auto finish = subRange.finish;
for (const auto& ref : refs) {
const auto intersection = subRange.Intersect(ref.position);
if (!intersection.has_value() || intersection->length() == 0) {
if (!intersection.has_value() || intersection->empty()) {
if (subRange.IsBefore(ref.position)) {
break;
}

View File

@ -16,10 +16,19 @@ struct RSConcept {
std::string definition{};
std::string convention{};
explicit RSConcept(const EntityUID entity, std::string alias, const CstType type = CstType::base,
std::string definition = {}, std::string convention = {}) noexcept
: uid{ entity }, alias{ std::move(alias) }, type{ type },
definition{ std::move(definition) }, convention{ std::move(convention) } {}
explicit RSConcept(
const EntityUID entity,
std::string alias,
const CstType type = CstType::base,
std::string definition = {},
std::string convention = {}
) noexcept :
uid{ entity },
alias{ std::move(alias) },
type{ type },
definition{ std::move(definition) },
convention{ std::move(convention) }
{}
RSConcept() = default;

View File

@ -81,7 +81,7 @@ public:
[[nodiscard]] change::Hash FullHash() const;
private:
[[nodiscard]] inline bool NotifyAndReturn(const bool result) {
[[nodiscard]] bool NotifyAndReturn(const bool result) {
if (result) {
NotifyModification();
}

View File

@ -71,7 +71,7 @@ public:
void UpdateState();
private:
[[nodiscard]] inline bool NotifyAndReturn(const bool result) {
[[nodiscard]] bool NotifyAndReturn(const bool result) {
if (result) {
NotifyModification();
}

View File

@ -17,17 +17,20 @@ bool EquationOptions::IsEqualTo(const Options& opt2) const {
bool EquationOptions::SwapKeyVal(const EntityUID key) {
if (!ContainsKey(key)) {
return false;
} else if (const auto val = translation(key); ContainsKey(translation(key))) {
}
const auto newKey = translation(key);
if (ContainsKey(newKey)) {
return false;
} else {
}
Equation props = properties[key];
if (props.mode != Equation::Mode::createNew) {
props.mode = props.mode == Equation::Mode::keepHier ? Equation::Mode::keepDel : Equation::Mode::keepHier;
}
Erase(key);
Insert(val, key, props);
const auto newValue = key;
Insert(newKey, newValue, props);
return true;
}
}
const Equation& EquationOptions::PropsFor(const EntityUID key) const {

View File

@ -126,8 +126,12 @@ void OSSchema::SetPictLink(const PictID target, const MediaLink& lnk) {
}
}
const Pict& OSSchema::LoadPict(Pict&& pict, GridPosition pos, const src::Handle& handle,
std::unique_ptr<OperationHandle> params) {
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
const Pict& OSSchema::LoadPict(
Pict&& pict, GridPosition pos,
const src::Handle& handle,
std::unique_ptr<OperationHandle> params
) {
if (Grid()(pos).has_value()) {
pos = Grid().ClosestFreePos(pos);
}
@ -149,10 +153,12 @@ PictPtr OSSchema::InsertOperation(const PictID operand1, const PictID operand2)
graph->AddItem(newID, { operand1, operand2 });
const auto newPos = Grid().ChildPosFor(operand1, operand2);
InsertInternal(Pict{ newID },
InsertInternal(
Pict{ newID },
newPos,
src::Handle{ src::SrcType::rsDoc },
std::make_unique<OperationHandle>());
std::make_unique<OperationHandle>()
);
NotifyModification();
return &storage.at(newID);
@ -168,9 +174,12 @@ PictPtr OSSchema::InsertBase() {
return &storage.at(newID);
}
void OSSchema::InsertInternal(const Pict& pict, GridPosition pos,
void OSSchema::InsertInternal(
const Pict& pict,
GridPosition pos,
const src::Handle& srcHandle,
std::unique_ptr<OperationHandle> opHandle) {
std::unique_ptr<OperationHandle> opHandle
) {
const auto pid = pict.uid;
idGen.AddUID(pid);

View File

@ -119,7 +119,7 @@ std::optional<size_t> ossGraphFacet::FindItemIndex(const PictID item) const {
}
size_t ossGraphFacet::InsertKeyValue(const PictID item) {
graph.emplace_back(std::vector<size_t>{});
graph.emplace_back();
items.emplace_back(item);
return size(items) - 1U;
}

View File

@ -216,9 +216,12 @@ ops::Result ossOperationsFacet::CreateNewResult(const PictID pid) {
return opResult;
}
bool ossOperationsFacet::SaveOperationResult(const PictID pid,
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
bool ossOperationsFacet::SaveOperationResult(
const PictID pid,
const EntityTranslation& old2New,
ops::Result&& opResult) {
ops::Result&& opResult
) {
auto& opHandle = operations.at(pid);
assert(opHandle != nullptr);
const auto guard = core.DndGuard();

View File

@ -87,6 +87,7 @@ EntityUID RSCore::Emplace(const CstType type, const std::string& definition) {
return newID.uid;
}
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
EntityUID RSCore::Insert(ConceptRecord&& cst) {
RSConcept newRS{cst.uid, cst.alias, cst.type, std::move(cst.rs), std::move(cst.convention) };
TextConcept newText{cst.uid, cst.alias, std::move(cst.term), std::move(cst.definition) };
@ -213,6 +214,7 @@ VectorOfEntities RSCore::InsertCopy(const std::vector<ConceptRecord>& input) {
return result;
}
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
EntityUID RSCore::Load(ConceptRecord&& cst) {
RSConcept newRS{ cst.uid, cst.alias, cst.type, std::move(cst.rs), std::move(cst.convention) };
TextConcept newText{ cst.uid, cst.alias, std::move(cst.term), std::move(cst.definition) };

View File

@ -172,7 +172,8 @@ void rsValuesFacet::PruneStructure(const EntityUID target) {
}
const auto& typeValue = core.GetParse(target).exprType;
assert(typeValue.has_value());
const auto& type = std::get<rslang::Typification>(typeValue.value()); // NOLINT(bugprone-exception-escape)
// NOLINTNEXTLINE(bugprone-exception-escape, bugprone-unchecked-optional-access)
const auto& type = std::get<rslang::Typification>(typeValue.value());
if (!oldData->IsCollection()) {
if (!CheckBasicElements(oldData.value(), type)) {
storage->Erase(target);

View File

@ -46,7 +46,7 @@
<ClCompile Include="unity\reflex_unity2.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="src\RSParserImpl.y"/>
<None Include="src\RSParserImpl.y" />
<None Include="src\AsciiLexerImpl.l" />
<None Include="src\MathLexerImpl.l" />
</ItemGroup>

View File

@ -207,10 +207,6 @@
<None Include="src\MathLexerImpl.l">
<Filter>11 parse\lexer</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Bison Include="src\RSParserImpl.y">
<Filter>11 parse\parser</Filter>
</Bison>
<None Include="src\RSParserImpl.y" />
</ItemGroup>
</Project>

View File

@ -18,7 +18,7 @@ enum class Syntax : uint8_t {
};
//! RS language token types enumeration
enum class TokenID : uint32_t {
enum class TokenID : uint32_t { // NOLINT(performance-enum-size)
// Global, local IDs and literals
ID_LOCAL = 258,
ID_GLOBAL,

View File

@ -92,7 +92,7 @@ std::string Normalizer::CreateTupleName(const SyntaxTree::Node& root) {
std::stack<const SyntaxTree::Node*> nodeStack{};
std::stack<std::vector<Index>> pathStack{};
nodeStack.push(&root);
pathStack.push({});
pathStack.emplace();
while (!std::empty(nodeStack)) {
auto curPath = pathStack.top();
pathStack.pop();

View File

@ -1,5 +1,3 @@
#pragma once
#include "ccl/rslang/Auditor.h"
namespace ccl::rslang {

View File

@ -1,5 +1,3 @@
#pragma once
#include "ccl/rslang/Interpreter.h"
#include <optional>

View File

@ -42,7 +42,7 @@ using Description = Generator::StructureDescription;
return {};
}
const auto& newName = substitutes.at(argName);
argsTypes.emplace_back(TypedID{ newName, std::get<Typification>(*type) });
argsTypes.emplace_back(newName, std::get<Typification>(*type));
}
return Generator::CreatePrefix(argsTypes);
}

View File

@ -63,7 +63,7 @@ SDCompact::Header SDCompact::CreateHeader(const Typification& type) {
result.push_back(host.E().baseID); break;
case rslang::StructureType::collection:
result.push_back("B"); break;
result.emplace_back("B"); break;
case rslang::StructureType::tuple:
break;

View File

@ -223,8 +223,8 @@ std::optional<SyntaxTree::Cursor> FindMinimalNode(SyntaxTree::Cursor root, StrRa
} else {
root.MoveToChild(0);
do {
if (const auto result = FindMinimalNode(root, range);
result.has_value()) {
const auto result = FindMinimalNode(root, range);
if (result.has_value()) {
return result;
}
} while (root.MoveToNextSibling());