Mirroar/hivemind

View on GitHub
src/process/trade.ts

Summary

Maintainability
F
1 wk
Test Coverage

Function run has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
Open

    run() {
        if (!hivemind.settings.get('enableTradeManagement')) return;

        // Only trade if we have a terminal to trade with.
        if (_.size(_.filter(Game.myRooms, room => room.terminal)) === 0) return;
Severity: Minor
Found in src/process/trade.ts - About 1 day 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 trade.ts has 413 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global RESOURCES_ALL RESOURCE_ENERGY RESOURCE_POWER OK RESOURCE_OPS
ORDER_BUY ORDER_SELL PIXEL STORAGE_CAPACITY INTERSHARD_RESOURCES
REACTION_TIME */

import cache from 'utils/cache';
Severity: Minor
Found in src/process/trade.ts - About 5 hrs to fix

    Function run has 84 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        run() {
            if (!hivemind.settings.get('enableTradeManagement')) return;
    
            // Only trade if we have a terminal to trade with.
            if (_.size(_.filter(Game.myRooms, room => room.terminal)) === 0) return;
    Severity: Major
    Found in src/process/trade.ts - About 3 hrs to fix

      Function instaBuyResources has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          instaBuyResources(resourceType: TradeResource, rooms?: Record<string, RoomResourceState>, force?: boolean) {
              // Find room with lowest amount of this resource.
              const roomName = isIntershardResource(resourceType) ? null : this.getLowestResourceState(resourceType, rooms);
              if (!roomName && !isIntershardResource(resourceType)) return;
      
      
      Severity: Minor
      Found in src/process/trade.ts - About 2 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 tryBuyResources has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          tryBuyResources(resourceType: TradeResource, rooms?: Record<string, RoomResourceState>, ignoreOtherRooms?: boolean) {
              if (_.some(Game.market.orders, order => {
                  if (order.type === ORDER_BUY && order.resourceType === resourceType) {
                      if (ignoreOtherRooms && !rooms[order.roomName]) {
                          return false;
      Severity: Minor
      Found in src/process/trade.ts - About 1 hr to fix

        Function instaSellResources has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            instaSellResources(resourceType: ResourceConstant, rooms: Record<string, RoomResourceState>) {
                // Find room with highest amount of this resource.
                const roomName = this.getHighestResourceState(resourceType, rooms);
                if (!roomName) return;
        
        
        Severity: Minor
        Found in src/process/trade.ts - 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 instaSellResources has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            instaSellResources(resourceType: ResourceConstant, rooms: Record<string, RoomResourceState>) {
                // Find room with highest amount of this resource.
                const roomName = this.getHighestResourceState(resourceType, rooms);
                if (!roomName) return;
        
        
        Severity: Minor
        Found in src/process/trade.ts - About 1 hr to fix

          Function instaBuyResources has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              instaBuyResources(resourceType: TradeResource, rooms?: Record<string, RoomResourceState>, force?: boolean) {
                  // Find room with lowest amount of this resource.
                  const roomName = isIntershardResource(resourceType) ? null : this.getLowestResourceState(resourceType, rooms);
                  if (!roomName && !isIntershardResource(resourceType)) return;
          
          
          Severity: Minor
          Found in src/process/trade.ts - About 1 hr to fix

            Function trySellResources has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                trySellResources(resourceType: ResourceConstant, rooms: Record<string, RoomResourceState>) {
                    if (_.some(Game.market.orders, order => order.type === ORDER_SELL && order.resourceType === resourceType)) {
                        return;
                    }
            
            
            Severity: Minor
            Found in src/process/trade.ts - About 1 hr to fix

              Function tryBuyResources has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  tryBuyResources(resourceType: TradeResource, rooms?: Record<string, RoomResourceState>, ignoreOtherRooms?: boolean) {
                      if (_.some(Game.market.orders, order => {
                          if (order.type === ORDER_BUY && order.resourceType === resourceType) {
                              if (ignoreOtherRooms && !rooms[order.roomName]) {
                                  return false;
              Severity: Minor
              Found in src/process/trade.ts - 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

              Avoid deeply nested control flow statements.
              Open

                              if (resourceWorth) {
                                  const history = this.getPriceData(resourceType);
                                  if (history && history.average && history.average > resourceWorth) {
                                      // Alright, looks like we can make a profit by selling this!
                                      if ((total.resources[resourceType] || 0) > minStorage) {
              Severity: Major
              Found in src/process/trade.ts - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if (room.factory && room.terminal.store.getUsedCapacity(RESOURCE_ENERGY) > 500) {
                                            this.instaBuyResources(RESOURCE_BATTERY, {[room.name]: resources.rooms[room.name]}, true);
                                        }
                                        else {
                                            this.instaBuyResources(RESOURCE_ENERGY, {[room.name]: resources.rooms[room.name]}, true);
                Severity: Major
                Found in src/process/trade.ts - About 45 mins to fix

                  Function getRoomResourceStates has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      getRoomResourceStates(): ResourceStates {
                          const rooms = {};
                          const total = {
                              resources: {},
                              sources: {},
                  Severity: Minor
                  Found in src/process/trade.ts - About 35 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

                  Function trySellResources has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      trySellResources(resourceType: ResourceConstant, rooms: Record<string, RoomResourceState>) {
                          if (_.some(Game.market.orders, order => order.type === ORDER_SELL && order.resourceType === resourceType)) {
                              return;
                          }
                  
                  
                  Severity: Minor
                  Found in src/process/trade.ts - About 35 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

                  Avoid too many return statements within this function.
                  Open

                              return;
                  Severity: Major
                  Found in src/process/trade.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                                return;
                    Severity: Major
                    Found in src/process/trade.ts - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                              if (history.average < 10_000 && history.total > 10) return 10;
                      Severity: Major
                      Found in src/process/trade.ts - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                if (this.availableCredits < amount * offerPrice) return;
                        Severity: Major
                        Found in src/process/trade.ts - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                      return;
                          Severity: Major
                          Found in src/process/trade.ts - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                    return 1;
                            Severity: Major
                            Found in src/process/trade.ts - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                              else return;
                              Severity: Major
                              Found in src/process/trade.ts - About 30 mins to fix

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

                                        _.each(orders, order => {
                                            if (order.amount < 100) return;
                                            const transactionCost = isIntershardResource(resourceType) ? 0 : Game.market.calcTransactionCost(1000, roomName, order.roomName);
                                            const credits = 1000 * order.price;
                                            const score = credits - (0.3 * transactionCost);
                                Severity: Major
                                Found in src/process/trade.ts and 1 other location - About 4 hrs to fix
                                src/process/trade.ts on lines 538..548

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

                                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

                                        _.each(orders, order => {
                                            if (order.amount < 100) return;
                                            const transactionCost = isIntershardResource(resourceType) ? 0 : Game.market.calcTransactionCost(1000, roomName, order.roomName);
                                            const credits = 1000 * order.price;
                                            const score = credits + (0.3 * transactionCost);
                                Severity: Major
                                Found in src/process/trade.ts and 1 other location - About 4 hrs to fix
                                src/process/trade.ts on lines 506..516

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

                                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 (hivemind.settings.get('allowSellingOps')) {
                                            // Sell excess ops.
                                            if ((total.resources[RESOURCE_OPS] || 0) > lowStorage) {
                                                this.instaSellResources(RESOURCE_OPS, resources.rooms);
                                            }
                                Severity: Major
                                Found in src/process/trade.ts and 1 other location - About 3 hrs to fix
                                src/process/trade.ts on lines 134..143

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

                                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 (hivemind.settings.get('allowSellingPower')) {
                                            // Sell excess power we can't apply to our account.
                                            if ((total.resources[RESOURCE_POWER] || 0) > highStorage) {
                                                this.instaSellResources(RESOURCE_POWER, resources.rooms);
                                            }
                                Severity: Major
                                Found in src/process/trade.ts and 1 other location - About 3 hrs to fix
                                src/process/trade.ts on lines 145..154

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

                                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 (room.memory.fillTerminal) {
                                                hivemind.log('trade', roomName).info('Busy, can\'t prepare', transactionCost, 'energy for selling', amount, resourceType);
                                            }
                                            else {
                                                room.prepareForTrading(RESOURCE_ENERGY, transactionCost);
                                Severity: Major
                                Found in src/process/trade.ts and 1 other location - About 2 hrs to fix
                                src/process/trade.ts on lines 286..292

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

                                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 (room.memory.fillTerminal) {
                                                    hivemind.log('trade', roomName).info('Busy, can\'t prepare', transactionCost, 'energy for buying', amount, resourceType);
                                                }
                                                else {
                                                    room.prepareForTrading(RESOURCE_ENERGY, transactionCost);
                                Severity: Major
                                Found in src/process/trade.ts and 1 other location - About 2 hrs to fix
                                src/process/trade.ts on lines 235..241

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

                                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

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

                                    getResourceTier(resourceType: ResourceConstant) {
                                        if (resourceType === RESOURCE_ENERGY) return 0;
                                        if (resourceType === RESOURCE_POWER) return 10;
                                
                                        const tier = resourceType.length;
                                Severity: Major
                                Found in src/process/trade.ts and 1 other location - About 1 hr to fix
                                src/empire/trade-route-manager.ts on lines 148..158

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

                                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 (!maxAmount || (roomState.totalResources[resourceType] || 0) > maxAmount) {
                                                maxAmount = roomState.totalResources[resourceType];
                                                bestRoom = roomName;
                                            }
                                Severity: Minor
                                Found in src/process/trade.ts and 1 other location - About 50 mins to fix
                                src/process/trade.ts on lines 455..458

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

                                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 (!minAmount || (roomState.totalResources[resourceType] || 0) < minAmount) {
                                                minAmount = roomState.totalResources[resourceType];
                                                bestRoom = roomName;
                                            }
                                Severity: Minor
                                Found in src/process/trade.ts and 1 other location - About 50 mins to fix
                                src/process/trade.ts on lines 480..483

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

                                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

                                        const orders = Game.market.getAllOrders(order => order.type === ORDER_BUY && order.resourceType === resourceType);
                                Severity: Minor
                                Found in src/process/trade.ts and 1 other location - About 30 mins to fix
                                src/process/trade.ts on lines 534..534

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

                                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

                                        const orders = Game.market.getAllOrders(order => order.type === ORDER_SELL && order.resourceType === resourceType);
                                Severity: Minor
                                Found in src/process/trade.ts and 1 other location - About 30 mins to fix
                                src/process/trade.ts on lines 502..502

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

                                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

                                There are no issues that match your filters.

                                Category
                                Status