Showing 497 of 497 total issues

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

Function reqHistoricalData has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  reqHistoricalData(
    tickerId: number,
    contract: Contract,
    endDateTime: string,
    durationStr: string,
Severity: Major
Found in src/core/io/encoder.ts - About 3 hrs to fix

    Function readVolOrderParams has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

      readVolOrderParams(readOpenOrderAttribs: boolean): void {
        if (this.version >= 11) {
          this.order.volatility = this.decoder.readDoubleOrUndefined();
          this.order.volatilityType = this.decoder.readInt();
          if (this.version == 11) {
    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

    File socket.ts has 299 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import net from "net";
    import { TextEncoder } from "util";
    
    import {
      IBApiCreationOptions,
    Severity: Minor
    Found in src/core/io/socket.ts - About 3 hrs to fix

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

          this.subscription$ = this.api.getPositions().subscribe({
            next: (positions) => {
              this.printObject(positions);
              if (!this.cmdLineArgs.watch) {
                this.stop();
      Severity: Major
      Found in src/tools/positions.ts and 3 other locations - About 3 hrs to fix
      src/tools/account-summary.ts on lines 62..77
      src/tools/pnl-single.ts on lines 51..67
      src/tools/pnl.ts on lines 43..58

      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 97.

      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 4 locations. Consider refactoring.
      Open

          this.subscription$ = this.api
            .getPnL(
              this.cmdLineArgs.account as string,
              this.cmdLineArgs.model as string,
            )
      Severity: Major
      Found in src/tools/pnl.ts and 3 other locations - About 3 hrs to fix
      src/tools/account-summary.ts on lines 62..77
      src/tools/pnl-single.ts on lines 51..67
      src/tools/positions.ts on lines 38..48

      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 97.

      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 4 locations. Consider refactoring.
      Open

          this.subscription$ = this.api
            .getPnLSingle(
              this.cmdLineArgs.account as string,
              this.cmdLineArgs.model as string,
              this.cmdLineArgs.conid as number,
      Severity: Major
      Found in src/tools/pnl-single.ts and 3 other locations - About 3 hrs to fix
      src/tools/account-summary.ts on lines 62..77
      src/tools/pnl.ts on lines 43..58
      src/tools/positions.ts on lines 38..48

      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 97.

      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 4 locations. Consider refactoring.
      Open

          this.subscription$ = this.api
            .getAccountSummary(
              (this.cmdLineArgs.group as string) ?? DEFAULT_GROUP,
              (this.cmdLineArgs.tags as string) ?? DEFAULT_TAGS,
            )
      Severity: Major
      Found in src/tools/account-summary.ts and 3 other locations - About 3 hrs to fix
      src/tools/pnl-single.ts on lines 51..67
      src/tools/pnl.ts on lines 43..58
      src/tools/positions.ts on lines 38..48

      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 97.

      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 exerciseOptions has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        exerciseOptions(
          tickerId: number,
          contract: Contract,
          exerciseAction: OptionExerciseAction,
          exerciseQuantity: number,
      Severity: Major
      Found in src/core/io/encoder.ts - About 3 hrs to fix

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

            this.api
              .getManagedAccounts()
              .then((accounts) => {
                this.printObject(accounts);
                this.stop();
        Severity: Major
        Found in src/tools/managed-accts.ts and 1 other location - About 3 hrs to fix
        src/tools/market-depth-exchanges.ts on lines 35..45

        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 96.

        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

        export class VolumeCondition implements ContractCondition {
          type = OrderConditionType.Volume;
        
          /**
           * Create a [[VolumeCondition]] object.
        Severity: Major
        Found in src/api/order/condition/volume-condition.ts and 1 other location - About 3 hrs to fix
        src/api/order/condition/percent-change-condition.ts on lines 8..31

        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 96.

        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

        export class PercentChangeCondition implements ContractCondition {
          type = OrderConditionType.PercentChange;
        
          /**
           * Create a [[PercentChangeCondition]] object.
        Severity: Major
        Found in src/api/order/condition/percent-change-condition.ts and 1 other location - About 3 hrs to fix
        src/api/order/condition/volume-condition.ts on lines 8..31

        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 96.

        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
              .getMarketDepthExchanges()
              .then((data) => {
                this.printObject(data);
                this.exit();
        Severity: Major
        Found in src/tools/market-depth-exchanges.ts and 1 other location - About 3 hrs to fix
        src/tools/managed-accts.ts on lines 33..41

        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 96.

        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 decodeMsg_COMPLETED_ORDER has 76 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          private decodeMsg_COMPLETED_ORDER(): void {
            const contract: Contract = {};
            const order: Order = {};
            const orderState: OrderState = {};
            const orderDecoder = new OrderDecoder(
        Severity: Major
        Found in src/core/io/decoder.ts - About 3 hrs to fix

          Function decodeMsg_BOND_CONTRACT_DATA has 76 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            private decodeMsg_BOND_CONTRACT_DATA(): void {
              let version = 6;
              if (this.serverVersion < MIN_SERVER_VER.SIZE_RULES) {
                version = 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

                return this.subscriptions.register<OpenOrder[]>(
                  () => {
                    this.api.reqOpenOrders();
                  },
                  undefined,
            Severity: Major
            Found in src/api-next/api-next.ts and 1 other location - About 2 hrs to fix
            src/api-next/api-next.ts on lines 2744..2757

            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 94.

            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.subscriptions
                    .register<OpenOrder[]>(
                      () => {
                        this.api.reqAllOpenOrders();
                      },
            Severity: Major
            Found in src/api-next/api-next.ts and 1 other location - About 2 hrs to fix
            src/api-next/api-next.ts on lines 2770..2782

            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 94.

            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.subscriptions
                    .register<HistogramEntry[]>(
                      (reqId) => {
                        this.api.reqHistogramData(
                          reqId,
            Severity: Major
            Found in src/api-next/api-next.ts and 1 other location - About 2 hrs to fix
            src/api-next/api-next.ts on lines 1627..1643

            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 93.

            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: {
                          const timeConditionCond = cond as VolumeCondition;
                          // OperatorCondition
                          tokens.push(timeConditionCond.isMore);
                          tokens.push(timeConditionCond.strValue);
            Severity: Major
            Found in src/core/io/encoder.ts and 1 other location - About 2 hrs to fix
            src/core/io/encoder.ts on lines 1594..1603

            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 93.

            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.subscriptions
                    .register<string>(
                      (reqId) => {
                        this.api.reqHeadTimestamp(
                          reqId,
            Severity: Major
            Found in src/api-next/api-next.ts and 1 other location - About 2 hrs to fix
            src/api-next/api-next.ts on lines 2524..2540

            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 93.

            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

            Severity
            Category
            Status
            Source
            Language