isaacgr/jaysonic

View on GitHub

Showing 6 of 14 total issues

File base.js has 336 lines of code (exceeds 250 allowed). Consider refactoring.
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");

Severity: Minor
Found in src/client/protocol/base.js - About 4 hrs to fix

    JsonRpcClientProtocol has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class JsonRpcClientProtocol {
      /**
       * JsonRpcClientProtocol contructor
       * @param {class} factory Instance of [JsonRpcClientFactory]{@link JsonRpcClientFactory}
       * @param {(1|2)} version JSON-RPC version to make requests with
    Severity: Minor
    Found in src/client/protocol/base.js - About 3 hrs to fix

      Function getResult has 47 lines of code (exceeds 30 allowed). Consider refactoring.
      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 = {
      Severity: Minor
      Found in src/server/protocol/base.js - About 1 hr to fix

        Function validateMessage has 40 lines of code (exceeds 30 allowed). Consider refactoring.
        Open

          validateMessage(message) {
            if (!(message === Object(message))) {
              this._raiseError(
                ERR_MSGS.invalidRequest,
                ERR_CODES.invalidRequest,
        Severity: Minor
        Found in src/server/protocol/base.js - About 1 hr to fix

          Function formatResponse has a Cognitive Complexity of 13 (exceeds 7 allowed). Consider refactoring.
          Open

          const formatResponse = ({
            jsonrpc, id, method, result, params, delimiter
          }) => {
            if (params && result) {
              throw new Error("Cannot send response with both params and result");
          Severity: Minor
          Found in src/util/format.js - About 1 hr to fix

          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

            verifyData(chunk) {
              try {
                // will throw an error if not valid json
                const message = JSON.parse(chunk);
                if (Array.isArray(message)) {
          Severity: Minor
          Found in src/client/protocol/base.js - About 45 mins to fix

          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

          Severity
          Category
          Status
          Source
          Language