bborn/communityengine

View on GitHub
app/models/user.rb

Summary

Maintainability
D
2 days
Test Coverage

Class User has 57 methods (exceeds 20 allowed). Consider refactoring.
Open

class User < ActiveRecord::Base
  extend FriendlyId
  include UrlUpload
  include FacebookProfile
  include TwitterProfile
Severity: Major
Found in app/models/user.rb - About 1 day to fix

    File user.rb has 366 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'digest/sha1'
    require 'bcrypt'
    
    class User < ActiveRecord::Base
      extend FriendlyId
    Severity: Minor
    Found in app/models/user.rb - About 4 hrs to fix

      Method find_country_and_state_from_search_params has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.find_country_and_state_from_search_params(search)
          country     = Country.find(search['country_id']) if !search['country_id'].blank?
          state       = State.find(search['state_id']) if !search['state_id'].blank?
          metro_area  = MetroArea.find(search['metro_area_id']) if !search['metro_area_id'].blank?
      
      
      Severity: Minor
      Found in app/models/user.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 build_conditions_for_search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.build_conditions_for_search(search)
          user = User.arel_table
          users = User.active
          if search['country_id'] && !(search['metro_area_id'] || search['state_id'])
            users = users.where(user[:country_id].eq(search['country_id']))
      Severity: Minor
      Found in app/models/user.rb - About 55 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 find_or_create_from_authorization has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.find_or_create_from_authorization(auth)
          user = User.where(:email => auth.email).first_or_initialize
          user.login ||= auth.nickname
      
          if user.new_record?
      Severity: Minor
      Found in app/models/user.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 avatar_photo_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def avatar_photo_url(size = :original)
          if avatar_id
            avatar.photo.url(size)
          elsif facebook?
            facebook_authorization.picture_url
      Severity: Minor
      Found in app/models/user.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

      There are no issues that match your filters.

      Category
      Status