phlegx/money-currencylayer-bank

View on GitHub

Showing 3 of 3 total issues

Class CurrencylayerBank has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

    class CurrencylayerBank < Money::Bank::VariableExchange
      # Apilayer url
      URL_AL = 'http://api.apilayer.com/currency_data/live'.freeze
      # CurrencylayerBank url
      URL_CL = 'http://api.currencylayer.com/live'.freeze
Severity: Minor
Found in lib/money/bank/currencylayer_bank.rb - About 2 hrs to fix

    Method exchange_rates has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

          def exchange_rates(straight = false)
            rates = straight ? raw_rates_straight : raw_rates_careful
            if rates.key?('quotes')
              @rates = rates['quotes']
            elsif rates.key?('error')
    Severity: Minor
    Found in lib/money/bank/currencylayer_bank.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 source_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def source_url
            raise NoAccessKey if access_key.nil? || access_key.empty?
    
            url = "#{currencylayer ? URL_CL : URL_AL}?source=#{source}"
            url = url.sub('http:', 'https:') if secure_connection
    Severity: Minor
    Found in lib/money/bank/currencylayer_bank.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

    Severity
    Category
    Status
    Source
    Language