Skip to content

Commit

Permalink
Implement the linter command using the AlterSchema project (#155)
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti authored Aug 23, 2024
1 parent fc5537c commit 50040f6
Show file tree
Hide file tree
Showing 64 changed files with 2,770 additions and 565 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ option(JSONSCHEMA_DEVELOPMENT "Build the JSON Schema CLI in development mode" OF
option(JSONSCHEMA_CONTINUOUS "Perform a continuous JSON Schema CLI release" ON)

find_package(JSONToolkit REQUIRED)
find_package(AlterSchema REQUIRED)
find_package(Hydra REQUIRED)
add_subdirectory(src)

Expand Down
3 changes: 2 additions & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendorpull https://github.com/sourcemeta/vendorpull dea311b5bfb53b6926a4140267959ae334d3ecf4
noa https://github.com/sourcemeta/noa 7e26abce7a4e31e86a16ef2851702a56773ca527
jsontoolkit https://github.com/sourcemeta/jsontoolkit 760aecee95213152bfea907c19cdaa43f616dc9b
jsontoolkit https://github.com/sourcemeta/jsontoolkit 9a88c7331742360abc06317bbce4df6afd11c61b
hydra https://github.com/sourcemeta/hydra 3c53d3fdef79e9ba603d48470a508cc45472a0dc
alterschema https://github.com/sourcemeta/alterschema a31722f04ae2d7e57f2fe5bbb0613670866c0840
5 changes: 5 additions & 0 deletions cmake/FindAlterSchema.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if(NOT Alterschema_FOUND)
set(ALTERSCHEMA_INSTALL OFF CACHE BOOL "disable installation")
add_subdirectory("${PROJECT_SOURCE_DIR}/vendor/alterschema")
set(Alterschema_FOUND ON)
endif()
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ target_link_libraries(jsonschema_cli PRIVATE sourcemeta::jsontoolkit::uri)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::jsontoolkit::json)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::jsontoolkit::jsonl)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::jsontoolkit::jsonschema)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::alterschema::engine)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::alterschema::linter)
target_link_libraries(jsonschema_cli PRIVATE sourcemeta::hydra::httpclient)

configure_file(configure.h.in configure.h @ONLY)
Expand Down
16 changes: 11 additions & 5 deletions src/command_lint.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <sourcemeta/alterschema/engine.h>
#include <sourcemeta/alterschema/linter.h>
#include <sourcemeta/jsontoolkit/json.h>
#include <sourcemeta/jsontoolkit/jsonschema.h>

Expand All @@ -12,11 +14,15 @@ auto intelligence::jsonschema::cli::lint(
const std::span<const std::string> &arguments) -> int {
const auto options{parse_options(arguments, {"f", "fix"})};

sourcemeta::jsontoolkit::SchemaTransformBundle bundle;
bundle.add(
sourcemeta::jsontoolkit::SchemaTransformBundle::Category::Modernize);
bundle.add(
sourcemeta::jsontoolkit::SchemaTransformBundle::Category::AntiPattern);
sourcemeta::alterschema::Bundle bundle;
sourcemeta::alterschema::add(
bundle, sourcemeta::alterschema::LinterCategory::Modernize);
sourcemeta::alterschema::add(
bundle, sourcemeta::alterschema::LinterCategory::AntiPattern);
sourcemeta::alterschema::add(
bundle, sourcemeta::alterschema::LinterCategory::Simplify);
sourcemeta::alterschema::add(
bundle, sourcemeta::alterschema::LinterCategory::Redundant);

bool result{true};

Expand Down
73 changes: 73 additions & 0 deletions vendor/alterschema/CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 50040f6

Please sign in to comment.