concord-consortium/rigse

View on GitHub
rails/app/models/user.rb

Summary

Maintainability
D
2 days
Test Coverage

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

class User < ApplicationRecord
  has_many :authentications, :dependent => :delete_all
  has_many :access_grants, :dependent => :delete_all

  has_many :favorites
Severity: Major
Found in rails/app/models/user.rb - About 1 day to fix

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

    require 'digest/sha1'
    
    class User < ApplicationRecord
      has_many :authentications, :dependent => :delete_all
      has_many :access_grants, :dependent => :delete_all
    Severity: Minor
    Found in rails/app/models/user.rb - About 7 hrs to fix

      Method find_for_omniauth has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def find_for_omniauth(auth, signed_in_resource=nil)
            authentication = Authentication.find_by_provider_and_uid auth.provider, auth.uid
            if authentication
              # Since we're not planning to access the provider on behalf of the user,
              # don't bother storing tokens for now.
      Severity: Minor
      Found in rails/app/models/user.rb - About 1 hr to fix

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

          def is_project_researcher?(project = nil, allow_expired: false, check_can_manage_permission_forms: false)
            target_association = allow_expired ? _project_user_researchers_inc_expired : _project_user_researchers
        
            if check_can_manage_permission_forms
              if project
        Severity: Minor
        Found in rails/app/models/user.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 set_role_for_projects has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def set_role_for_projects(role, possible_projects, selected_project_ids, expiration_dates={}, can_manage_permission_forms={})
        Severity: Minor
        Found in rails/app/models/user.rb - About 35 mins to fix

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

              def find_for_omniauth(auth, signed_in_resource=nil)
                authentication = Authentication.find_by_provider_and_uid auth.provider, auth.uid
                if authentication
                  # Since we're not planning to access the provider on behalf of the user,
                  # don't bother storing tokens for now.
          Severity: Minor
          Found in rails/app/models/user.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

          There are no issues that match your filters.

          Category
          Status