From 83a019d021ccac037af677d6a0d19065d1e61c8a Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Tue, 3 Sep 2019 02:17:36 +0300 Subject: [build] Fix clang format and tidy checks --- include/mbgl/util/default_styles.hpp | 13 ++++++++----- include/mbgl/util/util.hpp | 2 ++ platform/default/src/mbgl/storage/http_file_source.cpp | 12 ++++++------ platform/default/src/mbgl/util/format_number.cpp | 10 +++++----- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/include/mbgl/util/default_styles.hpp b/include/mbgl/util/default_styles.hpp index 335d3ea5f9..e1c53178b0 100644 --- a/include/mbgl/util/default_styles.hpp +++ b/include/mbgl/util/default_styles.hpp @@ -1,7 +1,8 @@ #pragma once -#include +#include #include +#include namespace mbgl { namespace util { @@ -13,17 +14,19 @@ struct DefaultStyle { const unsigned currentVersion; }; +// clang-format off constexpr const DefaultStyle streets = { "mapbox://styles/mapbox/streets-v11", "Streets", 11 }; constexpr const DefaultStyle outdoors = { "mapbox://styles/mapbox/outdoors-v11", "Outdoors", 11 }; constexpr const DefaultStyle light = { "mapbox://styles/mapbox/light-v10", "Light", 10 }; constexpr const DefaultStyle dark = { "mapbox://styles/mapbox/dark-v10", "Dark", 10 }; constexpr const DefaultStyle satellite = { "mapbox://styles/mapbox/satellite-v9", "Satellite", 9 }; constexpr const DefaultStyle satelliteStreets = { "mapbox://styles/mapbox/satellite-streets-v11", "Satellite Streets", 11 }; +// clang-format on -const DefaultStyle orderedStyles[] = { - streets, outdoors, light, dark, satellite, satelliteStreets, -}; -const size_t numOrderedStyles = sizeof(orderedStyles) / sizeof(DefaultStyle); +constexpr std::array orderedStyles = { + {streets, outdoors, light, dark, satellite, satelliteStreets}}; + +constexpr size_t numOrderedStyles = orderedStyles.size(); } // end namespace default_styles } // end namespace util diff --git a/include/mbgl/util/util.hpp b/include/mbgl/util/util.hpp index 178f1cba48..52d9ad85b7 100644 --- a/include/mbgl/util/util.hpp +++ b/include/mbgl/util/util.hpp @@ -23,6 +23,7 @@ // Compiler defines for making symbols visible, otherwise they // will be defined as hidden by default. +// clang-format off #if defined WIN32 #ifdef MBGL_BUILDING_LIB #ifdef __GNUC__ @@ -40,3 +41,4 @@ #else #define MBGL_EXPORT __attribute__((visibility ("default"))) // NOLINT #endif +// clang-format on diff --git a/platform/default/src/mbgl/storage/http_file_source.cpp b/platform/default/src/mbgl/storage/http_file_source.cpp index fad877ed08..b0390c58fc 100644 --- a/platform/default/src/mbgl/storage/http_file_source.cpp +++ b/platform/default/src/mbgl/storage/http_file_source.cpp @@ -321,7 +321,7 @@ size_t HTTPRequest::headerCallback(char *const buffer, const size_t size, const // Always overwrite the modification date; We might already have a value here from the // Date header, but this one is more accurate. const std::string value { buffer + begin, length - begin - 2 }; // remove \r\n - baton->response->modified = Timestamp{ Seconds(curl_getdate(value.c_str(), nullptr)) }; + baton->response->modified = Timestamp{Seconds(curl_getdate(value.c_str(), nullptr))}; } else if ((begin = headerMatches("etag: ", buffer, length)) != std::string::npos) { baton->response->etag = std::string(buffer + begin, length - begin - 2); // remove \r\n } else if ((begin = headerMatches("cache-control: ", buffer, length)) != std::string::npos) { @@ -331,7 +331,7 @@ size_t HTTPRequest::headerCallback(char *const buffer, const size_t size, const baton->response->mustRevalidate = cc.mustRevalidate; } else if ((begin = headerMatches("expires: ", buffer, length)) != std::string::npos) { const std::string value { buffer + begin, length - begin - 2 }; // remove \r\n - baton->response->expires = Timestamp{ Seconds(curl_getdate(value.c_str(), nullptr)) }; + baton->response->expires = Timestamp{Seconds(curl_getdate(value.c_str(), nullptr))}; } else if ((begin = headerMatches("retry-after: ", buffer, length)) != std::string::npos) { baton->retryAfter = std::string(buffer + begin, length - begin - 2); // remove \r\n } else if ((begin = headerMatches("x-rate-limit-reset: ", buffer, length)) != std::string::npos) { @@ -357,13 +357,13 @@ void HTTPRequest::handleResult(CURLcode code) { case CURLE_COULDNT_CONNECT: case CURLE_OPERATION_TIMEDOUT: - response->error = std::make_unique( - Error::Reason::Connection, std::string{ curl_easy_strerror(code) } + ": " + error); + response->error = std::make_unique(Error::Reason::Connection, + std::string{curl_easy_strerror(code)} + ": " + error); break; default: - response->error = std::make_unique( - Error::Reason::Other, std::string{ curl_easy_strerror(code) } + ": " + error); + response->error = + std::make_unique(Error::Reason::Other, std::string{curl_easy_strerror(code)} + ": " + error); break; } } else { diff --git a/platform/default/src/mbgl/util/format_number.cpp b/platform/default/src/mbgl/util/format_number.cpp index f58d6e100a..d1b51e11a1 100644 --- a/platform/default/src/mbgl/util/format_number.cpp +++ b/platform/default/src/mbgl/util/format_number.cpp @@ -24,13 +24,13 @@ std::string formatNumber(double number, const std::string& localeId, const std:: } else { ustr = icu::number::NumberFormatter::with() #if U_ICU_VERSION_MAJOR_NUM >= 62 - .precision(icu::number::Precision::minMaxFraction(minFractionDigits, maxFractionDigits)) + .precision(icu::number::Precision::minMaxFraction(minFractionDigits, maxFractionDigits)) #else - .rounding(icu::number::Rounder::minMaxFraction(minFractionDigits, maxFractionDigits)) + .rounding(icu::number::Rounder::minMaxFraction(minFractionDigits, maxFractionDigits)) #endif - .locale(locale) - .formatDouble(number, status) - .toString(); + .locale(locale) + .formatDouble(number, status) + .toString(); } return ustr.toUTF8String(formatted); } -- cgit v1.2.1