Skip to content

Commit

Permalink
applied pre-commit on entire repo
Browse files Browse the repository at this point in the history
  • Loading branch information
koniarik committed Apr 9, 2023
1 parent 554b640 commit f95973e
Show file tree
Hide file tree
Showing 22 changed files with 59 additions and 58 deletions.
3 changes: 1 addition & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
Checks: >
Checks: >
-*,
bugprone*,-bugprone-easily-swappable-parameters,-bugprone-macro-parentheses,-bugprone-exception-escape,
concurrency*,
Expand Down Expand Up @@ -54,4 +54,3 @@ CheckOptions:
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
...

2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ jobs:
sonar-scanner \
--define sonar.host.url="${{ env.SONAR_SERVER_URL }}" \
--define sonar.cfamily.build-wrapper-output="${{ env.BUILD_WRAPPER_OUT_DIR }}" \
--define sonar.coverageReportPaths=coverage.xml
--define sonar.coverageReportPaths=coverage.xml
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
deploy:
runs-on: ubuntu-22.04
runs-on: ubuntu-22.04
steps:
- name: Install graphviz
run: sudo apt install graphviz
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push]

jobs:
test:
runs-on: ubuntu-22.04
runs-on: ubuntu-22.04

defaults:
run:
Expand All @@ -13,7 +13,7 @@ jobs:
env:
CC: gcc-11
CXX: g++-11

steps:
- uses: actions/checkout@v2

Expand All @@ -22,9 +22,9 @@ jobs:

- name: Test
run: make test

- name: Test under address sanitizer
run: make test SANITIZER=address

- name: Test under undefined sanitizer
run: make test SANITIZER=undefined
6 changes: 1 addition & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: "^(build)"
exclude: "^(build|tests\/third-party|.doxygen\/)"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
Expand All @@ -9,10 +9,6 @@ repos:
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v15.0.4
hooks:
- id: clang-format
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.10
hooks:
Expand Down
4 changes: 2 additions & 2 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ HTML_STYLESHEET =
# list). For an example see the documentation.
# This tag requires that the tag GENERATE_HTML is set to YES.

HTML_EXTRA_STYLESHEET = .doxygen/doxygen-awesome-css/doxygen-awesome.css
HTML_EXTRA_STYLESHEET = .doxygen/doxygen-awesome-css/doxygen-awesome.css

# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note
Expand Down Expand Up @@ -1927,7 +1927,7 @@ LATEX_FOOTER =
# list).
# This tag requires that the tag GENERATE_LATEX is set to YES.

LATEX_EXTRA_STYLESHEET =
LATEX_EXTRA_STYLESHEET =

# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the LATEX_OUTPUT output
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ include-what-you-use:
cmake --build build/iwyu

clang-tidy:
cmake -Bbuild/clang-tidy -DEMLABCPP_TESTS_ENABLED=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_CLANG_TIDY=clang-tidy
cmake -Bbuild/clang-tidy -DEMLABCPP_TESTS_ENABLED=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCMAKE_CXX_CLANG_TIDY=clang-tidy
cmake --build build/clang-tidy

clang-format:
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Tests](https://github.com/koniarik/emlabcpp/actions/workflows/tests.yml/badge.svg)](https://github.com/koniarik/emlabcpp/actions/workflows/tests.yml)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nlohmann/json/master/LICENSE.MIT)

An opinionated C++20 library focusing on embedded development.
An opinionated C++20 library focusing on embedded development.
It provides a wide set of tools, from complex mechanisms (protocol library) to simple utilites (view).
More details in [Documentation](https://koniarik.github.io/emlabcpp/index.html)

Expand All @@ -31,7 +31,7 @@ More details in [Documentation](https://koniarik.github.io/emlabcpp/index.html)
- [zip.h](#ziph)

## Installation
Repository is at https://github.com/koniarik/emlabcpp
Repository is at https://github.com/koniarik/emlabcpp
The prefered of getting the library for now is via fetchcontent:

```cmake
Expand All @@ -48,7 +48,7 @@ The library can be view as a set of components.
These are organized based on the root header file for the said component.

### algorithm.h
Contains a set of algorithms similar to \<algorithm\> standard library, with a major change.
Contains a set of algorithms similar to \<algorithm\> standard library, with a major change.
Functions take as an argument a container itself, rather than iterators.
Most of the functions are also able to work with `std::tuple`.
This is expanded with other short functions representing simple algorithms.
Expand Down Expand Up @@ -162,7 +162,7 @@ Outputs `FOO` if `magic_enum` is enabled and `0` otherwise.

### iterator.h

Contains `generic_iterator<Derived>` CRTP baseclass.
Contains `generic_iterator<Derived>` CRTP baseclass.
This simplifies implementation of custom iterators, as most of the methods/operators we expect of iterators can be implemented based on a small set of functions. (operator+, operator++(int), operator++ can be implemetned with operator+=)

For implementing iterator, you only provide the basic subset for this class and it takes care of the rest.
Expand Down Expand Up @@ -207,7 +207,7 @@ struct foo{
std::vector<foo> vec_data;

auto acview = access_view(vec_data,
[](const foo& item) -> const std::string& {
[](const foo& item) -> const std::string& {
return item.attr;
});

Expand Down
25 changes: 14 additions & 11 deletions cmake/util.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
#
# Copyright (C) 2020 Jan Veverak Koniarik
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial
# portions of the Software.
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
# OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#

find_program(
Expand Down
4 changes: 2 additions & 2 deletions doc/adr/0003-standard-limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Library still can use techniques outside of the defined limits, but all that usa
For the extra facilities, the library can use of two approaches to avoid affecting standard usage:
- Make the concrete functionality conditional with usage of preprocessor defines (for example: EMLABCPP_USE_DEMANGLING define allows usage of demangling facility of the compiler)
- Clearly separate the extra functionality into separate file (library provides custom allocator/memory_resource concept, one of the memory resources uses new/delete and is in separate file)

In case preprocessor defines are used:
- The functionality is disabled by default
- The preprocessor define enables the functionality if defined, disabled otherwise
Expand All @@ -29,7 +29,7 @@ The exact limitations should be defined in other ADR records.

## Consequences

The benefit of this decision is that the "standard usage" of the library should be compatible with wide spectrum of embedded environments/setup.
The benefit of this decision is that the "standard usage" of the library should be compatible with wide spectrum of embedded environments/setup.

In case it is wanted by the user, there is still abillity to provide/use the advanced capabilities, user just has to explicitly enable it.

Expand Down
2 changes: 1 addition & 1 deletion doc/adr/0005-exceptions-shall-not-be-necessary.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ There are multiple motivations for avoiding exceptions that might arise:
- The opinion that they might lead to less stable/robust system, compared to explicit error handling
- Implementation of exceptions might use dynamic memory

And there are corner case problems, such as:
And there are corner case problems, such as:
In case exceptions are used, the system has to have default exception handler for std::terminate which might by called by exceptions. `gcc-arm-none-eabi` provides default handler that brings in C++ type name demangling capability, which results in +-30kbytes of code in the binary. (Which is a LOT for embedded)
The way to avoid is to override the function that gcc uses for this, which is not optimal.

Expand Down
6 changes: 3 additions & 3 deletions include/emlabcpp/concepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ concept container_invocable = requires( Container cont, UnaryCallable f )
}
|| requires( Container cont, UnaryCallable f )
{
/// this has to come after the size check, as gcc 10.2 will faill to compile the code using
/// this concept otherwise. If container is std::tuple<> and this check comes before the
/// size one, it fails on std::get<0> being not compailable.
/// this has to come after the size check, as gcc 10.2 will faill to compile the code
/// using this concept otherwise. If container is std::tuple<> and this check comes
/// before the size one, it fails on std::get<0> being not compailable.
f( std::get< 0 >( cont ) );
};

Expand Down
2 changes: 1 addition & 1 deletion include/emlabcpp/experimental/testing/coroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
namespace emlabcpp::testing
{

using test_coroutine = coro::recursive_coroutine<void>;
using test_coroutine = coro::recursive_coroutine< void >;

} // namespace emlabcpp::testing
4 changes: 2 additions & 2 deletions include/emlabcpp/pid.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ float update( pid< TimeType >& pid, TimeType now, float measured, float desired
pid.i_sum = std::clamp( pid.i_sum, pid.cfg.limits.min, pid.cfg.limits.max );

const float measured_diff = ( measured - pid.last_measured ) / t_diff;
pid.output = coeff.p * error + pid.i_sum - coeff.d * measured_diff;
pid.output = std::clamp( pid.output, pid.cfg.limits.min, pid.cfg.limits.max );
pid.output = coeff.p * error + pid.i_sum - coeff.d * measured_diff;
pid.output = std::clamp( pid.output, pid.cfg.limits.min, pid.cfg.limits.max );

pid.last_measured = measured;
pid.last_time = now;
Expand Down
6 changes: 3 additions & 3 deletions include/emlabcpp/protocol/packet_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ struct packet_handler
return sub_handler::extract( msg ).bind_left(
[&msg]( std::tuple< prefix_type, value_type, checksum_type > pack )
-> either< value_type, error_record > {
const checksum_type present_checksum = std::get< 2 >( pack );
const std::size_t checksum_pos = msg.size() - checksum_size;
const checksum_type calculated_checksum =
const checksum_type present_checksum = std::get< 2 >( pack );
const std::size_t checksum_pos = msg.size() - checksum_size;
const checksum_type calculated_checksum =
Packet::get_checksum( view_n( msg.begin(), checksum_pos ) );
if ( present_checksum != calculated_checksum ) {
EMLABCPP_ERROR_LOG(
Expand Down
6 changes: 3 additions & 3 deletions include/emlabcpp/protocol/register_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class register_map
: registers_( Regs{ args }... )
{
}

constexpr explicit register_map( const Regs&... regs )
: registers_( regs... )
{
Expand Down Expand Up @@ -162,7 +162,7 @@ class register_map
{
return with_register_impl(*this, key, std::forward<UnaryCallable>(f));
}

template < typename UnaryCallable > constexpr auto with_register( key_type key, UnaryCallable&& f )
{
return with_register_impl(*this, key, std::forward<UnaryCallable>(f));
Expand Down Expand Up @@ -214,7 +214,7 @@ template < std::endian Endianess, typename... Regs >
std::ostream& operator<<( std::ostream& os, const register_map< Endianess, Regs... >& m )
{
for_each_register(
m, [&os]< auto key, typename T >( const T& val ) {
m, [&os]< auto key, typename T >( const T& val ) {
os << key << "\t" << val << "\n";
} );

Expand Down
2 changes: 1 addition & 1 deletion scripts/copyright-header-syntax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ java:
open: '/*\n'
close: ' */\n\n'
prefix: ' * '

kotlin:
ext: ['.kt']
comment:
Expand Down
11 changes: 7 additions & 4 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ find_package(GTest REQUIRED)

target_compile_options(
emlabcpp
PUBLIC -DEMLABCPP_USE_NLOHMANN_JSON -DEMLABCPP_ASSERT_NATIVE
-DEMLABCPP_USE_MAGIC_ENUM -DEMLABCPP_USE_GTEST -DEMLABCPP_USE_LOGGING
-DEMLABCPP_USE_DEMANGLING -DEMLABCPP_USE_OSTREAM)
PUBLIC -DEMLABCPP_USE_NLOHMANN_JSON
-DEMLABCPP_ASSERT_NATIVE
-DEMLABCPP_USE_MAGIC_ENUM
-DEMLABCPP_USE_GTEST
-DEMLABCPP_USE_LOGGING
-DEMLABCPP_USE_DEMANGLING
-DEMLABCPP_USE_OSTREAM)
target_include_directories(emlabcpp SYSTEM PUBLIC third-party/)

function(emlabcpp_setup_test target)
Expand Down Expand Up @@ -90,4 +94,3 @@ add_emlabcpp_test(point_test)
add_emlabcpp_test(pose_test)
add_emlabcpp_test(quaternion_test)
add_emlabcpp_test(simplex_test)

4 changes: 2 additions & 2 deletions tests/function_view_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ TEST( FunctionView, call_callable )
return std::to_string( val );
};
const return_view rf{ lr };
std::string test_sres = rf( 42 );
std::string test_sres = rf( 42 );
EXPECT_EQ( test_value, 42 );
EXPECT_EQ( test_sres, "42" );
test_sres = rf( 666 );
Expand All @@ -82,7 +82,7 @@ TEST( FunctionView, call_callable )
return static_cast< float >( std::stoi( sval ) );
};
const complex_view cf{ lc };
float test_fres = cf( 42, "12" );
float test_fres = cf( 42, "12" );
EXPECT_EQ( test_value, 42 );
EXPECT_EQ( test_fres, 12.f );
test_fres = cf( 666, "13" );
Expand Down
2 changes: 1 addition & 1 deletion tests/pretty_printer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ TEST( pretty_printer, recursive_writer )
TEST( pretty_printer, pretty_stream_write )
{
std::stringstream ss;
const int i = 42;
const int i = 42;

pretty_stream_write( ss, i );

Expand Down
2 changes: 1 addition & 1 deletion tests/protocol_sophisticated_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct valid_test_case : protocol_test_fixture

void TestBody() final
{
auto msg = handler::serialize( val );
auto msg = handler::serialize( val );
const bool is_equal = equal( msg, expected_buffer );
EXPECT_TRUE( is_equal )
<< "msg: " << convert_view< int >( msg ) << "\n"
Expand Down
4 changes: 2 additions & 2 deletions tests/static_vector_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ TEST( static_vector_test, move_trivial )
}

const trivial_buffer cpy{ tbuff };
trivial_buffer moved{ std::move( tbuff ) };
trivial_buffer moved{ std::move( tbuff ) };

EXPECT_EQ( cpy, moved );

Expand All @@ -179,7 +179,7 @@ TEST( static_vector_test, move_object )
}

const obj_buffer cpy{ obuff };
obj_buffer moved{ std::move( obuff ) };
obj_buffer moved{ std::move( obuff ) };

EXPECT_EQ( cpy, moved );

Expand Down

0 comments on commit f95973e

Please sign in to comment.