Skip to content

style(clang-tidy): fix include headers clang-tidy errors #1688

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions src/core/json/json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
#include <filesystem> // std::filesystem
#include <fstream> // std::ifstream
#include <istream> // std::basic_istream
#include <memory> // std::allocator
#include <ostream> // std::basic_ostream
#include <string> // std::basic_string
#include <system_error> // std::make_error_code, std::errc

namespace sourcemeta::core {
Expand Down
16 changes: 12 additions & 4 deletions src/core/jsonschema/bundle.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#include <sourcemeta/core/json_value.h>
#include <sourcemeta/core/jsonpointer.h>
#include <sourcemeta/core/jsonschema.h>

#include <cassert> // assert
#include <sstream> // std::ostringstream
#include <utility> // std::move
#include <sourcemeta/core/jsonschema_error.h>
#include <sourcemeta/core/jsonschema_frame.h>
#include <sourcemeta/core/jsonschema_types.h>

#include <cassert> // assert
#include <cstddef> // std::size_t
#include <optional> // std::optional
#include <sstream> // std::ostringstream
#include <string> // std::string
#include <utility> // std::move

namespace {

Expand Down
10 changes: 10 additions & 0 deletions src/core/jsonschema/frame.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
#include <sourcemeta/core/json_value.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make modules only include public headers of other modules

Suggested change
#include <sourcemeta/core/json_value.h>
#include <sourcemeta/core/json.h>

The idea is that only src/json can be internally aware that there is a json_value.h header, and every consumer should just require the public one

#include <sourcemeta/core/jsonpointer.h>
#include <sourcemeta/core/jsonschema.h>
#include <sourcemeta/core/jsonschema_error.h>
#include <sourcemeta/core/jsonschema_frame.h>
#include <sourcemeta/core/jsonschema_types.h>
#include <sourcemeta/core/uri.h>

#include <algorithm> // std::sort, std::all_of, std::any_of
#include <cassert> // assert
#include <cstddef> // std::size_t
#include <cstdint> // std::uint8_t
#include <functional> // std::less
#include <iterator> // std::next
#include <map> // std::map
#include <optional> // std::optional
#include <ostream> // std::ostream
#include <set> // std::set
#include <sstream> // std::ostringstream
#include <utility> // std::pair, std::move
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

#include <sourcemeta/core/json.h>
#include <sourcemeta/core/jsonpointer.h>
#include <sourcemeta/core/uri.h>

#include <sourcemeta/core/jsonschema_frame.h>
#include <sourcemeta/core/jsonschema_resolver.h>
#include <sourcemeta/core/uri.h>

#include <cassert> // assert
#include <concepts> // std::derived_from
Expand Down
10 changes: 10 additions & 0 deletions src/core/jsonschema/jsonschema.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
#include <sourcemeta/core/json_value.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <sourcemeta/core/json_value.h>
#include <sourcemeta/core/json.h>

#include <sourcemeta/core/jsonpointer.h>
#include <sourcemeta/core/jsonschema.h>
#include <sourcemeta/core/jsonschema_error.h>
#include <sourcemeta/core/jsonschema_frame.h>
#include <sourcemeta/core/jsonschema_types.h>
#include <sourcemeta/core/uri.h>

#include <cassert> // assert
#include <cstdint> // std::uint64_t
#include <functional> // std::less
#include <limits> // std::numeric_limits
#include <map> // std::map
#include <numeric> // std::accumulate
#include <optional> // std::optional
#include <sstream> // std::ostringstream
#include <string> // std::string
#include <string_view> // std::string_view
#include <type_traits> // std::remove_reference_t
#include <utility> // std::move

Expand Down
5 changes: 5 additions & 0 deletions src/core/jsonschema/official_resolver.in.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include <sourcemeta/core/json.h>
#include <sourcemeta/core/json_value.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't include json_value.h if we are including json.h

#include <sourcemeta/core/jsonschema.h>

#include <optional> // std::optional
#include <string_view> // std::string_view

auto sourcemeta::core::schema_official_resolver(std::string_view identifier)
-> std::optional<sourcemeta::core::JSON> {
// JSON Schema 2020-12
Expand Down
4 changes: 4 additions & 0 deletions src/core/jsonschema/official_walker.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include <sourcemeta/core/jsonschema.h>
#include <sourcemeta/core/jsonschema_types.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't include jsonschema_types.h if we are including jsonschema.h


#include <optional> // std::nullopt
#include <string_view> // std::string_view

auto sourcemeta::core::schema_official_walker(
std::string_view keyword,
Expand Down
22 changes: 17 additions & 5 deletions src/core/jsonschema/resolver.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
#include <sourcemeta/core/json_value.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <sourcemeta/core/json_value.h>
#include <sourcemeta/core/json.h>

#include <sourcemeta/core/jsonpointer.h>
#include <sourcemeta/core/jsonschema.h>

#include <algorithm> // std::transform
#include <cassert> // assert
#include <cctype> // std::tolower
#include <sstream> // std::ostringstream
#include <sourcemeta/core/jsonschema_error.h>
#include <sourcemeta/core/jsonschema_frame.h>
#include <sourcemeta/core/jsonschema_resolver.h>
#include <sourcemeta/core/jsonschema_types.h>

#include <algorithm> // std::transform
#include <cassert> // assert
#include <cctype> // std::tolower
#include <filesystem> // std::filesystem::path
#include <functional> // std::function
#include <optional> // std::optional
#include <sstream> // std::ostringstream
#include <string> // std::string
#include <string_view> // std::string_view
#include <utility> // std::move

namespace sourcemeta::core {

Expand Down
9 changes: 9 additions & 0 deletions src/core/jsonschema/transformer.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
#include <sourcemeta/core/json_value.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <sourcemeta/core/json_value.h>
#include <sourcemeta/core/json.h>

#include <sourcemeta/core/jsonpointer.h>
#include <sourcemeta/core/jsonschema.h>
#include <sourcemeta/core/jsonschema_error.h>
#include <sourcemeta/core/jsonschema_frame.h>
#include <sourcemeta/core/jsonschema_transform.h>
#include <sourcemeta/core/jsonschema_types.h>

#include <cassert> // assert
#include <optional> // std::optional
#include <set> // std::set
#include <sstream> // std::ostringstream
#include <stdexcept> // std::runtime_error
#include <string> // std::string
#include <utility> // std::move, std::pair
#include <variant> // std::get_if, std::holds_alternative

namespace {

Expand Down
10 changes: 10 additions & 0 deletions src/core/jsonschema/walker.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
#include <sourcemeta/core/json_value.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <sourcemeta/core/json_value.h>
#include <sourcemeta/core/json.h>

#include <sourcemeta/core/jsonpointer.h>
#include <sourcemeta/core/jsonschema.h>
#include <sourcemeta/core/jsonschema_types.h>
#include <sourcemeta/core/jsonschema_walker.h>

#include <algorithm> // std::max, std::sort
#include <cassert> // assert
#include <cstddef> // std::size_t
#include <cstdint> // std::uint8_t
#include <optional> // std::optional
#include <string> // std::string
#include <utility> // std::move
#include <vector> // std::vector

namespace {
enum class SchemaWalkerType_t : std::uint8_t { Deep, Flat };
Expand Down
4 changes: 4 additions & 0 deletions src/core/uri/escaping.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#include <uriparser/Uri.h>
#include <uriparser/UriBase.h>

#include <sourcemeta/core/uri.h>

#include <algorithm> // std::copy
#include <istream> // std::istream
#include <ostream> // std::ostream
#include <sstream> // std::ostringstream
#include <string> // std::string

namespace sourcemeta::core {

Expand Down
23 changes: 13 additions & 10 deletions src/core/uri/uri.cc
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#include <uriparser/Uri.h>
#include <uriparser/UriBase.h>

#include <sourcemeta/core/uri.h>

#include <cassert> // assert
#include <cstdint> // std::uint32_t
#include <istream> // std::istream
#include <optional> // std::optional
#include <sstream> // std::ostringstream
#include <stdexcept> // std::length_error, std::runtime_error
#include <string> // std::stoul, std::string, std::tolower
#include <tuple> // std::tie
#include <utility> // std::move
#include <vector> // std::vector
#include <cassert> // assert
#include <cctype> // std::tolower
#include <cstdint> // std::uint32_t
#include <istream> // std::istream
#include <optional> // std::optional
#include <sstream> // std::ostringstream
#include <stdexcept> // std::length_error, std::runtime_error
#include <string> // std::stoul, std::string, std::tolower
#include <string_view> // std::string_view
#include <tuple> // std::tie
#include <utility> // std::move
#include <vector> // std::vector

static auto uri_normalize(UriUriA *uri) -> void {
if (uriNormalizeSyntaxA(uri) != URI_SUCCESS) {
Expand Down
6 changes: 6 additions & 0 deletions src/core/yaml/yaml.cc
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
// See https://pyyaml.org/wiki/LibYAML for basic documentation
#include <yaml.h>

#include <sourcemeta/core/json.h>
#include <sourcemeta/core/json_error.h>
#include <sourcemeta/core/json_value.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't include json_value.h (nor json_error.h as in the above line btw) if we are including json.h

#include <sourcemeta/core/yaml.h>
#include <sourcemeta/core/yaml_error.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't include yaml_error.h if we are including yaml.h


#include <filesystem> // std::filesystem::path
#include <istream> // std::basic_istream
#include <sstream> // std::ostringstream, std::istringstream
#include <string> // std::string
#include <string_view> // std::string_view

// TODO: Perform parsing token by token using `yaml_parser_parse`,
Expand Down
13 changes: 8 additions & 5 deletions src/extension/alterschema/alterschema.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#include <sourcemeta/core/alterschema.h>

#include <cassert> // assert
#include <sourcemeta/core/jsonschema_transform.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should only be including jsonschema.h

#include <sourcemeta/core/jsonschema_types.h>

// For built-in rules
#include <algorithm>
#include <cmath>
#include <iterator>
#include <algorithm> // std::any_of, std::all_of
#include <cassert> // assert
#include <cmath> // std::floor
#include <iterator> // std::cbegin, std::cend
#include <set> // std::set

namespace sourcemeta::core {
auto contains_any(const Vocabularies &container,
const std::set<typename Vocabularies::key_type> &values)
Expand Down