diff --git a/script/e2e-kube.sh b/script/e2e-kube.sh index c027d8c99..af1aab0b0 100755 --- a/script/e2e-kube.sh +++ b/script/e2e-kube.sh @@ -142,7 +142,7 @@ if [[ ("${ESP_ROLLOUT_STRATEGY}" == "managed") && ("${BACKEND}" == "bookstore") # Here wait for 200 seconds. for l in {1..20} do - echo "Wait for the new config to propogate: ${l}" + echo "Wait for the new config to propagate: ${l}" check_http_service "${HOST}/shelves" 200 sleep 10 done diff --git a/script/presubmits b/script/presubmits index c7f975148..43affb025 100755 --- a/script/presubmits +++ b/script/presubmits @@ -63,7 +63,7 @@ function build_and_test() { } # For now, asan doesn't work for "t" tests Nginx has some global memory not freed, -# TODO: find a way to supress these memory leaks from Nginx. +# TODO: find a way to suppress these memory leaks from Nginx. function test_asan() { local message='Running asan unit-tests, integration tests & NGINX tests' local error='Asan Unit, Integration, NGINX, start_esp tests failed' diff --git a/script/release-qualify b/script/release-qualify index 48aefa0d2..9c573b2b8 100755 --- a/script/release-qualify +++ b/script/release-qualify @@ -167,7 +167,7 @@ function count_stress_failures() { RQ_TESTS+=(${DIR}) - # the ! -path ... exludes the root directory which is otherwise + # the ! -path ... excludes the root directory which is otherwise # included in the result done 3< <(find "${LOGS}/${SHA}" ! -path "${LOGS}/${SHA}" -type f -name 'long-run-test*.log') diff --git a/script/robot-style b/script/robot-style index 932e405a5..fc786d256 100755 --- a/script/robot-style +++ b/script/robot-style @@ -29,6 +29,8 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" . ${ROOT}/script/all-utilities || { echo "Cannot load Bash utilities" ; exit 1 ; } + + CLANG_FORMAT="$(which clang-format-7)" pushd ${ROOT} > /dev/null @@ -44,4 +46,6 @@ if [[ "${#CHANGED_FILES}" -ne 0 ]]; then exit 1 fi +. ${ROOT}/tools/spelling/check_spelling.sh check || { echo "Find spelling error" ; exit 1 ; } + popd diff --git a/script/validate_release.py b/script/validate_release.py index 7a1b7e222..f15be6818 100644 --- a/script/validate_release.py +++ b/script/validate_release.py @@ -81,7 +81,7 @@ gflags.DEFINE_boolean( 'detail', False, - 'Prints detailled output.' + 'Prints detailed output.' ) class Error(Exception): diff --git a/src/api_manager/auth/lib/json_util.h b/src/api_manager/auth/lib/json_util.h index a0f943a8f..86f6e0d6f 100644 --- a/src/api_manager/auth/lib/json_util.h +++ b/src/api_manager/auth/lib/json_util.h @@ -28,7 +28,7 @@ namespace auth { // Gets given JSON property by key name. const grpc_json *GetProperty(const grpc_json *json, const char *key); -// Gets the primitive value of the json with given path, seperated by ".". +// Gets the primitive value of the json with given path, separated by ".". bool GetPrimitiveFieldValue(const std::string &json, const std::string &payload_path, std::string *payload_value); diff --git a/src/api_manager/auth/service_account_token.h b/src/api_manager/auth/service_account_token.h index 13a099aae..0102de292 100644 --- a/src/api_manager/auth/service_account_token.h +++ b/src/api_manager/auth/service_account_token.h @@ -68,7 +68,7 @@ class ServiceAccountToken { return access_token_.is_valid(duration); } - // JWT token calcualted from client auth secret are audience dependent. + // JWT token calculated from client auth secret are audience dependent. enum JWT_TOKEN_TYPE { JWT_TOKEN_FOR_SERVICE_CONTROL = 0, JWT_TOKEN_FOR_CLOUD_TRACING, @@ -87,13 +87,13 @@ class ServiceAccountToken { const std::string& GetAuthToken() const { return access_token_.token(); } // Gets the auth token to access Google services. - // If client auth secret is specified, use it to calcualte JWT token. + // If client auth secret is specified, use it to calculate JWT token. // Otherwise, use the access token fetched from metadata server. const std::string& GetAuthToken(JWT_TOKEN_TYPE type); // Gets the auth token to access Google services. This method accepts an // audience parameter to set when generating JWT token. - // If client auth secret is specified, use it to calcualte JWT token. + // If client auth secret is specified, use it to calculate JWT token. // Otherwise, use the access token fetched from metadata server. const std::string& GetAuthToken(JWT_TOKEN_TYPE type, const std::string& audience); @@ -146,7 +146,7 @@ class ServiceAccountToken { // The client auth secret which can be used to generate JWT auth token. std::string client_auth_secret_; - // JWT tokens calcualted from client auth secrect. + // JWT tokens calculated from client auth secrect. JwtTokenInfo jwt_tokens_[JWT_TOKEN_TYPE_MAX]; // GCE service account access token fetched from GCE metadata server. diff --git a/src/api_manager/check_security_rules_test.cc b/src/api_manager/check_security_rules_test.cc index 217327a9b..4b2443dfc 100644 --- a/src/api_manager/check_security_rules_test.cc +++ b/src/api_manager/check_security_rules_test.cc @@ -387,7 +387,7 @@ class CheckSecurityRulesTest : public ::testing::Test { std::string ruleset_test_url_; }; -// Cache first miss then hit. In this case, "yes" is cached on miss and returnd +// Cache first miss then hit. In this case, "yes" is cached on miss and returned // on hit. TEST_F(CheckSecurityRulesTest, CheckAuthzCacheMissThenHitPositive) { std::string service_config = std::string(kServiceName) + kProducerProjectId + @@ -419,7 +419,7 @@ TEST_F(CheckSecurityRulesTest, CheckAuthzCacheMissThenHitPositive) { }); } -// Cache first miss then hit. In this case, "no" is cached on miss and returnd +// Cache first miss then hit. In this case, "no" is cached on miss and returned // on hit. TEST_F(CheckSecurityRulesTest, CheckAuthzCacheMissThenHitNegative) { std::string service_config = std::string(kServiceName) + kProducerProjectId + diff --git a/src/api_manager/config_manager_test.cc b/src/api_manager/config_manager_test.cc index 504a880ae..8d655915e 100644 --- a/src/api_manager/config_manager_test.cc +++ b/src/api_manager/config_manager_test.cc @@ -388,7 +388,7 @@ TEST_F(ConfigManagerServiceNameConfigIdTest, RepeatedTrigger) { } TEST_F(ConfigManagerServiceNameConfigIdTest, RolloutMultipleServiceConfig) { - std::function hanlder = [this](HTTPRequest* req) { + std::function handler = [this](HTTPRequest* req) { std::map data = { {"https://servicemanagement.googleapis.com/v1/services/" "service_name_from_metadata/configs/2017-05-01r0", @@ -412,8 +412,8 @@ TEST_F(ConfigManagerServiceNameConfigIdTest, RolloutMultipleServiceConfig) { req->url()); req->OnComplete(Status::OK, {}, kRolloutsResponseMultipleServiceConfig); })) - .WillOnce(Invoke(hanlder)) - .WillOnce(Invoke(hanlder)); + .WillOnce(Invoke(handler)) + .WillOnce(Invoke(handler)); int sequence = 0; @@ -442,7 +442,7 @@ TEST_F(ConfigManagerServiceNameConfigIdTest, RolloutMultipleServiceConfig) { TEST_F(ConfigManagerServiceNameConfigIdTest, RolloutMultipleServiceConfigPartiallyFailedThenSucceededNextTimerEvent) { - std::function first_hanlder = + std::function first_handler = [this](HTTPRequest* req) { std::map data = { {"https://servicemanagement.googleapis.com/v1/services/" @@ -456,7 +456,7 @@ TEST_F(ConfigManagerServiceNameConfigIdTest, } }; - std::function second_hanlder = + std::function second_handler = [this](HTTPRequest* req) { std::map data = { {"https://servicemanagement.googleapis.com/v1/services/" @@ -481,8 +481,8 @@ TEST_F(ConfigManagerServiceNameConfigIdTest, req->url()); req->OnComplete(Status::OK, {}, kRolloutsResponseMultipleServiceConfig); })) - .WillOnce(Invoke(first_hanlder)) - .WillOnce(Invoke(first_hanlder)) + .WillOnce(Invoke(first_handler)) + .WillOnce(Invoke(first_handler)) .WillOnce(Invoke([this](HTTPRequest* req) { EXPECT_EQ( "https://servicemanagement.googleapis.com/v1/services/" @@ -490,8 +490,8 @@ TEST_F(ConfigManagerServiceNameConfigIdTest, req->url()); req->OnComplete(Status::OK, {}, kRolloutsResponseMultipleServiceConfig); })) - .WillOnce(Invoke(second_hanlder)) - .WillOnce(Invoke(second_hanlder)); + .WillOnce(Invoke(second_handler)) + .WillOnce(Invoke(second_handler)); int sequence = 0; diff --git a/src/api_manager/config_test.cc b/src/api_manager/config_test.cc index 42e68311b..68bc420df 100644 --- a/src/api_manager/config_test.cc +++ b/src/api_manager/config_test.cc @@ -681,11 +681,11 @@ TEST(Config, RpcMethodsWithHttpRulesAndVariableBindings) { rules { selector: "Bookstore.CreateBook" parameters { - name: "system_paramter" + name: "system_parameter" url_query_parameter: "sys" } parameters { - name: "system_paramter" + name: "system_parameter" url_query_parameter: "system" } } diff --git a/src/api_manager/firebase_rules/firebase_request.cc b/src/api_manager/firebase_rules/firebase_request.cc index ce94125d7..d14460ac0 100644 --- a/src/api_manager/firebase_rules/firebase_request.cc +++ b/src/api_manager/firebase_rules/firebase_request.cc @@ -370,7 +370,7 @@ Status FirebaseRequest::CheckFuncCallArgs(const FunctionCall &func) { if (std::string(func.args(1).string_value()).empty()) { return Status( Code::INVALID_ARGUMENT, - func.function() + " argument 2 [HTTP METHOD] cannot be emtpy"); + func.function() + " argument 2 [HTTP METHOD] cannot be empty"); } return Status::OK; diff --git a/src/api_manager/firebase_rules/firebase_request.h b/src/api_manager/firebase_rules/firebase_request.h index e3ff2092d..de76cfd7b 100644 --- a/src/api_manager/firebase_rules/firebase_request.h +++ b/src/api_manager/firebase_rules/firebase_request.h @@ -79,7 +79,7 @@ struct HttpRequest { // A FirebaseRequest object understands the various http requests that need // to be generated as a part of the TestRuleset request and response cycle. -// Here is the intented use of this code: +// Here is the intended use of this code: // FirebaseRequest request(...); // while(!request.is_done()) { // std::string url, method, body; @@ -179,7 +179,7 @@ class FirebaseRequest { // defined HTTP endpoint. If next_request points to firebase_http_request_, // upon receiving a response, UpdateResponse will convert the response to // TestRulesetResponse and process the response. If next_request_ points - // to external_http_request_, then the reponse provided via UpdateResponse + // to external_http_request_, then the response provided via UpdateResponse // is converted into a protobuf::Value. This value is initialized to nullptr // and will be nullptr once is_done_ is set to true. HttpRequest *next_request_; diff --git a/src/api_manager/http_template.cc b/src/api_manager/http_template.cc index 18bc86832..8684e5ad2 100644 --- a/src/api_manager/http_template.cc +++ b/src/api_manager/http_template.cc @@ -328,7 +328,7 @@ class Parser { void PostProcessVariables() { for (auto &var : variables_) { if (var.has_wildcard_path) { - // if the variable contains a '**', store the end_positon + // if the variable contains a '**', store the end_position // relative to the end, such that -1 corresponds to the end // of the path. As we only support fixed path after '**', // this will allow the matcher code to reconstruct the variable @@ -337,7 +337,7 @@ class Parser { if (!verb_.empty()) { // a custom verb will add an additional segment, so - // the end_postion needs a -1 + // the end_position needs a -1 --var.end_segment; } } diff --git a/src/api_manager/proto/server_config.proto b/src/api_manager/proto/server_config.proto index b944051d9..bcc63a7c6 100644 --- a/src/api_manager/proto/server_config.proto +++ b/src/api_manager/proto/server_config.proto @@ -61,7 +61,7 @@ message ServerConfig { // The attributes from the metadata server MetadataAttributes metadata_attributes = 15; - // The overriden compute platform to be reported. + // The overridden compute platform to be reported. string compute_platform_override = 16; // The SSL credential for gRPC backend. diff --git a/src/api_manager/service_control/aggregated.h b/src/api_manager/service_control/aggregated.h index 7c70e055d..a2e77a1a2 100644 --- a/src/api_manager/service_control/aggregated.h +++ b/src/api_manager/service_control/aggregated.h @@ -144,7 +144,7 @@ class Aggregated : public Interface { template void HandleResponse(const ResponseType& response); - // the sevice config. + // the service config. const ::google::api::Service* service_; // the server config. const proto::ServerConfig* server_config_; diff --git a/src/api_manager/service_control/info.h b/src/api_manager/service_control/info.h index ffecbd4b2..3925d0d05 100644 --- a/src/api_manager/service_control/info.h +++ b/src/api_manager/service_control/info.h @@ -76,7 +76,7 @@ struct CheckRequestInfo : public OperationInfo { std::string ios_bundle_id; }; -// Stores the information substracted from the check response. +// Stores the information subtracted from the check response. struct CheckResponseInfo { // If the request have a valid api key. bool is_api_key_valid; diff --git a/src/grpc/message_serializer.cc b/src/grpc/message_serializer.cc index 66e61f1c6..65b888588 100644 --- a/src/grpc/message_serializer.cc +++ b/src/grpc/message_serializer.cc @@ -74,7 +74,7 @@ bool GrpcMessageSerializer::NextInternal(const unsigned char** data, messages_.front().first->data.raw.slice_buffer.count) { // The current buffer has been consumed, destroy it if needed if (messages_.front().second) { - // Destroy it if the ownership was transfered to GrpcMessageSerializer + // Destroy it if the ownership was transferred to GrpcMessageSerializer grpc_byte_buffer_destroy(messages_.front().first); } messages_.pop_front(); diff --git a/src/nginx/config.cc b/src/nginx/config.cc index f67b6272e..a5898013c 100644 --- a/src/nginx/config.cc +++ b/src/nginx/config.cc @@ -486,7 +486,7 @@ bool ngx_esp_parse_message_from_json(const std::string &json, // Reads server config from a string. Returns true if successful, otherwise // returns false. -// NOTE: This is similiar to ReadConfigFromString() in +// NOTE: This is similar to ReadConfigFromString() in // src/api_manager/config.cc. We are repeating it here to avoid additional // dependencies. If there are more utilities like this to be duplicated, // we should think of a place for utilities that are common for diff --git a/src/nginx/http.cc b/src/nginx/http.cc index d1720b01c..e818af478 100644 --- a/src/nginx/http.cc +++ b/src/nginx/http.cc @@ -917,7 +917,7 @@ Status initialize_request(ngx_pool_t *request_pool, // The main and server configuration contexts we use are from the HTTP module. // The local configuration context is built from scratch at our module - // initialization and is roughly equivelent in function to an empty location + // initialization and is roughly equivalent in function to an empty location // configuration block. r->main_conf = http_cctx->main_conf; r->srv_conf = http_cctx->srv_conf; diff --git a/src/nginx/module.cc b/src/nginx/module.cc index 3dc00e188..3908626f0 100644 --- a/src/nginx/module.cc +++ b/src/nginx/module.cc @@ -1116,7 +1116,7 @@ ngx_uint_t ngx_esp_count_active_connections(ngx_cycle_t *cycle) { // Attempts to shut down ESP, returns true if ESP is ready to exit. bool ngx_esp_attempt_shutdown(ngx_cycle_t *cycle) { - // The states ESP needs to go throught before it is ready to exit: + // The states ESP needs to go thought before it is ready to exit: // 1) Waits all current requests to be done before closing ESP service // control. This wait should not be long since when exit_handler // is called, all listen ports have been closed. diff --git a/src/nginx/request.cc b/src/nginx/request.cc index 87b096828..c66ae6161 100644 --- a/src/nginx/request.cc +++ b/src/nginx/request.cc @@ -85,7 +85,7 @@ ::google::api_manager::protocol::Protocol NgxEspRequest::GetBackendProtocol() { } std::string NgxEspRequest::GetClientIP() { - // use remote_addr varaible to get client_ip. + // use remote_addr variable to get client_ip. ngx_esp_main_conf_t *mc = reinterpret_cast( ngx_http_get_module_main_conf(r_, ngx_esp_module)); if (mc->remote_addr_variable_index != NGX_ERROR) { diff --git a/src/nginx/zero_copy_stream.h b/src/nginx/zero_copy_stream.h index 3b486d479..c95a55445 100644 --- a/src/nginx/zero_copy_stream.h +++ b/src/nginx/zero_copy_stream.h @@ -63,7 +63,7 @@ class NgxRequestZeroCopyInputStream private: // Advances to the next buffer. Returns true if successful; otherwise returns - // false (if no buffer is available or if an error occured). + // false (if no buffer is available or if an error occurred). bool NextBuffer(); // The request diff --git a/start_esp/start_esp.py b/start_esp/start_esp.py index 0ca0115c2..8a050e871 100755 --- a/start_esp/start_esp.py +++ b/start_esp/start_esp.py @@ -694,7 +694,7 @@ def make_argparser(): # The server_config dir to save server configs parser.add_argument('--server_config_dir', default=SERVER_CONF_DIR, - help='''Sets the folder for writting server config file. + help='''Sets the folder for writing server config file. The server config file is passed to ESP in Nginx config. If you are using your own nginx config, please be sure its server_config path matches this one. diff --git a/start_esp/trusted-ca-certificates.crt b/start_esp/trusted-ca-certificates.crt index 3698c60d0..3008929fb 100644 --- a/start_esp/trusted-ca-certificates.crt +++ b/start_esp/trusted-ca-certificates.crt @@ -6067,8 +6067,8 @@ BDNEJkpEBx9zoINBKeCSBrzVAer+vK9x6yAfCl0NoClezuRBUVWWwx+0MaWj81Pq/8KchnLPNkxW WgYyfl6rSqHOp+ufpIwquSSLuLXzBk2myn2Z+/ZV6q5Iee4mWdMfDFMV92JR+YQNlmxesQjmWQgr JikKwYNAcw== -----END CERTIFICATE----- -# Issuer: C=BR, O=ICP-Brasil, OU=Instituto Nacional de Tecnologia da Informacao - ITI, CN=Autoridade Certificadora Raiz Brasileira v1 -# Subject: C=BR, O=ICP-Brasil, OU=Instituto Nacional de Tecnologia da Informacao - ITI, CN=Autoridade Certificadora Raiz Brasileira v1 +# Issuer: C=BR, O=ICP-Brasil, OU=Institution Nacional de Tecnologia da Informacao - ITI, CN=Autoridade Certificadora Raiz Brasileira v1 +# Subject: C=BR, O=ICP-Brasil, OU=Institution Nacional de Tecnologia da Informacao - ITI, CN=Autoridade Certificadora Raiz Brasileira v1 # SHA256 Fingerprint: CB:D8:ED:38:D4:A2:D6:77:D4:53:D7:0D:D8:89:0A:F4:F6:37:4C:BA:62:99:94:3F:1A:B3:A6:93:6C:6F:D7:95 -----BEGIN CERTIFICATE----- MIIEgDCCA2igAwIBAgIBATANBgkqhkiG9w0BAQUFADCBlzELMAkGA1UEBhMCQlIxEzARBgNVBAoT @@ -6093,8 +6093,8 @@ moAlpVKeOQ7tOvR4B1/VKHoKSvXQw2f3jFgXbwoAoyYQtGAiOkpIpdrgqYTeQ9ufQ6c/KARHki/3 52R1IdJPgc6qPmQO4w6tVZp+lJs0wdCuaU4eo9mzh1facMJafYfN+b833u1WNfe3Ig5Pkrg/CN+c nphe8m+5+pss+M1F2HKyIA== -----END CERTIFICATE----- -# Issuer: C=BR, O=ICP-Brasil, OU=Instituto Nacional de Tecnologia da Informacao - ITI, CN=Autoridade Certificadora Raiz Brasileira v2 -# Subject: C=BR, O=ICP-Brasil, OU=Instituto Nacional de Tecnologia da Informacao - ITI, CN=Autoridade Certificadora Raiz Brasileira v2 +# Issuer: C=BR, O=ICP-Brasil, OU=Institution Nacional de Tecnologia da Informacao - ITI, CN=Autoridade Certificadora Raiz Brasileira v2 +# Subject: C=BR, O=ICP-Brasil, OU=Institution Nacional de Tecnologia da Informacao - ITI, CN=Autoridade Certificadora Raiz Brasileira v2 # SHA256 Fingerprint: FB:47:D9:2A:99:09:FD:4F:A9:BE:C0:27:37:54:3E:1F:35:14:CE:D7:47:40:7A:8D:9C:FA:39:7B:09:15:06:7C -----BEGIN CERTIFICATE----- MIIGoTCCBImgAwIBAgIBATANBgkqhkiG9w0BAQ0FADCBlzELMAkGA1UEBhMCQlIxEzARBgNVBAoT @@ -8911,8 +8911,8 @@ N8NWpNemGoAebDNyzVb7X+Xd3DBb7rhMs99asJEk4o0cMQ8pswcghdZ2yj66d4v49VCFDU82cWtV EglAOwMVOP7ll3hLKB24gLuOsvrgsh3CeIkps44M7ABfTke1ncvcTcLIdcg+UEbYfN+GyvVxKpQK bVdveOry1+XjV1R3W2KX1+yRzkJz3pBKv4IcldkZSND8mycZ+4nz5hATRNkCu8VfY29lmzE= -----END CERTIFICATE----- -# Issuer: C=UY, O=ADMINISTRACION NACIONAL DE CORREOS, OU=SERVICIOS ELECTRONICOS, CN=Correo Uruguayo - Root CA -# Subject: C=UY, O=ADMINISTRACION NACIONAL DE CORREOS, OU=SERVICIOS ELECTRONICOS, CN=Correo Uruguayo - Root CA +# Issuer: C=UY, O=ADMINISTRACION NACIONAL DE CORREOS, OU=SERVICIOS ELECTRONICS, CN=Correo Uruguayo - Root CA +# Subject: C=UY, O=ADMINISTRACION NACIONAL DE CORREOS, OU=SERVICIOS ELECTRONICS, CN=Correo Uruguayo - Root CA # SHA256 Fingerprint: 46:27:32:85:61:5D:96:E5:2D:A9:FC:2E:D8:C0:36:F1:0A:F3:D9:F6:28:0F:8D:28:87:06:C5:2B:20:11:B4:DA -----BEGIN CERTIFICATE----- MIIGGjCCBAKgAwIBAgIQAMoieQgjKvD1griF02Pd8TANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQG diff --git a/test/client/wrk_script.lua.temp b/test/client/wrk_script.lua.temp index 1d721f420..5cb2b4f6c 100644 --- a/test/client/wrk_script.lua.temp +++ b/test/client/wrk_script.lua.temp @@ -1,7 +1,7 @@ -- WRK script template -- Parameters: -- OUT: output file for JSON summary --- ERR: error reponse file prefix per thread +-- ERR: error response file prefix per thread -- HTTP_METHOD: request method -- REQUEST_BODY_FILE: request body file name diff --git a/tools/spelling/check_spelling.sh b/tools/spelling/check_spelling.sh new file mode 100755 index 000000000..efa313f42 --- /dev/null +++ b/tools/spelling/check_spelling.sh @@ -0,0 +1,111 @@ +# Copyright (C) Extensible Service Proxy Authors +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +################################################################################ +# + +#!/bin/bash + +# Applies requisite code formatters to the source tree +# check_spelling.sh + +# Why choose misspell? +# https://github.com/client9/misspell#what-are-other-misspelling-correctors-and-whats-wrong-with-them + +set -u +set -e + +VERSION="0.3.4" +LINUX_MISSPELL_SHA="34d489dbc5ddb4dfd6d3cfac9fde8660e6c37e6c" +MAC_MISSPELL_SHA="f2607e2297b9e8af562e384c38045033375c7433" +TMP_DIR="/tmp" +OS="" + +MISSPELL_ARGS="-error -o stderr" + +if [[ "$#" -lt 1 ]]; then + echo "Usage: $0 check|fix" + exit -1 +fi + +if [[ "$1" == "fix" ]]; then + MISSPELL_ARGS="-w" +fi + +if [[ "$(uname)" == "Darwin" ]]; then + OS="mac" +elif [[ "$(uname)" == "Linux" ]]; then + OS="linux" +else + echo "Current only support mac/Linux" + exit 1 +fi + +ROOTDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" +cd "$ROOTDIR" + + + +BIN_FILENAME="misspell_"${VERSION}"_"${OS}"_64bit.tar.gz" +# Install tools we need +if [[ ! -e "${TMP_DIR}/misspell" ]]; then + if ! wget https://github.com/client9/misspell/releases/download/v"${VERSION}"/"${BIN_FILENAME}" \ + -O "${TMP_DIR}/${BIN_FILENAME}" --no-verbose --tries=3 -o "${TMP_DIR}/wget.log"; then + cat "${TMP_DIR}/wget.log" + exit -1 + fi + tar -xvf "${TMP_DIR}/${BIN_FILENAME}" -C "${TMP_DIR}" &> /dev/null +fi + +ACTUAL_SHA="" +EXPECT_SHA="" + +if [[ "${OS}" == "linux" ]]; then + ACTUAL_SHA=$(sha1sum "${TMP_DIR}"/misspell|cut -d' ' -f1) + EXPECT_SHA="${LINUX_MISSPELL_SHA}" +else + ACTUAL_SHA=$(shasum -a 1 "${TMP_DIR}"/misspell|cut -d' ' -f1) + EXPECT_SHA="${MAC_MISSPELL_SHA}" +fi + +if [[ ! ${ACTUAL_SHA} == ${EXPECT_SHA} ]]; then + echo "Expect shasum is ${ACTUAL_SHA}, but actual is shasum ${EXPECT_SHA}" + exit 1 +fi + +chmod +x "${TMP_DIR}/misspell" + +# Spell checking +# All the skipping files are defined in tools/spelling/spelling_skip_files.txt +SPELLING_SKIP_FILES="${ROOTDIR}/tools/spelling/spelling_skip_files.txt" + +# All the ignore words are defined in tools/spelling/spelling_whitelist_words.txt +SPELLING_WHITELIST_WORDS_FILE="${ROOTDIR}/tools/spelling/spelling_whitelist_words.txt" + +WHITELIST_WORDS=$(echo -n $(cat "${SPELLING_WHITELIST_WORDS_FILE}" | \ + grep -v "^#"|grep -v "^$") | tr ' ' ',') + +SKIP_FILES=$(echo $(cat "${SPELLING_SKIP_FILES}") | sed "s| | -e |g") +git ls-files | grep -v -e "${SKIP_FILES}" | xargs "${TMP_DIR}/misspell" -i \ + "${WHITELIST_WORDS}" ${MISSPELL_ARGS} diff --git a/tools/spelling/spelling_skip_files.txt b/tools/spelling/spelling_skip_files.txt new file mode 100644 index 000000000..f935f8143 --- /dev/null +++ b/tools/spelling/spelling_skip_files.txt @@ -0,0 +1 @@ +third_party/nginx-tests diff --git a/tools/spelling/spelling_whitelist_words.txt b/tools/spelling/spelling_whitelist_words.txt new file mode 100644 index 000000000..e69de29bb