Skip to content

Commit 6057b31

Browse files
authored
Overwork astyle call (#4573)
* 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * Use ubuntu-latest image to run Valgrind (#4575) * 🔧 use Clang image to run valgrind * 🔧 use Clang image to run valgrind * 🔧 use Clang image to run valgrind * 🔧 use Ubuntu image to run valgrind * Use Clang image to run iwyu (#4574) * 🔧 use Clang image to run iwyu * 🔧 use Clang image to run iwyu * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🔧 overwork astyle call * 🎨 format code * 🔨 clean up
1 parent 0fa326a commit 6057b31

25 files changed

+191
-218
lines changed

.clang-format

Lines changed: 0 additions & 84 deletions
This file was deleted.

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ updates:
1010
schedule:
1111
interval: daily
1212

13+
- package-ecosystem: pip
14+
directory: /tools/astyle
15+
schedule:
16+
interval: daily
17+
1318
- package-ecosystem: pip
1419
directory: /tools/serve_header
1520
schedule:

.github/workflows/check_amalgamation.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ jobs:
3131
MAIN_DIR: ${{ github.workspace }}/main
3232
INCLUDE_DIR: ${{ github.workspace }}/main/single_include/nlohmann
3333
TOOL_DIR: ${{ github.workspace }}/tools/tools/amalgamate
34-
ASTYLE_FLAGS: >
35-
--style=allman --indent=spaces=4 --indent-modifiers --indent-switches --indent-preproc-block
36-
--indent-preproc-define --indent-col1-comments --pad-oper --pad-header --align-pointer=type
37-
--align-reference=type --add-brackets --convert-tabs --close-templates --lineend=linux --preserve-date
38-
--formatted
3934

4035
steps:
4136
- name: Harden Runner
@@ -57,8 +52,8 @@ jobs:
5752

5853
- name: Install astyle
5954
run: |
60-
sudo apt-get update
61-
sudo apt-get install astyle
55+
python3 -mvenv venv
56+
venv/bin/pip3 install -r $MAIN_DIR/tools/astyle/requirements.txt
6257
6358
- name: Check amalgamation
6459
run: |
@@ -71,11 +66,11 @@ jobs:
7166
python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json.json -s .
7267
python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json_fwd.json -s .
7368
echo "Format (1)"
74-
astyle $ASTYLE_FLAGS --suffix=none --quiet $INCLUDE_DIR/json.hpp $INCLUDE_DIR/json_fwd.hpp
69+
${{ github.workspace }}/venv/bin/astyle --project=tools/astyle/.astylerc --suffix=none --quiet $INCLUDE_DIR/json.hpp $INCLUDE_DIR/json_fwd.hpp
7570
7671
diff $INCLUDE_DIR/json.hpp~ $INCLUDE_DIR/json.hpp
7772
diff $INCLUDE_DIR/json_fwd.hpp~ $INCLUDE_DIR/json_fwd.hpp
7873
79-
astyle $ASTYLE_FLAGS $(find docs/examples include tests -type f \( -name '*.hpp' -o -name '*.cpp' -o -name '*.cu' \) -not -path 'tests/thirdparty/*' -not -path 'tests/abi/include/nlohmann/*' | sort)
74+
${{ github.workspace }}/venv/bin/astyle --project=tools/astyle/.astylerc --suffix=orig $(find docs/examples include tests -type f \( -name '*.hpp' -o -name '*.cpp' -o -name '*.cu' \) -not -path 'tests/thirdparty/*' -not -path 'tests/abi/include/nlohmann/*' | sort)
8075
echo Check
8176
find $MAIN_DIR -name '*.orig' -exec false {} \+

.github/workflows/ubuntu.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,15 @@ jobs:
4343
- name: Build
4444
run: cmake --build build --target ci_test_gcc
4545

46-
ci_static_analysis:
46+
ci_infer:
4747
runs-on: ubuntu-latest
4848
container: ghcr.io/nlohmann/json-ci:v2.4.0
49-
strategy:
50-
matrix:
51-
target: [
52-
ci_test_amalgamation, # needs AStyle
53-
ci_infer # needs Infer
54-
]
5549
steps:
5650
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
5751
- name: Run CMake
5852
run: cmake -S . -B build -DJSON_CI=On
5953
- name: Build
60-
run: cmake --build build --target ${{ matrix.target }}
54+
run: cmake --build build --target ci_infer
6155

6256
ci_test_single_header:
6357
runs-on: ubuntu-latest
@@ -75,7 +69,7 @@ jobs:
7569
runs-on: ubuntu-latest
7670
strategy:
7771
matrix:
78-
target: [ci_cppcheck, ci_cpplint, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata, ci_reuse_compliance, ci_test_valgrind]
72+
target: [ci_test_amalgamation, ci_cppcheck, ci_cpplint, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata, ci_reuse_compliance, ci_test_valgrind]
7973
steps:
8074
- name: Harden Runner
8175
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@
4141
/serve_header.yml
4242

4343
# Swift Package Manager build directory
44-
/.build
44+
/.build
45+
46+
/tools/astyle/venv/

Makefile

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -142,28 +142,16 @@ pvs_studio:
142142
# Code format and source amalgamation
143143
##########################################################################
144144

145+
ASTYLE=tools/astyle/venv/bin/astyle
146+
147+
install_astyle:
148+
@test -d tools/astyle/venv || python3 -mvenv tools/astyle/venv ; tools/astyle/venv/bin/pip3 install --quiet --upgrade pip
149+
@test -f $(ASTYLE) || tools/astyle/venv/bin/pip3 install --quiet -r tools/astyle/requirements.txt
150+
@$(ASTYLE) --version
151+
145152
# call the Artistic Style pretty printer on all source files
146-
pretty:
147-
astyle \
148-
--style=allman \
149-
--indent=spaces=4 \
150-
--indent-modifiers \
151-
--indent-switches \
152-
--indent-preproc-block \
153-
--indent-preproc-define \
154-
--indent-col1-comments \
155-
--pad-oper \
156-
--pad-header \
157-
--align-pointer=type \
158-
--align-reference=type \
159-
--add-braces \
160-
--convert-tabs \
161-
--close-templates \
162-
--lineend=linux \
163-
--preserve-date \
164-
--suffix=none \
165-
--formatted \
166-
$(SRCS) $(TESTS_SRCS) $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) docs/examples/*.cpp
153+
pretty: install_astyle
154+
$(ASTYLE) --project=tools/astyle/.astylerc $(SRCS) $(TESTS_SRCS) $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) docs/examples/*.cpp
167155

168156
# call the Clang-Format on all source files
169157
pretty_format:

cmake/ci.cmake

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ set(N 10)
88
include(FindPython3)
99
find_package(Python3 COMPONENTS Interpreter)
1010

11-
find_program(ASTYLE_TOOL NAMES astyle)
12-
execute_process(COMMAND ${ASTYLE_TOOL} --version OUTPUT_VARIABLE ASTYLE_TOOL_VERSION ERROR_VARIABLE ASTYLE_TOOL_VERSION)
13-
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" ASTYLE_TOOL_VERSION "${ASTYLE_TOOL_VERSION}")
14-
message(STATUS "🔖 Artistic Style ${ASTYLE_TOOL_VERSION} (${ASTYLE_TOOL})")
15-
1611
find_program(CLANG_TOOL NAMES clang++-HEAD clang++ clang++-20 clang++-19 clang++-18 clang++-17 clang++-16 clang++-15 clang++-14 clang++-13 clang++-12 clang++-11 clang++)
1712
execute_process(COMMAND ${CLANG_TOOL} --version OUTPUT_VARIABLE CLANG_TOOL_VERSION ERROR_VARIABLE CLANG_TOOL_VERSION)
1813
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TOOL_VERSION "${CLANG_TOOL_VERSION}")
@@ -632,8 +627,6 @@ add_custom_target(ci_test_clang_sanitizer
632627
# Check if header is amalgamated and sources are properly indented.
633628
###############################################################################
634629

635-
set(ASTYLE_FLAGS --style=allman --indent=spaces=4 --indent-modifiers --indent-switches --indent-preproc-block --indent-preproc-define --indent-col1-comments --pad-oper --pad-header --align-pointer=type --align-reference=type --add-brackets --convert-tabs --close-templates --lineend=linux --preserve-date --formatted)
636-
637630
file(GLOB_RECURSE INDENT_FILES
638631
${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp
639632
${PROJECT_SOURCE_DIR}/tests/src/*.cpp
@@ -649,14 +642,18 @@ add_custom_target(ci_test_amalgamation
649642
COMMAND cp ${include_dir}/json.hpp ${include_dir}/json.hpp~
650643
COMMAND cp ${include_dir}/json_fwd.hpp ${include_dir}/json_fwd.hpp~
651644

645+
COMMAND ${Python3_EXECUTABLE} -mvenv venv_astyle
646+
COMMAND venv_astyle/bin/pip3 --quiet install -r ${CMAKE_SOURCE_DIR}/tools/astyle/requirements.txt
647+
COMMAND venv_astyle/bin/astyle --version
648+
652649
COMMAND ${Python3_EXECUTABLE} ${tool_dir}/amalgamate.py -c ${tool_dir}/config_json.json -s .
653650
COMMAND ${Python3_EXECUTABLE} ${tool_dir}/amalgamate.py -c ${tool_dir}/config_json_fwd.json -s .
654-
COMMAND ${ASTYLE_TOOL} ${ASTYLE_FLAGS} --suffix=none --quiet ${include_dir}/json.hpp ${include_dir}/json_fwd.hpp
651+
COMMAND venv_astyle/bin/astyle --project=tools/astyle/.astylerc --suffix=none ${include_dir}/json.hpp ${include_dir}/json_fwd.hpp
655652

656653
COMMAND diff ${include_dir}/json.hpp~ ${include_dir}/json.hpp
657654
COMMAND diff ${include_dir}/json_fwd.hpp~ ${include_dir}/json_fwd.hpp
658655

659-
COMMAND ${ASTYLE_TOOL} ${ASTYLE_FLAGS} ${INDENT_FILES}
656+
COMMAND venv_astyle/bin/astyle --project=tools/astyle/.astylerc --suffix=orig ${INDENT_FILES}
660657
COMMAND for FILE in `find . -name '*.orig'`\; do false \; done
661658

662659
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}

docs/examples/json_base_class_t.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ int main()
7979

8080
// visit and output
8181
j.visit(
82-
[&](const json::json_pointer & p,
83-
const json & j)
82+
[&](const json::json_pointer & p,
83+
const json & j)
8484
{
8585
std::cout << (p.empty() ? std::string{"/"} : p.to_string())
8686
<< " - metadata = " << j.metadata << " -> " << j.dump() << '\n';

include/nlohmann/detail/conversions/from_json.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <utility> // pair, declval
2424
#include <valarray> // valarray
2525

26-
2726
#include <nlohmann/detail/exceptions.hpp>
2827
#include <nlohmann/detail/macro_scope.hpp>
2928
#include <nlohmann/detail/meta/cpp_future.hpp>
@@ -345,7 +344,7 @@ void())
345344

346345
template < typename BasicJsonType, typename T, std::size_t... Idx >
347346
std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
348-
identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
347+
identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
349348
{
350349
return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
351350
}

include/nlohmann/detail/iterators/iteration_proxy.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ namespace std
213213
#endif
214214
template<typename IteratorType>
215215
class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>> // NOLINT(cert-dcl58-cpp)
216-
: public std::integral_constant<std::size_t, 2> {};
216+
: public std::integral_constant<std::size_t, 2> {};
217217

218218
template<std::size_t N, typename IteratorType>
219219
class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >> // NOLINT(cert-dcl58-cpp)

0 commit comments

Comments
 (0)