strawberrycanyon/redeemify

View on GitHub

Showing 4 of 4 total issues

Method customer has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def customer
    if session[:user_id]
      if current_user.code.nil?
        unless RedeemifyCode.serve(current_user, params[:code])
          flash.now[:error] = 
Severity: Minor
Found in app/controllers/sessions_controller.rb - About 45 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

Method process_codes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def process_codes(file)
    f = File.open(file.path, "r")
      f.each_line do |row|
        row = row.gsub(/\s+/, "")
        unless row.empty?
Severity: Minor
Found in app/models/concerns/offeror.rb - 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

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

  def self.decode(val)
    obj = self.new(10) # any product will do
    result = obj.generator.decipher(val.to_i).to_s
    obj.errors.add(:base, "Invalid code (format mismatch)") and return nil unless result =~ FORMAT_REGEX
    product1, day, product2, seq = [$1,$2,$3,$4].map(&:to_i)
Severity: Minor
Found in lib/coupon_code.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

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

  def import
    if params[:file].nil?
      redirect_to "/#{params[:controller]}/upload_page", 
        :flash => { :error => "You have not selected a file to upload" }
    else
Severity: Minor
Found in app/controllers/concerns/offeror_actions.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