diff --git a/.lgtm.yml b/.lgtm.yml new file mode 100644 index 00000000..de07e869 --- /dev/null +++ b/.lgtm.yml @@ -0,0 +1,9 @@ +extraction: + cpp: + prepare: + packages: + - libwebsockets-dev + - libuv1-dev + python: + python_setup: + version: 3 diff --git a/README.md b/README.md index e9159789..47ed0a55 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ > A library for easy HTTP and websockets messaging in C++ applications. [![Travis CI](https://img.shields.io/travis/BlueBrain/Rockets/master.svg?style=flat-square)](https://travis-ci.org/BlueBrain/Rockets) +[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/BlueBrain/Rockets.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/BlueBrain/Rockets/context:cpp) # Table of Contents diff --git a/js/README.md b/js/README.md index d7d3ed78..a21fd0a8 100644 --- a/js/README.md +++ b/js/README.md @@ -3,6 +3,7 @@ > A small client for [Rockets](../README.md) using [JSON RPC](https://www.jsonrpc.org) as communication contract over a [WebSocket](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket). [![Travis CI](https://img.shields.io/travis/BlueBrain/Rockets/master.svg?style=flat-square)](https://travis-ci.org/BlueBrain/Rockets) +[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/BlueBrain/Rockets.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/BlueBrain/Rockets/context:javascript) # Table of Contents diff --git a/python/README.md b/python/README.md index 30972735..bc0cb7a6 100644 --- a/python/README.md +++ b/python/README.md @@ -8,6 +8,7 @@ [![Latest version](https://img.shields.io/pypi/v/rockets.svg)](https://pypi.org/project/rockets/) [![Python versions](https://img.shields.io/pypi/pyversions/rockets.svg)](https://pypi.org/project/rockets/) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) +[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/BlueBrain/Rockets.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/BlueBrain/Rockets/context:python) # Table of Contents diff --git a/rockets/http/client.cpp b/rockets/http/client.cpp index c5f5d65d..7dd48ec8 100644 --- a/rockets/http/client.cpp +++ b/rockets/http/client.cpp @@ -132,7 +132,7 @@ std::future Client::request(const std::string& uri, const Method method, std::string body) { auto promise = std::make_shared>(); - auto callback = [promise](Response response) { + auto callback = [promise](Response&& response) { promise->set_value(std::move(response)); }; auto errorCallback = [promise](std::string e) { diff --git a/rockets/jsonrpc/asyncReceiverImpl.h b/rockets/jsonrpc/asyncReceiverImpl.h index 9182efc5..64c9a65c 100644 --- a/rockets/jsonrpc/asyncReceiverImpl.h +++ b/rockets/jsonrpc/asyncReceiverImpl.h @@ -17,6 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#pragma once + #include "receiverImpl.h" #include "utils.h" @@ -50,7 +52,7 @@ class AsyncReceiverImpl : public ReceiverImpl } const auto& func = _methods[method]; - func(request, [respond, requestID](const Response rep) { + func(request, [respond, requestID](const Response& rep) { // No reply for valid "notifications" (requests without an "id") if (requestID.is_null()) respond(json()); diff --git a/rockets/jsonrpc/cancellableReceiverImpl.h b/rockets/jsonrpc/cancellableReceiverImpl.h index adfe17f3..9deed453 100644 --- a/rockets/jsonrpc/cancellableReceiverImpl.h +++ b/rockets/jsonrpc/cancellableReceiverImpl.h @@ -17,6 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#pragma once + #include "asyncReceiverImpl.h" #include "helpers.h" #include "utils.h" diff --git a/rockets/jsonrpc/http.cpp b/rockets/jsonrpc/http.cpp index 3be31135..68549a0b 100644 --- a/rockets/jsonrpc/http.cpp +++ b/rockets/jsonrpc/http.cpp @@ -49,7 +49,7 @@ void HttpCommunicator::sendText(std::string message) // http::Client (which aborts pending requests, calling the error callback). const auto& cb = callback; client.request(url, http::Method::POST, std::move(message), - [cb](http::Response response) { + [cb](http::Response&& response) { if (cb) cb(ws::Request{std::move(response.body)}); }, diff --git a/rockets/jsonrpc/receiverImpl.h b/rockets/jsonrpc/receiverImpl.h index f9204bbf..b242d02a 100644 --- a/rockets/jsonrpc/receiverImpl.h +++ b/rockets/jsonrpc/receiverImpl.h @@ -17,6 +17,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#pragma once + #include "requestProcessor.h" #include "utils.h" diff --git a/rockets/jsonrpc/requester.cpp b/rockets/jsonrpc/requester.cpp index 88d589cb..29ae9cfc 100644 --- a/rockets/jsonrpc/requester.cpp +++ b/rockets/jsonrpc/requester.cpp @@ -105,7 +105,7 @@ ClientRequest Requester::request(const std::string& method, const std::string& params) { auto promise = std::make_shared>(); - auto callback = [promise](Response response) { + auto callback = [promise](Response&& response) { promise->set_value(std::move(response)); }; return {request(method, params, callback), promise->get_future(), diff --git a/rockets/jsonrpc/requester.h b/rockets/jsonrpc/requester.h index fa433a9d..dcd63c1e 100644 --- a/rockets/jsonrpc/requester.h +++ b/rockets/jsonrpc/requester.h @@ -80,7 +80,7 @@ class Requester : public Notifier const Params& params) { auto promise = std::make_shared>(); - auto callback = [promise](Response response) { + auto callback = [promise](const Response& response) { if (response.isError()) promise->set_exception( std::make_exception_ptr(response_error(response.error))); @@ -114,7 +114,7 @@ class Requester : public Notifier ClientRequest request(const std::string& method) { auto promise = std::make_shared>(); - auto callback = [promise](Response response) { + auto callback = [promise](const Response& response) { if (response.isError()) promise->set_exception( std::make_exception_ptr(response_error(response.error)));