Skip to content

Commit

Permalink
Merge pull request #564 from vizzuhq/clang-tidy-fixes
Browse files Browse the repository at this point in the history
Fix clang-tidy(-18) issues
  • Loading branch information
schaumb authored Aug 12, 2024
2 parents ef7a0e4 + cdd4dde commit 115668e
Show file tree
Hide file tree
Showing 139 changed files with 1,238 additions and 457 deletions.
5 changes: 3 additions & 2 deletions project/cmake/common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(sourceDir ${root}/src)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
Expand Down Expand Up @@ -63,11 +64,11 @@ if (cpplint)
endif()

if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20 /Zi /GR-")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi /GR-")
add_definitions(-D_USE_MATH_DEFINES)
set(CMAKE_SHARED_LINKER_FLAGS "/INCREMENTAL:NO /Debug")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 \
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-Wpedantic \
-Wall \
-Wextra \
Expand Down
12 changes: 9 additions & 3 deletions src/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Checks: >
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-special-member-functions,
fuchsia-statically-constructed-objects,
fuchsia-trailing-return,
google-build-using-namespace,
google-default-arguments,
google-explicit-constructor,
Expand All @@ -48,10 +47,10 @@ Checks: >
-readability-identifier-length,
-readability-implicit-bool-conversion,
-readability-magic-numbers,
-readability-named-parameter
-readability-named-parameter,
-readability-redundant-member-init
WarningsAsErrors: '*,-readability-function-size,-readability-function-cognitive-complexity,-misc-no-recursion'
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: none
User: simon
CheckOptions:
Expand Down Expand Up @@ -375,5 +374,12 @@ CheckOptions:
value: '0'
- key: readability-simplify-subscript-expr.Types
value: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array'
- key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams
value: 'true'
- key: cppcoreguidelines-rvalue-reference-param-not-moved.AllowPartialMove
value: 'true'
- key: misc-include-cleaner.IgnoreHeaders
value: (.*\.tpp)

...

86 changes: 46 additions & 40 deletions src/apps/weblib/cinterface.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
#include "cinterface.h"

#include <cstddef>
#include <cstdint>
#include <exception>
#include <functional>
#include <limits>
#include <new>
#include <optional>
#include <stdexcept>
#include <string>
#include <string_view>
#include <typeinfo>
#include <variant>

#include "interface.h"

using Vizzu::Interface;
Expand All @@ -17,7 +30,8 @@ constexpr std::uint_fast32_t hash(std::string_view s) noexcept

for (size_t i = 0; i < s.size(); ++i)
val ^= static_cast<std::uint_fast32_t>(s[i])
<< ((i % sizeof(std::uint_fast32_t)) * CHAR_BIT);
<< ((i % sizeof(std::uint_fast32_t))
* std::numeric_limits<unsigned char>::digits);

return val;
}
Expand Down Expand Up @@ -90,6 +104,7 @@ const char *vizzu_errorMessage(APIHandles::Exception exceptionPtr,
static_cast<const std::bad_variant_access *>(
exceptionPtr);
break;
default: break;
}

if (realException) return realException->what();
Expand All @@ -106,10 +121,7 @@ const char *vizzu_errorMessage(APIHandles::Exception exceptionPtr,

const char *vizzu_version() { return Interface::version(); }

void vizzu_setLogging(bool enable)
{
return Interface::setLogging(enable);
}
void vizzu_setLogging(bool enable) { Interface::setLogging(enable); }

APIHandles::Chart vizzu_createChart()
{
Expand All @@ -127,7 +139,7 @@ void vizzu_pointerMove(APIHandles::Chart chart,
double x,
double y)
{
return Interface::getInstance().pointerMove(chart,
Interface::getInstance().pointerMove(chart,
canvas,
pointerId,
x,
Expand All @@ -140,7 +152,7 @@ void vizzu_pointerDown(APIHandles::Chart chart,
double x,
double y)
{
return Interface::getInstance().pointerDown(chart,
Interface::getInstance().pointerDown(chart,
canvas,
pointerId,
x,
Expand All @@ -153,7 +165,7 @@ void vizzu_pointerUp(APIHandles::Chart chart,
double x,
double y)
{
return Interface::getInstance().pointerUp(chart,
Interface::getInstance().pointerUp(chart,
canvas,
pointerId,
x,
Expand All @@ -164,16 +176,14 @@ void vizzu_pointerLeave(APIHandles::Chart chart,
APIHandles::Canvas canvas,
int pointerId)
{
return Interface::getInstance().pointerLeave(chart,
canvas,
pointerId);
Interface::getInstance().pointerLeave(chart, canvas, pointerId);
}

void vizzu_wheel(APIHandles::Chart chart,
APIHandles::Canvas canvas,
double delta)
{
return Interface::getInstance().wheel(chart, canvas, delta);
Interface::getInstance().wheel(chart, canvas, delta);
}

void vizzu_update(APIHandles::Chart chart, double timeInMSecs)
Expand All @@ -186,10 +196,7 @@ void vizzu_render(APIHandles::Chart chart,
double width,
double height)
{
return Interface::getInstance().render(chart,
canvas,
width,
height);
Interface::getInstance().render(chart, canvas, width, height);
}

void vizzu_setLineResolution(APIHandles::Canvas canvas,
Expand All @@ -207,7 +214,7 @@ void style_setValue(APIHandles::Chart chart,
const char *path,
const char *value)
{
return Interface::getInstance().setStyleValue(chart, path, value);
Interface::getInstance().setStyleValue(chart, path, value);
}

const char *style_getValue(APIHandles::Chart chart,
Expand All @@ -227,7 +234,7 @@ APIHandles::Snapshot chart_store(APIHandles::Chart chart)
void chart_restore(APIHandles::Chart chart,
APIHandles::Snapshot snapshot)
{
return Interface::getInstance().restoreChart(chart, snapshot);
Interface::getInstance().restoreChart(chart, snapshot);
}

APIHandles::Animation chart_anim_store(APIHandles::Chart chart)
Expand All @@ -238,12 +245,12 @@ APIHandles::Animation chart_anim_store(APIHandles::Chart chart)
void chart_anim_restore(APIHandles::Chart chart,
APIHandles::Animation anim)
{
return Interface::getInstance().restoreAnim(chart, anim);
Interface::getInstance().restoreAnim(chart, anim);
}

void object_free(APIHandles::Any handle)
{
return Interface::getInstance().freeObj(handle);
Interface::getInstance().freeObj(handle);
}

const char *chart_getList() { return Interface::getChartParamList(); }
Expand All @@ -257,29 +264,32 @@ void chart_setValue(APIHandles::Chart chart,
const char *path,
const char *value)
{
return Interface::getInstance().setChartValue(chart, path, value);
Interface::getInstance().setChartValue(chart, path, value);
}

void chart_setFilter(APIHandles::Chart chart,
bool (*filter)(const Vizzu::Data::RowWrapper *),
void (*deleter)(bool (*)(const Vizzu::Data::RowWrapper *)))
{
return Interface::getInstance().setChartFilter(chart,
{filter, deleter});
Interface::getInstance().setChartFilter(chart, {filter, deleter});
}

const Value *record_getValue(const Vizzu::Data::RowWrapper *record,
const char *column)
{
thread_local Value val{{}, {}};
if (auto &&cval = Interface::getRecordValue(*record, column);
(val.dimension = cval.index())) {
cval.index()) {
val.dimension = true;
auto &&dim = *std::get_if<const std::string *>(&cval);
new (&val.dimensionValue)
new (
&val.dimensionValue) // NOLINT(bugprone-multi-level-implicit-pointer-conversion)
const char *{dim ? dim->c_str() : nullptr};
}
else
else {
val.dimension = false;
new (&val.measureValue) double{*std::get_if<double>(&cval)};
}
return &val;
}

Expand All @@ -290,7 +300,7 @@ void data_addDimension(APIHandles::Chart chart,
const std::uint32_t *categoryIndices,
std::uint32_t categoryIndicesCount)
{
return Interface::getInstance().addDimension(chart,
Interface::getInstance().addDimension(chart,
name,
categories,
categoriesCount,
Expand All @@ -304,7 +314,7 @@ void data_addMeasure(APIHandles::Chart chart,
const double *values,
std::uint32_t count)
{
return Interface::getInstance().addMeasure(chart,
Interface::getInstance().addMeasure(chart,
name,
unit,
values,
Expand All @@ -315,7 +325,7 @@ void data_addRecord(APIHandles::Chart chart,
const char *const *cells,
std::uint32_t count)
{
return Interface::getInstance().addRecord(chart, cells, count);
Interface::getInstance().addRecord(chart, cells, count);
}

const char *data_metaInfo(APIHandles::Chart chart)
Expand All @@ -327,28 +337,26 @@ void addEventListener(APIHandles::Chart chart,
const char *name,
void (*callback)(APIHandles::Event event, const char *))
{
return Interface::getInstance().addEventListener(chart,
name,
callback);
Interface::getInstance().addEventListener(chart, name, callback);
}

void removeEventListener(APIHandles::Chart chart,
const char *name,
void (*callback)(APIHandles::Event event, const char *))
{
return Interface::getInstance().removeEventListener(chart,
Interface::getInstance().removeEventListener(chart,
name,
callback);
}

void event_preventDefault(APIHandles::Event event)
{
return Interface::preventDefaultEvent(event);
Interface::preventDefaultEvent(event);
}

void chart_animate(APIHandles::Chart chart, void (*callback)(bool))
{
return Interface::getInstance().animate(chart, callback);
Interface::getInstance().animate(chart, callback);
}

const Point *
Expand Down Expand Up @@ -377,16 +385,14 @@ chart_canvasToRelCoords(APIHandles::Chart chart, double x, double y)

void chart_setKeyframe(APIHandles::Chart chart)
{
return Interface::getInstance().setKeyframe(chart);
Interface::getInstance().setKeyframe(chart);
}

void anim_control_setValue(APIHandles::Chart chart,
const char *path,
const char *value)
{
return Interface::getInstance().setAnimControlValue(chart,
path,
value);
Interface::getInstance().setAnimControlValue(chart, path, value);
}

const char *anim_control_getValue(APIHandles::Chart chart,
Expand All @@ -399,5 +405,5 @@ void anim_setValue(APIHandles::Chart chart,
const char *path,
const char *value)
{
return Interface::getInstance().setAnimValue(chart, path, value);
Interface::getInstance().setAnimValue(chart, path, value);
}
Loading

0 comments on commit 115668e

Please sign in to comment.