From 59463560831ea5bae5672fb08a858690b7c66903 Mon Sep 17 00:00:00 2001 From: Aaron Po Date: Sat, 11 Apr 2026 11:56:45 -0400 Subject: [PATCH] Style audit: update code to strictly follow Google Style Guide --- pipeline/.clang-tidy | 42 +++++++--- pipeline/CMakeLists.txt | 78 ++++++++----------- pipeline/includes/biergarten_data_generator.h | 8 +- .../includes/data_generation/data_generator.h | 6 +- .../data_generation/llama_generator.h | 6 +- .../data_generation/llama_generator_helpers.h | 6 +- .../includes/data_generation/mock_generator.h | 6 +- pipeline/includes/data_model/location.h | 6 +- pipeline/includes/json_handling/json_loader.h | 6 +- pipeline/includes/llama_backend_state.h | 6 +- .../includes/services/enrichment_service.h | 6 +- .../includes/services/wikipedia_service.h | 6 +- .../includes/web_client/curl_web_client.h | 6 +- pipeline/includes/web_client/web_client.h | 7 +- .../generate_breweries.cpp | 4 +- .../biergarten_data_generator/log_results.cpp | 2 +- .../query_cities_with_countries.cpp | 3 +- .../src/biergarten_data_generator/run.cpp | 2 +- .../llama/generate_brewery.cpp | 7 +- .../mock/deterministic_hash.cpp | 3 +- .../data_generation/mock/generate_brewery.cpp | 5 +- pipeline/src/json_handling/json_loader.cpp | 13 ++-- pipeline/src/main.cpp | 6 +- .../src/services/wikipedia/fetch_extract.cpp | 2 +- .../src/services/wikipedia/get_summary.cpp | 2 +- .../src/web_client/curl_web_client_utils.cpp | 6 +- .../src/web_client/curl_web_client_utils.h | 6 +- 27 files changed, 129 insertions(+), 127 deletions(-) diff --git a/pipeline/.clang-tidy b/pipeline/.clang-tidy index e4b27c2..836f842 100644 --- a/pipeline/.clang-tidy +++ b/pipeline/.clang-tidy @@ -1,17 +1,37 @@ ---- Checks: > -*, bugprone-*, - clang-analyzer-*, - cppcoreguidelines-*, google-*, modernize-*, - performance-*, readability-*, - -cppcoreguidelines-avoid-magic-numbers, - -cppcoreguidelines-owning-memory, - -readability-magic-numbers, - -google-readability-todo -HeaderFilterRegex: "^(src|includes)/.*" -FormatStyle: file -... + cppcoreguidelines-*, + -modernize-use-trailing-return-type, + -google-runtime-references + +CheckOptions: + # Enforce Google Naming Conventions + - key: readability-identifier-naming.ClassMemberCase + value: snake_case + - key: readability-identifier-naming.ClassMemberSuffix + value: _ + - key: readability-identifier-naming.ClassCase + value: PascalCase + - key: readability-identifier-naming.FunctionCase + value: PascalCase + - key: readability-identifier-naming.StructCase + value: PascalCase + - key: readability-identifier-naming.VariableCase + value: snake_case + - key: readability-identifier-naming.GlobalConstantCase + value: kPascalCase + + # Ensure C++20 Modernization + - key: modernize-make-unique.MakeSmartPtrFunction + value: std::make_unique + - key: modernize-make-shared.MakeSmartPtrFunction + value: std::make_shared + - key: modernize-use-override.IgnoreDestructors + value: "false" + +# Warnings as Errors to ensure compliance during build +WarningsAsErrors: "*" diff --git a/pipeline/CMakeLists.txt b/pipeline/CMakeLists.txt index afc522a..3a7c37d 100644 --- a/pipeline/CMakeLists.txt +++ b/pipeline/CMakeLists.txt @@ -4,78 +4,76 @@ project(biergarten-pipeline) # Boost.DI still declares a very old minimum CMake version, which newer CMake # releases reject unless a policy version floor is provided. set(CMAKE_POLICY_VERSION_MINIMUM 3.5 CACHE STRING "" FORCE) + # ============================================================================= -# 1. GPU Detection -# ============================================================================= -# GGML_CUDA / GGML_METAL are set here so that the llama.cpp FetchContent below -# inherits them as cache variables before its CMakeLists.txt is processed. -# ============================================================================= -# 1. Platform & GPU Detection +# 1. Platform & GPU Detection (Windows explicitly NOT supported) # ============================================================================= +if(WIN32) + message(FATAL_ERROR "[biergarten] Windows is currently not supported. Please use Linux (Fedora 43) or macOS (M1 Pro).") +endif() if(APPLE) - # Check if this is an M-series Mac (arm64) or Intel Mac (x86_64) if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64") message(STATUS "[biergarten] Apple Silicon detected — enabling Metal acceleration.") set(GGML_METAL ON CACHE BOOL "Enable Metal for Apple Silicon" FORCE) else() message(STATUS "[biergarten] Intel Mac detected — using CPU / Accelerate framework.") - # Explicitly turn off Metal so the build doesn't fail on x86_64 set(GGML_METAL OFF CACHE BOOL "Disable Metal for Intel Macs" FORCE) - # Note: llama.cpp will automatically detect and enable Apple's Accelerate framework here endif() - elseif(UNIX AND NOT APPLE) - # Search for NVIDIA CUDA Toolkit find_package(CUDAToolkit QUIET) - - # Search for AMD HIP/ROCm Toolkit find_package(HIP QUIET) if(CUDAToolkit_FOUND) message(STATUS "[biergarten] NVIDIA GPU detected — enabling CUDA acceleration.") set(GGML_CUDA ON CACHE BOOL "Enable CUDA for NVIDIA GPUs" FORCE) set(CMAKE_CUDA_ARCHITECTURES native) - elseif(HIP_FOUND OR EXISTS "/opt/rocm") message(STATUS "[biergarten] AMD GPU detected — enabling HIP/ROCm acceleration.") set(GGML_HIPBLAS ON CACHE BOOL "Enable HIP for AMD GPUs" FORCE) - else() message(STATUS "[biergarten] No NVIDIA or AMD GPU found — falling back to CPU.") endif() - -else() - message(FATAL_ERROR "[biergarten] Unrecognized platform. Windows is currently not supported.") endif() # ============================================================================= -# 2. Project-wide Settings +# 2. Project-wide Settings (Standard & Optimization) # ============================================================================= -set(CMAKE_CXX_STANDARD 23) + +# Downgrade to C++20 as per Google Style Guide +set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# GCC/Clang specific settings (warnings as errors) +add_compile_options(-Wall -Wextra -Werror -Wpedantic) + +# Release Build Optimization: Aggressive (-O3), Arch-specific, and LTO +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native -flto") + +# Debug Build Optimization: Fast and debuggable (-Og) +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og -g") + # ============================================================================= # 3. Dependencies # ============================================================================= include(FetchContent) -# --- libcurl ------------------------------------------------------------------ -# Prefer the system package; the build will fail at link time if absent and -# no system curl is found, so emit a fatal error early rather than a silent gap. + find_package(CURL QUIET) if(NOT CURL_FOUND) - message(FATAL_ERROR - "[biergarten] libcurl not found. Install it via your package manager " - "(e.g. 'sudo dnf install libcurl-devel') or set CURL_ROOT.") + message(FATAL_ERROR "[biergarten] libcurl not found. Install it (e.g. 'sudo dnf install libcurl-devel').") endif() -# --- llama.cpp ---------------------------------------------------------------- + +# Require system Boost for JSON and Program Options to speed up build times +find_package(Boost REQUIRED COMPONENTS json program_options) + FetchContent_Declare( llama-cpp GIT_REPOSITORY https://github.com/ggml-org/llama.cpp.git GIT_TAG b8739 ) FetchContent_MakeAvailable(llama-cpp) -# --- boost-ext/di ------------------------------------------------------------- + FetchContent_Declare( boost-di GIT_REPOSITORY https://github.com/boost-ext/di.git @@ -85,42 +83,33 @@ FetchContent_MakeAvailable(boost-di) if(TARGET Boost.DI AND NOT TARGET boost::di) add_library(boost::di ALIAS Boost.DI) endif() -# --- Boost (JSON + program_options) ------------------------------------------ -FetchContent_Declare( - boost - URL https://github.com/boostorg/boost/releases/download/boost-1.85.0/boost-1.85.0-cmake.tar.gz -) -FetchContent_MakeAvailable(boost) -# --- spdlog ------------------------------------------------------------------- + FetchContent_Declare( spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git GIT_TAG v1.15.3 ) FetchContent_MakeAvailable(spdlog) + # ============================================================================= # 4. Sources # ============================================================================= set(SOURCES src/main.cpp - # BiergartenDataGenerator methods src/biergarten_data_generator/biergarten_data_generator.cpp src/biergarten_data_generator/run.cpp src/biergarten_data_generator/query_cities_with_countries.cpp src/biergarten_data_generator/generate_breweries.cpp src/biergarten_data_generator/log_results.cpp - # WikipediaService methods src/services/wikipedia/wikipedia_service.cpp src/services/wikipedia/get_summary.cpp src/services/wikipedia/fetch_extract.cpp - # CURLWebClient and CurlGlobalState methods src/web_client/curl_global_state.cpp src/web_client/curl_web_client.cpp src/web_client/curl_web_client_download_to_file.cpp src/web_client/curl_web_client_get.cpp src/web_client/curl_web_client_utils.cpp src/web_client/curl_web_client_url_encode.cpp - # Data generation modules src/data_generation/llama/llama_generator.cpp src/data_generation/llama/generate_brewery.cpp src/data_generation/llama/generate_user.cpp @@ -134,12 +123,11 @@ set(SOURCES src/data_generation/mock/generate_user.cpp src/json_handling/json_loader.cpp ) + # ============================================================================= # 5. Target # ============================================================================= -add_executable(${PROJECT_NAME} - ${SOURCES} -) +add_executable(${PROJECT_NAME} ${SOURCES}) target_include_directories(${PROJECT_NAME} PRIVATE includes ${llama-cpp_SOURCE_DIR}/include @@ -148,8 +136,8 @@ target_include_directories(${PROJECT_NAME} PRIVATE target_link_libraries(${PROJECT_NAME} PRIVATE llama boost::di - boost_json - boost_program_options + Boost::json + Boost::program_options spdlog::spdlog CURL::libcurl ) @@ -157,8 +145,6 @@ target_link_libraries(${PROJECT_NAME} PRIVATE # ============================================================================= # 6. Runtime Assets # ============================================================================= -# Make locations.json available in the build directory for runtime relative path -# lookups (e.g. when running from ./build). configure_file( ${CMAKE_SOURCE_DIR}/locations.json ${CMAKE_BINARY_DIR}/locations.json diff --git a/pipeline/includes/biergarten_data_generator.h b/pipeline/includes/biergarten_data_generator.h index 7695cc4..6a9e4e9 100644 --- a/pipeline/includes/biergarten_data_generator.h +++ b/pipeline/includes/biergarten_data_generator.h @@ -1,5 +1,5 @@ -#ifndef BIERGARTEN_PIPELINE_BIERGARTEN_DATA_GENERATOR_H_ -#define BIERGARTEN_PIPELINE_BIERGARTEN_DATA_GENERATOR_H_ +#ifndef BIERGARTEN_PIPELINE_INCLUDES_BIERGARTEN_DATA_GENERATOR_H_ +#define BIERGARTEN_PIPELINE_INCLUDES_BIERGARTEN_DATA_GENERATOR_H_ /** * @file biergarten_data_generator.h @@ -117,6 +117,6 @@ class BiergartenDataGenerator { }; /// @brief Stores generated brewery data. - std::vector generatedBreweries_; + std::vector generated_breweries_; }; -#endif // BIERGARTEN_PIPELINE_BIERGARTEN_DATA_GENERATOR_H_ +#endif // BIERGARTEN_PIPELINE_INCLUDES_BIERGARTEN_DATA_GENERATOR_H_ diff --git a/pipeline/includes/data_generation/data_generator.h b/pipeline/includes/data_generation/data_generator.h index 70824ed..0f60bfc 100644 --- a/pipeline/includes/data_generation/data_generator.h +++ b/pipeline/includes/data_generation/data_generator.h @@ -1,5 +1,5 @@ -#ifndef BIERGARTEN_PIPELINE_DATA_GENERATION_DATA_GENERATOR_H_ -#define BIERGARTEN_PIPELINE_DATA_GENERATION_DATA_GENERATOR_H_ +#ifndef BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_DATA_GENERATOR_H_ +#define BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_DATA_GENERATOR_H_ /** * @file data_generation/data_generator.h @@ -69,4 +69,4 @@ class DataGenerator { virtual UserResult GenerateUser(const std::string& locale) = 0; }; -#endif // BIERGARTEN_PIPELINE_DATA_GENERATION_DATA_GENERATOR_H_ +#endif // BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_DATA_GENERATOR_H_ diff --git a/pipeline/includes/data_generation/llama_generator.h b/pipeline/includes/data_generation/llama_generator.h index 97d1232..fac2742 100644 --- a/pipeline/includes/data_generation/llama_generator.h +++ b/pipeline/includes/data_generation/llama_generator.h @@ -1,5 +1,5 @@ -#ifndef BIERGARTEN_PIPELINE_DATA_GENERATION_LLAMA_GENERATOR_H_ -#define BIERGARTEN_PIPELINE_DATA_GENERATION_LLAMA_GENERATOR_H_ +#ifndef BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_LLAMA_GENERATOR_H_ +#define BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_LLAMA_GENERATOR_H_ /** * @file data_generation/llama_generator.h @@ -120,4 +120,4 @@ class LlamaGenerator final : public DataGenerator { std::string brewery_system_prompt_; }; -#endif // BIERGARTEN_PIPELINE_DATA_GENERATION_LLAMA_GENERATOR_H_ +#endif // BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_LLAMA_GENERATOR_H_ diff --git a/pipeline/includes/data_generation/llama_generator_helpers.h b/pipeline/includes/data_generation/llama_generator_helpers.h index 00cb779..6feaccf 100644 --- a/pipeline/includes/data_generation/llama_generator_helpers.h +++ b/pipeline/includes/data_generation/llama_generator_helpers.h @@ -1,5 +1,5 @@ -#ifndef BIERGARTEN_PIPELINE_DATA_GENERATION_LLAMA_GENERATOR_HELPERS_H_ -#define BIERGARTEN_PIPELINE_DATA_GENERATION_LLAMA_GENERATOR_HELPERS_H_ +#ifndef BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_LLAMA_GENERATOR_HELPERS_H_ +#define BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_LLAMA_GENERATOR_HELPERS_H_ /** * @file data_generation/llama_generator_helpers.h @@ -85,4 +85,4 @@ std::string ValidateBreweryJsonPublic(const std::string& raw, */ std::string ExtractLastJsonObjectPublic(const std::string& text); -#endif // BIERGARTEN_PIPELINE_DATA_GENERATION_LLAMA_GENERATOR_HELPERS_H_ +#endif // BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_LLAMA_GENERATOR_HELPERS_H_ diff --git a/pipeline/includes/data_generation/mock_generator.h b/pipeline/includes/data_generation/mock_generator.h index b427fcf..f3ae71f 100644 --- a/pipeline/includes/data_generation/mock_generator.h +++ b/pipeline/includes/data_generation/mock_generator.h @@ -1,5 +1,5 @@ -#ifndef BIERGARTEN_PIPELINE_DATA_GENERATION_MOCK_GENERATOR_H_ -#define BIERGARTEN_PIPELINE_DATA_GENERATION_MOCK_GENERATOR_H_ +#ifndef BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_MOCK_GENERATOR_H_ +#define BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_MOCK_GENERATOR_H_ /** * @file data_generation/mock_generator.h @@ -51,4 +51,4 @@ class MockGenerator final : public DataGenerator { static const std::vector kBios; }; -#endif // BIERGARTEN_PIPELINE_DATA_GENERATION_MOCK_GENERATOR_H_ +#endif // BIERGARTEN_PIPELINE_INCLUDES_DATA_GENERATION_MOCK_GENERATOR_H_ diff --git a/pipeline/includes/data_model/location.h b/pipeline/includes/data_model/location.h index 02dee24..74d62b2 100644 --- a/pipeline/includes/data_model/location.h +++ b/pipeline/includes/data_model/location.h @@ -1,5 +1,5 @@ -#ifndef BIERGARTEN_PIPELINE_MODELS_LOCATION_H_ -#define BIERGARTEN_PIPELINE_MODELS_LOCATION_H_ +#ifndef BIERGARTEN_PIPELINE_INCLUDES_DATA_MODEL_LOCATION_H_ +#define BIERGARTEN_PIPELINE_INCLUDES_DATA_MODEL_LOCATION_H_ /** * @file data_model/location.h @@ -34,4 +34,4 @@ struct Location { double longitude; }; -#endif // BIERGARTEN_PIPELINE_MODELS_LOCATION_H_ +#endif // BIERGARTEN_PIPELINE_INCLUDES_DATA_MODEL_LOCATION_H_ diff --git a/pipeline/includes/json_handling/json_loader.h b/pipeline/includes/json_handling/json_loader.h index 3a65d1f..9b2ecc8 100644 --- a/pipeline/includes/json_handling/json_loader.h +++ b/pipeline/includes/json_handling/json_loader.h @@ -1,5 +1,5 @@ -#ifndef BIERGARTEN_PIPELINE_JSON_HANDLING_JSON_LOADER_H_ -#define BIERGARTEN_PIPELINE_JSON_HANDLING_JSON_LOADER_H_ +#ifndef BIERGARTEN_PIPELINE_INCLUDES_JSON_HANDLING_JSON_LOADER_H_ +#define BIERGARTEN_PIPELINE_INCLUDES_JSON_HANDLING_JSON_LOADER_H_ /** * @file json_handling/json_loader.h @@ -18,4 +18,4 @@ class JsonLoader { static std::vector LoadLocations(const std::string& filepath); }; -#endif // BIERGARTEN_PIPELINE_JSON_HANDLING_JSON_LOADER_H_ +#endif // BIERGARTEN_PIPELINE_INCLUDES_JSON_HANDLING_JSON_LOADER_H_ diff --git a/pipeline/includes/llama_backend_state.h b/pipeline/includes/llama_backend_state.h index 7800f19..c8cdcff 100644 --- a/pipeline/includes/llama_backend_state.h +++ b/pipeline/includes/llama_backend_state.h @@ -1,5 +1,5 @@ -#ifndef BIERGARTEN_PIPELINE_LLAMA_BACKEND_STATE_H_ -#define BIERGARTEN_PIPELINE_LLAMA_BACKEND_STATE_H_ +#ifndef BIERGARTEN_PIPELINE_INCLUDES_LLAMA_BACKEND_STATE_H_ +#define BIERGARTEN_PIPELINE_INCLUDES_LLAMA_BACKEND_STATE_H_ /** * @file llama_backend_state.h @@ -29,4 +29,4 @@ class LlamaBackendState { LlamaBackendState& operator=(const LlamaBackendState&) = delete; }; -#endif // BIERGARTEN_PIPELINE_LLAMA_BACKEND_STATE_H_ +#endif // BIERGARTEN_PIPELINE_INCLUDES_LLAMA_BACKEND_STATE_H_ diff --git a/pipeline/includes/services/enrichment_service.h b/pipeline/includes/services/enrichment_service.h index 7c60305..aa8c220 100644 --- a/pipeline/includes/services/enrichment_service.h +++ b/pipeline/includes/services/enrichment_service.h @@ -1,5 +1,5 @@ -#ifndef BIERGARTEN_PIPELINE_SERVICES_ENRICHMENT_SERVICE_H_ -#define BIERGARTEN_PIPELINE_SERVICES_ENRICHMENT_SERVICE_H_ +#ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_SERVICE_H_ +#define BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_SERVICE_H_ /** * @file services/enrichment_service.h @@ -27,4 +27,4 @@ class IEnrichmentService { virtual std::string GetLocationContext(const Location& loc) = 0; }; -#endif // BIERGARTEN_PIPELINE_SERVICES_ENRICHMENT_SERVICE_H_ \ No newline at end of file +#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_ENRICHMENT_SERVICE_H_ diff --git a/pipeline/includes/services/wikipedia_service.h b/pipeline/includes/services/wikipedia_service.h index 7b188c4..bfbd39d 100644 --- a/pipeline/includes/services/wikipedia_service.h +++ b/pipeline/includes/services/wikipedia_service.h @@ -1,5 +1,5 @@ -#ifndef BIERGARTEN_PIPELINE_WIKIPEDIA_SERVICE_H_ -#define BIERGARTEN_PIPELINE_WIKIPEDIA_SERVICE_H_ +#ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_WIKIPEDIA_SERVICE_H_ +#define BIERGARTEN_PIPELINE_INCLUDES_SERVICES_WIKIPEDIA_SERVICE_H_ /** * @file services/wikipedia_service.h @@ -30,4 +30,4 @@ class WikipediaService final : public IEnrichmentService { std::unordered_map extract_cache_; }; -#endif // BIERGARTEN_PIPELINE_WIKIPEDIA_SERVICE_H_ +#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_WIKIPEDIA_SERVICE_H_ diff --git a/pipeline/includes/web_client/curl_web_client.h b/pipeline/includes/web_client/curl_web_client.h index cf4a6e3..75d4046 100644 --- a/pipeline/includes/web_client/curl_web_client.h +++ b/pipeline/includes/web_client/curl_web_client.h @@ -1,5 +1,5 @@ -#ifndef BIERGARTEN_PIPELINE_WEB_CLIENT_CURL_WEB_CLIENT_H_ -#define BIERGARTEN_PIPELINE_WEB_CLIENT_CURL_WEB_CLIENT_H_ +#ifndef BIERGARTEN_PIPELINE_INCLUDES_WEB_CLIENT_CURL_WEB_CLIENT_H_ +#define BIERGARTEN_PIPELINE_INCLUDES_WEB_CLIENT_CURL_WEB_CLIENT_H_ /** * @file web_client/curl_web_client.h @@ -68,4 +68,4 @@ class CURLWebClient : public WebClient { std::string UrlEncode(const std::string& value) override; }; -#endif // BIERGARTEN_PIPELINE_WEB_CLIENT_CURL_WEB_CLIENT_H_ +#endif // BIERGARTEN_PIPELINE_INCLUDES_WEB_CLIENT_CURL_WEB_CLIENT_H_ diff --git a/pipeline/includes/web_client/web_client.h b/pipeline/includes/web_client/web_client.h index 21f98bc..1ef0bbf 100644 --- a/pipeline/includes/web_client/web_client.h +++ b/pipeline/includes/web_client/web_client.h @@ -1,5 +1,6 @@ -#ifndef BIERGARTEN_PIPELINE_WEB_CLIENT_WEB_CLIENT_H_ -#define BIERGARTEN_PIPELINE_WEB_CLIENT_WEB_CLIENT_H_ +#ifndef +BIERGARTEN_PIPELINE_INCLUDES_WEB_CLIENT_WEB_CLIENT_H_ +#define BIERGARTEN_PIPELINE_INCLUDES_WEB_CLIENT_WEB_CLIENT_H_ /** * @file web_client/web_client.h @@ -42,4 +43,4 @@ class WebClient { virtual std::string UrlEncode(const std::string& value) = 0; }; -#endif // BIERGARTEN_PIPELINE_WEB_CLIENT_WEB_CLIENT_H_ +#endif // BIERGARTEN_PIPELINE_INCLUDES_WEB_CLIENT_WEB_CLIENT_H_ diff --git a/pipeline/src/biergarten_data_generator/generate_breweries.cpp b/pipeline/src/biergarten_data_generator/generate_breweries.cpp index b5ade4d..8727913 100644 --- a/pipeline/src/biergarten_data_generator/generate_breweries.cpp +++ b/pipeline/src/biergarten_data_generator/generate_breweries.cpp @@ -10,7 +10,7 @@ void BiergartenDataGenerator::GenerateBreweries( const std::vector& cities) { spdlog::info("\n=== SAMPLE BREWERY GENERATION ==="); - generatedBreweries_.clear(); + generated_breweries_.clear(); size_t skipped_count = 0; @@ -20,7 +20,7 @@ void BiergartenDataGenerator::GenerateBreweries( BreweryLocation{enriched_city.location.city, enriched_city.location.country}, enriched_city.region_context); - generatedBreweries_.push_back(GeneratedBrewery{ + generated_breweries_.push_back(GeneratedBrewery{ .location = enriched_city.location, .brewery = brewery}); } catch (const std::exception& e) { ++skipped_count; diff --git a/pipeline/src/biergarten_data_generator/log_results.cpp b/pipeline/src/biergarten_data_generator/log_results.cpp index 041fb3a..5da3811 100644 --- a/pipeline/src/biergarten_data_generator/log_results.cpp +++ b/pipeline/src/biergarten_data_generator/log_results.cpp @@ -10,7 +10,7 @@ void BiergartenDataGenerator::LogResults() const { spdlog::info("\n=== GENERATED DATA DUMP ==="); size_t index = 1; - for (const auto& [location, brewery] : generatedBreweries_) { + for (const auto& [location, brewery] : generated_breweries_) { spdlog::info( "{}. city=\"{}\" country=\"{}\" state=\"{}\" " "iso3166_2={} lat={} lon={}", diff --git a/pipeline/src/biergarten_data_generator/query_cities_with_countries.cpp b/pipeline/src/biergarten_data_generator/query_cities_with_countries.cpp index 8b3972c..b0e80d1 100644 --- a/pipeline/src/biergarten_data_generator/query_cities_with_countries.cpp +++ b/pipeline/src/biergarten_data_generator/query_cities_with_countries.cpp @@ -14,8 +14,7 @@ static constexpr unsigned int brewery_amount = 4; -auto BiergartenDataGenerator::QueryCitiesWithCountries() - -> std::vector { +std::vector BiergartenDataGenerator::QueryCitiesWithCountries() { spdlog::info("\n=== GEOGRAPHIC DATA OVERVIEW ==="); const std::filesystem::path locations_path = "locations.json"; diff --git a/pipeline/src/biergarten_data_generator/run.cpp b/pipeline/src/biergarten_data_generator/run.cpp index f8f2595..e45e2ba 100644 --- a/pipeline/src/biergarten_data_generator/run.cpp +++ b/pipeline/src/biergarten_data_generator/run.cpp @@ -7,7 +7,7 @@ #include "biergarten_data_generator.h" -auto BiergartenDataGenerator::Run() -> bool { +bool BiergartenDataGenerator::Run() { try { const std::vector cities = QueryCitiesWithCountries(); std::vector enriched; diff --git a/pipeline/src/data_generation/llama/generate_brewery.cpp b/pipeline/src/data_generation/llama/generate_brewery.cpp index 79a933f..b47e50e 100644 --- a/pipeline/src/data_generation/llama/generate_brewery.cpp +++ b/pipeline/src/data_generation/llama/generate_brewery.cpp @@ -15,7 +15,7 @@ namespace { -auto ExtractFinalJsonPayload(std::string raw_response) -> std::string { +std::string ExtractFinalJsonPayload(std::string raw_response) { auto trim = [](std::string_view text) -> std::string_view { const std::size_t first = text.find_first_not_of(" \t\n\r"); if (first == std::string_view::npos) { @@ -58,9 +58,8 @@ auto ExtractFinalJsonPayload(std::string raw_response) -> std::string { } // namespace -auto LlamaGenerator::GenerateBrewery(const BreweryLocation& location, - const std::string& region_context) - -> BreweryResult { +BreweryResult LlamaGenerator::GenerateBrewery( + const BreweryLocation& location, const std::string& region_context) { /** * Preprocess and truncate region context to manageable size */ diff --git a/pipeline/src/data_generation/mock/deterministic_hash.cpp b/pipeline/src/data_generation/mock/deterministic_hash.cpp index 82e2142..fcbbe1d 100644 --- a/pipeline/src/data_generation/mock/deterministic_hash.cpp +++ b/pipeline/src/data_generation/mock/deterministic_hash.cpp @@ -9,8 +9,7 @@ #include "data_generation/mock_generator.h" -auto MockGenerator::DeterministicHash(const BreweryLocation& location) - -> std::size_t { +std::size_t MockGenerator::DeterministicHash(const BreweryLocation& location) { std::size_t seed = 0; boost::hash_combine(seed, location.city_name); boost::hash_combine(seed, location.country_name); diff --git a/pipeline/src/data_generation/mock/generate_brewery.cpp b/pipeline/src/data_generation/mock/generate_brewery.cpp index fdb32d3..e441a64 100644 --- a/pipeline/src/data_generation/mock/generate_brewery.cpp +++ b/pipeline/src/data_generation/mock/generate_brewery.cpp @@ -8,9 +8,8 @@ #include "data_generation/mock_generator.h" -auto MockGenerator::GenerateBrewery(const BreweryLocation& location, - const std::string& /*region_context*/) - -> BreweryResult { +BreweryResult MockGenerator::GenerateBrewery( + const BreweryLocation& location, const std::string& /*region_context*/) { const std::size_t hash = DeterministicHash(location); const std::string& adjective = diff --git a/pipeline/src/json_handling/json_loader.cpp b/pipeline/src/json_handling/json_loader.cpp index 907265d..e6e2d16 100644 --- a/pipeline/src/json_handling/json_loader.cpp +++ b/pipeline/src/json_handling/json_loader.cpp @@ -13,8 +13,8 @@ #include #include -static auto ReadRequiredString(const boost::json::object& object, - const char* key) -> std::string { +static std::string ReadRequiredString(const boost::json::object& object, + const char* key) { const boost::json::value* value = object.if_contains(key); if (value == nullptr || !value->is_string()) { throw std::runtime_error( @@ -23,8 +23,8 @@ static auto ReadRequiredString(const boost::json::object& object, return std::string(value->as_string().c_str()); } -static auto ReadRequiredNumber(const boost::json::object& object, - const char* key) -> double { +static double ReadRequiredNumber(const boost::json::object& object, + const char* key) { const boost::json::value* value = object.if_contains(key); if (value == nullptr || !value->is_number()) { throw std::runtime_error( @@ -33,8 +33,7 @@ static auto ReadRequiredNumber(const boost::json::object& object, return value->to_number(); } -auto JsonLoader::LoadLocations(const std::string& filepath) - -> std::vector { +std::vector JsonLoader::LoadLocations(const std::string& filepath) { std::ifstream input(filepath); if (!input.is_open()) { throw std::runtime_error("Failed to open locations file: " + filepath); @@ -44,7 +43,7 @@ auto JsonLoader::LoadLocations(const std::string& filepath) buffer << input.rdbuf(); const std::string content = buffer.str(); - boost::json::error_code error; + boost::system::error_code error; boost::json::value root = boost::json::parse(content, error); if (error) { throw std::runtime_error("Failed to parse locations JSON: " + diff --git a/pipeline/src/main.cpp b/pipeline/src/main.cpp index 1523364..4ee58b7 100644 --- a/pipeline/src/main.cpp +++ b/pipeline/src/main.cpp @@ -32,8 +32,8 @@ namespace di = boost::di; * @param options Output ApplicationOptions struct. * @return true if parsing succeeded and should proceed, false otherwise. */ -auto ParseArguments(const int argc, char** argv, - ApplicationOptions& options) noexcept -> bool { +bool ParseArguments(const int argc, char** argv, + ApplicationOptions& options) noexcept { prog_opts::options_description desc("Pipeline Options"); desc.add_options()("help,h", "Produce help message")( "mocked", prog_opts::bool_switch(), @@ -118,7 +118,7 @@ auto ParseArguments(const int argc, char** argv, } } -auto main(const int argc, char** argv) noexcept -> int { +int main(const int argc, char** argv) noexcept { try { const CurlGlobalState curl_state; const LlamaBackendState llama_backend_state; diff --git a/pipeline/src/services/wikipedia/fetch_extract.cpp b/pipeline/src/services/wikipedia/fetch_extract.cpp index 4eaadce..3deb1ae 100644 --- a/pipeline/src/services/wikipedia/fetch_extract.cpp +++ b/pipeline/src/services/wikipedia/fetch_extract.cpp @@ -11,7 +11,7 @@ #include "services/wikipedia_service.h" -auto WikipediaService::FetchExtract(std::string_view query) -> std::string { +std::string WikipediaService::FetchExtract(std::string_view query) { const std::string cache_key(query); const auto cache_it = this->extract_cache_.find(cache_key); if (cache_it != this->extract_cache_.end()) { diff --git a/pipeline/src/services/wikipedia/get_summary.cpp b/pipeline/src/services/wikipedia/get_summary.cpp index f83094d..d801195 100644 --- a/pipeline/src/services/wikipedia/get_summary.cpp +++ b/pipeline/src/services/wikipedia/get_summary.cpp @@ -9,7 +9,7 @@ #include "services/wikipedia_service.h" -auto WikipediaService::GetLocationContext(const Location& loc) -> std::string { +std::string WikipediaService::GetLocationContext(const Location& loc) { const std::string cache_key = loc.city + "|" + loc.country; const auto cache_it = cache_.find(cache_key); if (cache_it != cache_.end()) { diff --git a/pipeline/src/web_client/curl_web_client_utils.cpp b/pipeline/src/web_client/curl_web_client_utils.cpp index 70844bc..9ab76d9 100644 --- a/pipeline/src/web_client/curl_web_client_utils.cpp +++ b/pipeline/src/web_client/curl_web_client_utils.cpp @@ -7,7 +7,7 @@ #include -auto create_handle() -> CurlHandle { +CurlHandle create_handle() { CURL* handle = curl_easy_init(); if (handle == nullptr) { throw std::runtime_error( @@ -16,8 +16,8 @@ auto create_handle() -> CurlHandle { return CurlHandle(handle, &curl_easy_cleanup); } -auto set_common_get_options(CURL* curl, const std::string& url, - CurlTimeouts timeouts) -> void { +void set_common_get_options(CURL* curl, const std::string& url, + CurlTimeouts timeouts) { curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_USERAGENT, "biergarten-pipeline/0.1.0"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); diff --git a/pipeline/src/web_client/curl_web_client_utils.h b/pipeline/src/web_client/curl_web_client_utils.h index 47990e7..04b6e6c 100644 --- a/pipeline/src/web_client/curl_web_client_utils.h +++ b/pipeline/src/web_client/curl_web_client_utils.h @@ -1,5 +1,5 @@ -#ifndef BIERGARTEN_PIPELINE_WEB_CLIENT_CURL_WEB_CLIENT_UTILS_H_ -#define BIERGARTEN_PIPELINE_WEB_CLIENT_CURL_WEB_CLIENT_UTILS_H_ +#ifndef BIERGARTEN_PIPELINE_SRC_WEB_CLIENT_CURL_WEB_CLIENT_UTILS_H_ +#define BIERGARTEN_PIPELINE_SRC_WEB_CLIENT_CURL_WEB_CLIENT_UTILS_H_ /** * @file web_client/curl_web_client_utils.h @@ -23,4 +23,4 @@ CurlHandle create_handle(); void set_common_get_options(CURL* curl, const std::string& url, CurlTimeouts timeouts); -#endif // BIERGARTEN_PIPELINE_WEB_CLIENT_CURL_WEB_CLIENT_UTILS_H_ +#endif // BIERGARTEN_PIPELINE_SRC_WEB_CLIENT_CURL_WEB_CLIENT_UTILS_H_