Showing 142 of 497 total issues

File decoder.ts has 2690 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Contract } from "../../api/contract/contract";
import { ContractDescription } from "../../api/contract/contractDescription";
import { ContractDetails } from "../../api/contract/contractDetails";
import { DeltaNeutralContract } from "../../api/contract/deltaNeutralContract";
import {
Severity: Major
Found in src/core/io/decoder.ts - About 1 wk to fix

    File encoder.ts has 2569 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { MarketDataType, WhatToShow } from "../..";
    import { ScanCode } from "../../api-next/market-scanner/market-scanner";
    import { Contract } from "../../api/contract/contract";
    import WshEventData from "../../api/contract/wsh";
    import TagValue from "../../api/data/container/tag-value";
    Severity: Major
    Found in src/core/io/encoder.ts - About 1 wk to fix

      File api-next.ts has 2116 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { lastValueFrom, Observable, Subject } from "rxjs";
      import { map } from "rxjs/operators";
      import {
        Bar,
        BarSizeSetting,
      Severity: Major
      Found in src/api-next/api-next.ts - About 5 days to fix

        Function placeOrder has a Cognitive Complexity of 248 (exceeds 5 allowed). Consider refactoring.
        Open

          placeOrder(id: number, contract: Contract, order: Order): void {
            if (this.serverVersion < MIN_SERVER_VER.SCALE_ORDERS) {
              if (
                order.scaleInitLevelSize !== undefined ||
                order.scalePriceIncrement !== undefined
        Severity: Minor
        Found in src/core/io/encoder.ts - About 5 days 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 placeOrder has 884 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          placeOrder(id: number, contract: Contract, order: Order): void {
            if (this.serverVersion < MIN_SERVER_VER.SCALE_ORDERS) {
              if (
                order.scaleInitLevelSize !== undefined ||
                order.scalePriceIncrement !== undefined
        Severity: Major
        Found in src/core/io/encoder.ts - About 4 days to fix

          File api.ts has 1282 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /*
           * Typescript implementation of the Interactive Brokers TWS (or IB Gateway) API.
           */
          /* eslint @typescript-eslint/no-unsafe-declaration-merging:warn */
          import { EventEmitter } from "eventemitter3";
          Severity: Major
          Found in src/api/api.ts - About 3 days to fix

            Decoder has 95 functions (exceeds 20 allowed). Consider refactoring.
            Open

            export class Decoder {
              /**
               * Create an [[Incoming]] object.
               *
               * @param callback A [[DecoderCallbacks]] implementation.
            Severity: Major
            Found in src/core/io/decoder.ts - About 1 day to fix

              IBApiNext has 89 functions (exceeds 20 allowed). Consider refactoring.
              Open

              export class IBApiNext {
                /**
                 * Create an [[IBApiNext]] object.
                 *
                 * @param options Creation options.
              Severity: Major
              Found in src/api-next/api-next.ts - About 1 day to fix

                OrderDecoder has 84 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class OrderDecoder {
                  constructor(
                    private decoder: Decoder,
                    private contract: Contract,
                    private order: Order,
                Severity: Major
                Found in src/core/io/decoder.ts - About 1 day to fix

                  Encoder has 82 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  export class Encoder {
                    /**
                     * Create an [[Encoder]] object for encoding messages to token data.
                     *
                     * @param callback A [[EncoderCallbacks]] implementation.
                  Severity: Major
                  Found in src/core/io/encoder.ts - About 1 day to fix

                    IBApi has 81 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    export class IBApi extends EventEmitter {
                      /**
                       * Create a IB API object.
                       *
                       * @param options Creation options.
                    Severity: Major
                    Found in src/api/api.ts - About 1 day to fix

                      Function processMsg has 164 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        processMsg(msgId: IN_MSG_ID): void {
                          switch (msgId) {
                            case IN_MSG_ID.TICK_PRICE:
                              return this.decodeMsg_TICK_PRICE();
                            case IN_MSG_ID.TICK_SIZE:
                      Severity: Major
                      Found in src/core/io/decoder.ts - About 6 hrs to fix

                        Function decodeMsg_CONTRACT_DATA has 125 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          private decodeMsg_CONTRACT_DATA(): void {
                            let version = 8;
                            if (this.serverVersion < MIN_SERVER_VER.SIZE_RULES) {
                              version = this.readInt();
                            }
                        Severity: Major
                        Found in src/core/io/decoder.ts - About 5 hrs to fix

                          Function reqContractDetails has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                          Open

                            reqContractDetails(reqId: number, contract: Contract): void {
                              if (this.serverVersion < 4) {
                                return this.emitError(
                                  "This feature is only available for versions of TWS >=4",
                                  ErrorCode.UPDATE_TWS,
                          Severity: Minor
                          Found in src/core/io/encoder.ts - About 4 hrs 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 reqMktData has 93 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            reqMktData(
                              tickerId: number,
                              contract: Contract,
                              genericTickList: string,
                              snapshot: boolean,
                          Severity: Major
                          Found in src/core/io/encoder.ts - About 3 hrs to fix

                            Function readConditions has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              readConditions(): void {
                                if (this.serverVersion >= MIN_SERVER_VER.PEGGED_TO_BENCHMARK) {
                                  const nConditions = this.decoder.readInt();
                            
                                  if (nConditions > 0) {
                            Severity: Major
                            Found in src/core/io/decoder.ts - About 3 hrs to fix

                              Function decodeMsg_CONTRACT_DATA has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                              Open

                                private decodeMsg_CONTRACT_DATA(): void {
                                  let version = 8;
                                  if (this.serverVersion < MIN_SERVER_VER.SIZE_RULES) {
                                    version = this.readInt();
                                  }
                              Severity: Minor
                              Found in src/core/io/decoder.ts - About 3 hrs 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 decodeMsg_OPEN_ORDER has 88 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                private decodeMsg_OPEN_ORDER(): void {
                                  // read version
                                  const version =
                                    this.serverVersion < MIN_SERVER_VER.ORDER_CONTAINER
                                      ? this.readInt()
                              Severity: Major
                              Found in src/core/io/decoder.ts - About 3 hrs to fix

                                Function reqContractDetails has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                  reqContractDetails(reqId: number, contract: Contract): void {
                                    if (this.serverVersion < 4) {
                                      return this.emitError(
                                        "This feature is only available for versions of TWS >=4",
                                        ErrorCode.UPDATE_TWS,
                                Severity: Major
                                Found in src/core/io/encoder.ts - About 3 hrs to fix

                                  Function reqMktData has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                    reqMktData(
                                      tickerId: number,
                                      contract: Contract,
                                      genericTickList: string,
                                      snapshot: boolean,
                                  Severity: Minor
                                  Found in src/core/io/encoder.ts - About 3 hrs 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