nathanshox/PayslipExplainator

View on GitHub

Showing 3 of 3 total issues

File explain_payslip.rb has 358 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'bigdecimal'
require 'bigdecimal/util'
require 'open-uri'
require 'openssl'
require 'optparse'
Severity: Minor
Found in explain_payslip.rb - About 4 hrs to fix

    Method calculate_usc has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def calculate_usc(taxable_amount, point_five_percent_band, two_percent_band, four_point_five_percent_band)
      result = Hash.new
    
      already_charged = 0
      result['chargable_at_point_five'] = taxable_amount > point_five_percent_band ? point_five_percent_band : taxable_amount
    Severity: Minor
    Found in explain_payslip.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 parse has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.parse(args)
        # The options specified on the command line will be collected in *options*.
        # Set default values here.
        options = OpenStruct.new
        options.config_file_path = File.join(File.dirname(File.expand_path(__FILE__)), 'payslip_config.yml')
    Severity: Minor
    Found in explain_payslip.rb - About 1 hr to fix
      Severity
      Category
      Status
      Source
      Language