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 {
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";
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,
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
- 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 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
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";
Decoder
has 95 functions (exceeds 20 allowed). Consider refactoring. Open
export class Decoder {
/**
* Create an [[Incoming]] object.
*
* @param callback A [[DecoderCallbacks]] implementation.
IBApiNext
has 89 functions (exceeds 20 allowed). Consider refactoring. Open
export class IBApiNext {
/**
* Create an [[IBApiNext]] object.
*
* @param options Creation options.
OrderDecoder
has 84 functions (exceeds 20 allowed). Consider refactoring. Open
class OrderDecoder {
constructor(
private decoder: Decoder,
private contract: Contract,
private order: Order,
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.
IBApi
has 81 functions (exceeds 20 allowed). Consider refactoring. Open
export class IBApi extends EventEmitter {
/**
* Create a IB API object.
*
* @param options Creation options.
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:
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();
}
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,
- 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 reqMktData
has 93 lines of code (exceeds 25 allowed). Consider refactoring. Open
reqMktData(
tickerId: number,
contract: Contract,
genericTickList: string,
snapshot: boolean,
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) {
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();
}
- 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 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()
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,
Function reqMktData
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
reqMktData(
tickerId: number,
contract: Contract,
genericTickList: string,
snapshot: boolean,
- 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"