Skip to content

Commit

Permalink
Implement the linter command using the AlterSchema project
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
  • Loading branch information
jviotti committed Aug 23, 2024
1 parent fc5537c commit f4c8ff1
Show file tree
Hide file tree
Showing 52 changed files with 3,291 additions and 5 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
1 change: 1 addition & 0 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ vendorpull https://github.com/sourcemeta/vendorpull dea311b5bfb53b6926a414026795
noa https://github.com/sourcemeta/noa 7e26abce7a4e31e86a16ef2851702a56773ca527
jsontoolkit https://github.com/sourcemeta/jsontoolkit 760aecee95213152bfea907c19cdaa43f616dc9b
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 f4c8ff1

Please sign in to comment.