infertux/ubea

View on GitHub

Showing 16 of 16 total issues

Method post_private has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def post_private(method, params = {})
        params['nonce'] = nonce

        response = retryable_http_request do
          http_adapter("https://api.kraken.com").post(url_path(method), params) do |request|
Severity: Minor
Found in lib/ubea/exchanges/kraken_base.rb - 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

Method post_private has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def post_private(method, params = {})
        params['method'] = method
        params['nonce'] = nonce

        response = retryable_http_request do
Severity: Minor
Found in lib/ubea/exchanges/bitcoin_co_id_idr.rb - 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

Method to_s has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def to_s(with_currency: true, auto_format: true, tooltip_currency: false)
      amount = dup
      currency = self.currency.dup

      old_amount_string = if tooltip_currency
Severity: Minor
Found in lib/ubea/money.rb - 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

Method trade! has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def trade!(args, simulate: false)
        params = {
          pair: "XXBTZ#{fiat_currency}",
          type: args.fetch(:type),
          volume: args.fetch(:volume),
Severity: Minor
Found in lib/ubea/exchanges/kraken_base.rb - About 1 hr to fix

    Method to_s has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def to_s(with_currency: true, auto_format: true, tooltip_currency: false)
          amount = dup
          currency = self.currency.dup
    
          old_amount_string = if tooltip_currency
    Severity: Minor
    Found in lib/ubea/money.rb - About 1 hr to fix

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

            def nonce
              now = Time.now.to_f
      
              if (@nonce || 0) + 1 > now.to_i
                Log.warn "Throttling API call for 1s to #{self}"
      Severity: Minor
      Found in lib/ubea/exchanges/hit_btc_base.rb and 1 other location - About 35 mins to fix
      lib/ubea/exchanges/bitcoin_co_id_idr.rb on lines 113..124

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

      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

            def nonce
              now = Time.now.to_f
      
              if (@nonce || 0) + 1 > now.to_i
                Log.warn "Throttling API call for 1s to #{self}"
      Severity: Minor
      Found in lib/ubea/exchanges/bitcoin_co_id_idr.rb and 1 other location - About 35 mins to fix
      lib/ubea/exchanges/hit_btc_base.rb on lines 109..120

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

      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

      Method best_offer_price_for_fiat_amount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def best_offer_price_for_fiat_amount(type, fiat_amount, fiat_currency)
            total_fiat_amount = 0
            good_offers = []
      
            offers = public_send(type).dup # asks or bids
      Severity: Minor
      Found in lib/ubea/order_book.rb - About 25 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

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

            def refresh_order_book!
              json = get_json("https://vip.bitcoin.co.id/api/btc_#{fiat_currency.downcase}/depth") or return
      
              asks = format_asks_bids(json["sell"])
              bids = format_asks_bids(json["buy"])
      Severity: Minor
      Found in lib/ubea/exchanges/bitcoin_co_id_idr.rb and 2 other locations - About 25 mins to fix
      lib/ubea/exchanges/bitcurex_eur.rb on lines 14..21
      lib/ubea/exchanges/btc_e_base.rb on lines 22..29

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

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

            def refresh_order_book!
              json = get_json("https://#{fiat_currency.downcase}.bitcurex.com/data/orderbook.json") or return
      
              asks = format_asks_bids(json["asks"])
              bids = format_asks_bids(json["bids"])
      Severity: Minor
      Found in lib/ubea/exchanges/bitcurex_eur.rb and 2 other locations - About 25 mins to fix
      lib/ubea/exchanges/bitcoin_co_id_idr.rb on lines 20..27
      lib/ubea/exchanges/btc_e_base.rb on lines 22..29

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

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

            def refresh_order_book!
              json = get_json("https://btc-e.com/api/2/btc_#{fiat_currency.downcase}/depth") or return
      
              asks = format_asks_bids(json["asks"])
              bids = format_asks_bids(json["bids"])
      Severity: Minor
      Found in lib/ubea/exchanges/btc_e_base.rb and 2 other locations - About 25 mins to fix
      lib/ubea/exchanges/bitcoin_co_id_idr.rb on lines 20..27
      lib/ubea/exchanges/bitcurex_eur.rb on lines 14..21

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

      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

      Method rate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.rate(from, to)
            pair = [from, to].join
      
            if @rates[pair].nil? || @rates[pair].updated_at < Time.now - 10 * 60
      
      
      Severity: Minor
      Found in lib/ubea/currency_converter.rb - About 25 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

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

            def balance
              balance = post_private("getInfo")
      
              OpenStruct.new(
                fiat: Money.new(balance["funds"][fiat_currency.downcase].to_s, fiat_currency),
      Severity: Minor
      Found in lib/ubea/exchanges/btc_e_base.rb and 1 other location - About 25 mins to fix
      lib/ubea/exchanges/bitcoin_co_id_idr.rb on lines 30..36

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

      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

            def balance
              balance = post_private("getInfo")
      
              OpenStruct.new(
                fiat: Money.new(balance["balance"][fiat_currency.downcase].to_s, fiat_currency),
      Severity: Minor
      Found in lib/ubea/exchanges/bitcoin_co_id_idr.rb and 1 other location - About 25 mins to fix
      lib/ubea/exchanges/btc_e_base.rb on lines 32..38

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

      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

            def refresh_order_book!
              json = get_json("https://www.bitstamp.net/api/order_book/") or return
      
              asks = format_asks_bids(json["asks"])
              bids = format_asks_bids(json["bids"])
      Severity: Minor
      Found in lib/ubea/exchanges/bitstamp_usd.rb and 1 other location - About 15 mins to fix
      lib/ubea/exchanges/bit_nz_nzd.rb on lines 22..29

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

      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

            def refresh_order_book!
              json = get_json("https://bitnz.com/api/0/orderbook") or return
      
              asks = format_asks_bids(json["asks"])
              bids = format_asks_bids(json["bids"])
      Severity: Minor
      Found in lib/ubea/exchanges/bit_nz_nzd.rb and 1 other location - About 15 mins to fix
      lib/ubea/exchanges/bitstamp_usd.rb on lines 22..29

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

      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