Showing 6 of 14 total issues
File base.js
has 336 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
const { formatRequest, formatError } = require("../../util/format");
const { ERR_CODES, ERR_MSGS } = require("../../util/constants");
const MessageBuffer = require("../../util/buffer");
const logging = require("../../util/logger");
JsonRpcClientProtocol
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class JsonRpcClientProtocol {
/**
* JsonRpcClientProtocol contructor
* @param {class} factory Instance of [JsonRpcClientFactory]{@link JsonRpcClientFactory}
* @param {(1|2)} version JSON-RPC version to make requests with
Function getResult
has 47 lines of code (exceeds 30 allowed). Consider refactoring. Open
Open
getResult(message) {
// function needs to be async since the method can be a promise
return new Promise((resolve, reject) => {
const { params } = message;
const response = {
Function validateMessage
has 40 lines of code (exceeds 30 allowed). Consider refactoring. Open
Open
validateMessage(message) {
if (!(message === Object(message))) {
this._raiseError(
ERR_MSGS.invalidRequest,
ERR_CODES.invalidRequest,
Function formatResponse
has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring. Open
Open
const formatResponse = ({
jsonrpc, id, method, result, params, delimiter
}) => {
if (params && result) {
throw new Error("Cannot send response with both params and result");
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function verifyData
has a Cognitive Complexity of 10 (exceeds 7 allowed). Consider refactoring. Open
Open
verifyData(chunk) {
try {
// will throw an error if not valid json
const message = JSON.parse(chunk);
if (Array.isArray(message)) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"