<commit_before>module MortgageCalculator
  class Repayment
    attr_reader :debt, :term_years, :interest_rate

    def initialize(options = {})
      @debt = options.fetch(:debt)
      @term_years = options.fetch(:term_years)
      @interest_rate = options.fetch(:interest_rate)
    end

    def monthly_payment
      monthly_interest / f1
    end

    def total_interest
      (monthly_payment * term_months) - debt
    end

    def total_payable
      debt + total_interest
    end

    def remaining_balances
      array = [debt]

      (1..term_years).each do |year|
        month = year * 12

        a1 = debt * ((1 + monthly_rate) ** month)
        b1 = -monthly_payment
        c1 = ((1 + monthly_rate) ** month) - 1
        d1 = (b1 * c1) / monthly_rate
        outstanding_balance = a1 + d1

        array.push outstanding_balance
      end

      array
    end

    private

    def term_months
      term_years * 12
    end

    def f1
      1 - ((1 + monthly_rate) ** -(term_months))
    end

    def monthly_rate
      DAYS_IN_A_MONTH * ((interest_rate / 100) / DAYS_IN_A_YEAR)
    end

    def monthly_interest
      debt * monthly_rate
    end
  end
end
<commit_msg>refactor out unneeded local variables<commit_after>module MortgageCalculator
  class Repayment
    attr_reader :debt, :term_years, :interest_rate

    def initialize(options = {})
      @debt = options.fetch(:debt)
      @term_years = options.fetch(:term_years)
      @interest_rate = options.fetch(:interest_rate)
    end

    def monthly_payment
      monthly_interest / f1
    end

    def total_interest
      (monthly_payment * term_months) - debt
    end

    def total_payable
      debt + total_interest
    end

    def remaining_balances
      [debt] + (1..term_years).map do |year|
        month = year * 12

        a1 = debt * ((1 + monthly_rate) ** month)
        b1 = -monthly_payment
        c1 = ((1 + monthly_rate) ** month) - 1
        d1 = (b1 * c1) / monthly_rate
        a1 + d1
      end
    end

    private

    def term_months
      term_years * 12
    end

    def f1
      1 - ((1 + monthly_rate) ** -(term_months))
    end

    def monthly_rate
      DAYS_IN_A_MONTH * ((interest_rate / 100) / DAYS_IN_A_YEAR)
    end

    def monthly_interest
      debt * monthly_rate
    end
  end
end

{'fraction_non_alphanumeric': 0.08351457155284907, 'fraction_numerical': 0.020008699434536755, 'mean_word_length': 2.1123139377537212, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2813683', 'n_tokens_mistral': 809, 'n_tokens_neox': 737, 'n_words': 187}