Showing 497 of 497 total issues

Similar blocks of code found in 8 locations. Consider refactoring.
Open

      case IBApiTickType.MODEL_OPTION:
        ticks.push(
          [
            IBApiNextTickType.MODEL_OPTION_IV,
            { value: impliedVolatility, ingressTm: now },
Severity: Major
Found in src/api-next/api-next.ts and 7 other locations - About 4 hrs to fix
src/api-next/api-next.ts on lines 1242..1266
src/api-next/api-next.ts on lines 1267..1294
src/api-next/api-next.ts on lines 1295..1319
src/api-next/api-next.ts on lines 1320..1347
src/api-next/api-next.ts on lines 1348..1372
src/api-next/api-next.ts on lines 1373..1400
src/api-next/api-next.ts on lines 1429..1456

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 133.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 8 locations. Consider refactoring.
Open

      case IBApiTickType.DELAYED_MODEL_OPTION:
        ticks.push(
          [
            IBApiNextTickType.DELAYED_MODEL_OPTION_IV,
            { value: impliedVolatility, ingressTm: now },
Severity: Major
Found in src/api-next/api-next.ts and 7 other locations - About 4 hrs to fix
src/api-next/api-next.ts on lines 1242..1266
src/api-next/api-next.ts on lines 1267..1294
src/api-next/api-next.ts on lines 1295..1319
src/api-next/api-next.ts on lines 1320..1347
src/api-next/api-next.ts on lines 1348..1372
src/api-next/api-next.ts on lines 1373..1400
src/api-next/api-next.ts on lines 1401..1428

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 133.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (
      this.serverVersion >= 8 &&
      SecType.BAG === contract.secType?.toUpperCase()
    ) {
      if (!contract.comboLegs) {
Severity: Major
Found in src/core/io/encoder.ts and 1 other location - About 4 hrs to fix
src/core/io/encoder.ts on lines 2254..2266

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 132.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (SecType.BAG === contract.secType?.toUpperCase()) {
      if (!contract.comboLegs) {
        tokens.push(0);
      } else {
        tokens.push(contract.comboLegs.length);
Severity: Major
Found in src/core/io/encoder.ts and 1 other location - About 4 hrs to fix
src/core/io/encoder.ts on lines 2513..2528

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 132.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  private decodeMsg_NEWS_PROVIDERS(): void {
    const nNewsProviders = this.readInt();
    const newProviders: NewsProvider[] = new Array(nNewsProviders);
    for (let i = 0; i < nNewsProviders; i++) {
      newProviders[i] = {
Severity: Major
Found in src/core/io/decoder.ts and 1 other location - About 4 hrs to fix
src/core/io/decoder.ts on lines 2085..2097

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 124.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

  private decodeMsg_FAMILY_CODES(): void {
    const nFamilyCodes = this.readInt();

    const familyCodes: FamilyCode[] = new Array(nFamilyCodes);
    for (let i = 0; i < nFamilyCodes; i++) {
Severity: Major
Found in src/core/io/decoder.ts and 1 other location - About 4 hrs to fix
src/core/io/decoder.ts on lines 2241..2252

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 124.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            case OrderConditionType.PercentChange: {
              // OperatorCondition
              const isMore = this.decoder.readBool();
              const value = this.decoder.readDouble();
              // ContractCondition
Severity: Major
Found in src/core/io/decoder.ts and 1 other location - About 4 hrs to fix
src/core/io/decoder.ts on lines 3387..3403

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 123.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            case OrderConditionType.Volume: {
              // OperatorCondition
              const isMore = this.decoder.readBool();
              const value = this.decoder.readInt();
              // ContractCondition
Severity: Major
Found in src/core/io/decoder.ts and 1 other location - About 4 hrs to fix
src/core/io/decoder.ts on lines 3335..3351

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 123.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (this.serverVersion >= MIN_SERVER_VER.DELTA_NEUTRAL) {
      if (contract.deltaNeutralContract) {
        args.push(true);
        args.push(contract.deltaNeutralContract.conId);
        args.push(contract.deltaNeutralContract.delta);
Severity: Major
Found in src/core/io/encoder.ts and 1 other location - About 3 hrs to fix
src/core/io/encoder.ts on lines 1511..1520

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 113.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    if (this.serverVersion >= MIN_SERVER_VER.DELTA_NEUTRAL) {
      if (contract.deltaNeutralContract) {
        tokens.push(true);
        tokens.push(contract.deltaNeutralContract.conId);
        tokens.push(contract.deltaNeutralContract.delta);
Severity: Major
Found in src/core/io/encoder.ts and 1 other location - About 3 hrs to fix
src/core/io/encoder.ts on lines 2530..2539

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 113.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          private decodeMsg_NEWS_BULLETINS(): void {
            this.readInt(); // version
            const newsMsgId = this.readInt();
            const newsMsgType = this.readInt();
            const newsMessage = this.readStr();
        Severity: Major
        Found in src/core/io/decoder.ts and 1 other location - About 3 hrs to fix
        src/core/io/decoder.ts on lines 837..845

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 105.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            this.api
              .getUserInfo()
              .then((whiteBrandingId) => {
                this.printText(`User Info. WhiteBrandingId: '${whiteBrandingId}'`);
                this.stop();
        Severity: Major
        Found in src/tools/user-info.ts and 1 other location - About 3 hrs to fix
        src/tools/next-valid-order-id.ts on lines 34..42

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 105.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          private decodeMsg_ACCT_VALUE(): void {
            this.readInt(); // version
            const key = this.readStr();
            const value = this.readStr();
            const currency = this.readStr();
        Severity: Major
        Found in src/core/io/decoder.ts and 1 other location - About 3 hrs to fix
        src/core/io/decoder.ts on lines 1233..1247

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 105.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            this.api
              .getNextValidOrderId()
              .then((id) => {
                this.printText(`${id}`);
                this.exit();
        Severity: Major
        Found in src/tools/next-valid-order-id.ts and 1 other location - About 3 hrs to fix
        src/tools/user-info.ts on lines 32..40

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 105.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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
          Severity
          Category
          Status
          Source
          Language