Skip to content

Overwork astyle call #4573

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

Merged
merged 27 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
387a7fc
:wrench: overwork astyle call
nlohmann Dec 28, 2024
47304f4
:wrench: overwork astyle call
nlohmann Dec 28, 2024
0a6adc2
:wrench: overwork astyle call
nlohmann Dec 28, 2024
709ceff
:wrench: overwork astyle call
nlohmann Dec 28, 2024
171c65a
:wrench: overwork astyle call
nlohmann Dec 28, 2024
2489bdf
:wrench: overwork astyle call
nlohmann Dec 28, 2024
34f4807
:wrench: overwork astyle call
nlohmann Dec 28, 2024
af55a8a
:wrench: overwork astyle call
nlohmann Dec 28, 2024
17dec65
:wrench: overwork astyle call
nlohmann Dec 28, 2024
3543e70
:wrench: overwork astyle call
nlohmann Dec 28, 2024
f1105b2
:wrench: overwork astyle call
nlohmann Dec 29, 2024
8314ac2
Use ubuntu-latest image to run Valgrind (#4575)
nlohmann Dec 29, 2024
0fa326a
Use Clang image to run iwyu (#4574)
nlohmann Dec 29, 2024
7915102
:wrench: overwork astyle call
nlohmann Dec 28, 2024
e1df8f4
:wrench: overwork astyle call
nlohmann Dec 28, 2024
36139b0
:wrench: overwork astyle call
nlohmann Dec 28, 2024
b520579
:wrench: overwork astyle call
nlohmann Dec 28, 2024
45a02b9
:wrench: overwork astyle call
nlohmann Dec 28, 2024
cc7cea0
:wrench: overwork astyle call
nlohmann Dec 28, 2024
87e6e61
:wrench: overwork astyle call
nlohmann Dec 28, 2024
2607687
:wrench: overwork astyle call
nlohmann Dec 28, 2024
6a92028
:wrench: overwork astyle call
nlohmann Dec 28, 2024
c349ee0
:wrench: overwork astyle call
nlohmann Dec 28, 2024
55f6f8b
:wrench: overwork astyle call
nlohmann Dec 29, 2024
a55444c
:art: format code
nlohmann Dec 29, 2024
4bd1282
Merge remote-tracking branch 'origin/astyle' into astyle
nlohmann Dec 29, 2024
5f7c9ad
:hammer: clean up
nlohmann Dec 29, 2024
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
84 changes: 0 additions & 84 deletions .clang-format

This file was deleted.

5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ updates:
schedule:
interval: daily

- package-ecosystem: pip
directory: /tools/astyle
schedule:
interval: daily

- package-ecosystem: pip
directory: /tools/serve_header
schedule:
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/check_amalgamation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ jobs:
MAIN_DIR: ${{ github.workspace }}/main
INCLUDE_DIR: ${{ github.workspace }}/main/single_include/nlohmann
TOOL_DIR: ${{ github.workspace }}/tools/tools/amalgamate
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

steps:
- name: Harden Runner
Expand All @@ -57,8 +52,8 @@ jobs:

- name: Install astyle
run: |
sudo apt-get update
sudo apt-get install astyle
python3 -mvenv venv
venv/bin/pip3 install -r $MAIN_DIR/tools/astyle/requirements.txt

- name: Check amalgamation
run: |
Expand All @@ -71,11 +66,11 @@ jobs:
python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json.json -s .
python3 $TOOL_DIR/amalgamate.py -c $TOOL_DIR/config_json_fwd.json -s .
echo "Format (1)"
astyle $ASTYLE_FLAGS --suffix=none --quiet $INCLUDE_DIR/json.hpp $INCLUDE_DIR/json_fwd.hpp
${{ github.workspace }}/venv/bin/astyle --project=tools/astyle/.astylerc --suffix=none --quiet $INCLUDE_DIR/json.hpp $INCLUDE_DIR/json_fwd.hpp

diff $INCLUDE_DIR/json.hpp~ $INCLUDE_DIR/json.hpp
diff $INCLUDE_DIR/json_fwd.hpp~ $INCLUDE_DIR/json_fwd.hpp

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)
${{ 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)
echo Check
find $MAIN_DIR -name '*.orig' -exec false {} \+
20 changes: 7 additions & 13 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,15 @@ jobs:
- name: Build
run: cmake --build build --target ci_test_gcc

ci_static_analysis:
ci_infer:
runs-on: ubuntu-latest
container: ghcr.io/nlohmann/json-ci:v2.4.0
strategy:
matrix:
target: [
ci_test_valgrind, # needs Valgrind
ci_test_amalgamation, # needs AStyle
ci_infer, # needs Infer
ci_single_binaries # needs iwyu
]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Run CMake
run: cmake -S . -B build -DJSON_CI=On
- name: Build
run: cmake --build build --target ${{ matrix.target }}
run: cmake --build build --target ci_infer

ci_test_single_header:
runs-on: ubuntu-latest
Expand All @@ -77,13 +69,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
target: [ci_cppcheck, ci_cpplint, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata, ci_reuse_compliance]
target: [ci_test_amalgamation, ci_cppcheck, ci_cpplint, ci_reproducible_tests, ci_non_git_tests, ci_offline_testdata, ci_reuse_compliance, ci_test_valgrind]
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Install Valgrind
run: sudo apt-get update ; sudo apt-get install -y valgrind
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get latest CMake and ninja
uses: lukka/get-cmake@5979409e62bdf841487c5fb3c053149de97a86d3 # v3.31.2
Expand All @@ -97,10 +91,10 @@ jobs:
container: silkeh/clang:dev
strategy:
matrix:
target: [ci_clang_tidy, ci_test_clang_sanitizer, ci_clang_analyze]
target: [ci_clang_tidy, ci_test_clang_sanitizer, ci_clang_analyze, ci_single_binaries]
steps:
- name: Install git, clang-tools, and unzip
run: apt-get update ; apt-get install -y git clang-tools unzip
run: apt-get update ; apt-get install -y git clang-tools iwyu unzip
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Get latest CMake and ninja
uses: lukka/get-cmake@5979409e62bdf841487c5fb3c053149de97a86d3 # v3.31.2
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@
/serve_header.yml

# Swift Package Manager build directory
/.build
/.build

/tools/astyle/venv/
30 changes: 9 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,28 +142,16 @@ pvs_studio:
# Code format and source amalgamation
##########################################################################

ASTYLE=tools/astyle/venv/bin/astyle

install_astyle:
@test -d tools/astyle/venv || python3 -mvenv tools/astyle/venv ; tools/astyle/venv/bin/pip3 install --quiet --upgrade pip
@test -f $(ASTYLE) || tools/astyle/venv/bin/pip3 install --quiet -r tools/astyle/requirements.txt
@$(ASTYLE) --version

# call the Artistic Style pretty printer on all source files
pretty:
astyle \
--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-braces \
--convert-tabs \
--close-templates \
--lineend=linux \
--preserve-date \
--suffix=none \
--formatted \
$(SRCS) $(TESTS_SRCS) $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) docs/examples/*.cpp
pretty: install_astyle
$(ASTYLE) --project=tools/astyle/.astylerc $(SRCS) $(TESTS_SRCS) $(AMALGAMATED_FILE) $(AMALGAMATED_FWD_FILE) docs/examples/*.cpp

# call the Clang-Format on all source files
pretty_format:
Expand Down
15 changes: 6 additions & 9 deletions cmake/ci.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ set(N 10)
include(FindPython3)
find_package(Python3 COMPONENTS Interpreter)

find_program(ASTYLE_TOOL NAMES astyle)
execute_process(COMMAND ${ASTYLE_TOOL} --version OUTPUT_VARIABLE ASTYLE_TOOL_VERSION ERROR_VARIABLE ASTYLE_TOOL_VERSION)
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" ASTYLE_TOOL_VERSION "${ASTYLE_TOOL_VERSION}")
message(STATUS "🔖 Artistic Style ${ASTYLE_TOOL_VERSION} (${ASTYLE_TOOL})")

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++)
execute_process(COMMAND ${CLANG_TOOL} --version OUTPUT_VARIABLE CLANG_TOOL_VERSION ERROR_VARIABLE CLANG_TOOL_VERSION)
string(REGEX MATCH "[0-9]+(\\.[0-9]+)+" CLANG_TOOL_VERSION "${CLANG_TOOL_VERSION}")
Expand Down Expand Up @@ -632,8 +627,6 @@ add_custom_target(ci_test_clang_sanitizer
# Check if header is amalgamated and sources are properly indented.
###############################################################################

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)

file(GLOB_RECURSE INDENT_FILES
${PROJECT_SOURCE_DIR}/include/nlohmann/*.hpp
${PROJECT_SOURCE_DIR}/tests/src/*.cpp
Expand All @@ -649,14 +642,18 @@ add_custom_target(ci_test_amalgamation
COMMAND cp ${include_dir}/json.hpp ${include_dir}/json.hpp~
COMMAND cp ${include_dir}/json_fwd.hpp ${include_dir}/json_fwd.hpp~

COMMAND ${Python3_EXECUTABLE} -mvenv venv_astyle
COMMAND venv_astyle/bin/pip3 --quiet install -r ${CMAKE_SOURCE_DIR}/tools/astyle/requirements.txt
COMMAND venv_astyle/bin/astyle --version

COMMAND ${Python3_EXECUTABLE} ${tool_dir}/amalgamate.py -c ${tool_dir}/config_json.json -s .
COMMAND ${Python3_EXECUTABLE} ${tool_dir}/amalgamate.py -c ${tool_dir}/config_json_fwd.json -s .
COMMAND ${ASTYLE_TOOL} ${ASTYLE_FLAGS} --suffix=none --quiet ${include_dir}/json.hpp ${include_dir}/json_fwd.hpp
COMMAND venv_astyle/bin/astyle --project=tools/astyle/.astylerc --suffix=none ${include_dir}/json.hpp ${include_dir}/json_fwd.hpp

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

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

WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/json_base_class_t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ int main()

// visit and output
j.visit(
[&](const json::json_pointer & p,
const json & j)
[&](const json::json_pointer & p,
const json & j)
{
std::cout << (p.empty() ? std::string{"/"} : p.to_string())
<< " - metadata = " << j.metadata << " -> " << j.dump() << '\n';
Expand Down
3 changes: 1 addition & 2 deletions include/nlohmann/detail/conversions/from_json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <utility> // pair, declval
#include <valarray> // valarray


#include <nlohmann/detail/exceptions.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp>
Expand Down Expand Up @@ -345,7 +344,7 @@ void())

template < typename BasicJsonType, typename T, std::size_t... Idx >
std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
{
return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
}
Expand Down
7 changes: 4 additions & 3 deletions include/nlohmann/detail/conversions/to_json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

#pragma once

#include <algorithm> // copy
#include <iterator> // begin, end
#include <nlohmann/detail/macro_scope.hpp> // JSON_HAS_CPP_17
#ifdef JSON_HAS_CPP_17
#include <optional> // optional
#endif

#include <algorithm> // copy
#include <iterator> // begin, end
#include <string> // string
#include <tuple> // tuple, get
#include <type_traits> // is_same, is_constructible, is_floating_point, is_enum, underlying_type
Expand All @@ -21,7 +23,6 @@
#include <vector> // vector

#include <nlohmann/detail/iterators/iteration_proxy.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/cpp_future.hpp>
#include <nlohmann/detail/meta/std_fs.hpp>
#include <nlohmann/detail/meta/type_traits.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/nlohmann/detail/iterators/iteration_proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ namespace std
#endif
template<typename IteratorType>
class tuple_size<::nlohmann::detail::iteration_proxy_value<IteratorType>> // NOLINT(cert-dcl58-cpp)
: public std::integral_constant<std::size_t, 2> {};
: public std::integral_constant<std::size_t, 2> {};

template<std::size_t N, typename IteratorType>
class tuple_element<N, ::nlohmann::detail::iteration_proxy_value<IteratorType >> // NOLINT(cert-dcl58-cpp)
Expand Down
2 changes: 1 addition & 1 deletion include/nlohmann/detail/iterators/iterator_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct iterator_traits

template<typename T>
struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
: iterator_types<T>
: iterator_types<T>
{
};

Expand Down
Loading
Loading