SysMO-DB/seek

View on GitHub
app/controllers/people_controller.rb

Summary

Maintainability
D
3 days
Test Coverage

File people_controller.rb has 357 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class PeopleController < ApplicationController

  include Seek::AnnotationCommon
  include Seek::Publishing::PublishingCommon
  include Seek::Publishing::GatekeeperPublish
Severity: Minor
Found in app/controllers/people_controller.rb - About 4 hrs to fix

    Class PeopleController has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class PeopleController < ApplicationController
    
      include Seek::AnnotationCommon
      include Seek::Publishing::PublishingCommon
      include Seek::Publishing::GatekeeperPublish
    Severity: Minor
    Found in app/controllers/people_controller.rb - About 3 hrs to fix

      Method do_projects_belong_to_project_manager_projects has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

        def do_projects_belong_to_project_manager_projects
            if (params[:person] and params[:person][:work_group_ids])
              if User.project_manager_logged_in? && !User.admin_logged_in?
                projects = []
                params[:person][:work_group_ids].each do |id|
      Severity: Minor
      Found in app/controllers/people_controller.rb - About 3 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 create has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        def create
          @person = Person.new(params[:person])
      
          redirect_action="new"
      
      
      Severity: Minor
      Found in app/controllers/people_controller.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 administer_update has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

        def administer_update
          had_no_projects = @person.work_groups.empty?
      
          passed_params=    {:roles                 =>  User.admin_logged_in?,
                             :roles_mask            => User.admin_logged_in?,
      Severity: Minor
      Found in app/controllers/people_controller.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 create has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create
          @person = Person.new(params[:person])
      
          redirect_action="new"
      
      
      Severity: Minor
      Found in app/controllers/people_controller.rb - About 1 hr to fix

        Method update has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def update
            @person.disciplines.clear if params[:discipline_ids].nil?
        
            # extra check required to see if any avatar was actually selected (or it remains to be the default one)
            
        Severity: Minor
        Found in app/controllers/people_controller.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 index has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

          def index
            if (params[:discipline_id])
              @discipline=Discipline.find(params[:discipline_id])
              #FIXME: strips out the disciplines that don't match
              @people=Person.where(["disciplines.id=?",@discipline.id]).includes(:disciplines)
        Severity: Minor
        Found in app/controllers/people_controller.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 index has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def index
            if (params[:discipline_id])
              @discipline=Discipline.find(params[:discipline_id])
              #FIXME: strips out the disciplines that don't match
              @people=Person.where(["disciplines.id=?",@discipline.id]).includes(:disciplines)
        Severity: Minor
        Found in app/controllers/people_controller.rb - About 1 hr to fix

          Method administer_update has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def administer_update
              had_no_projects = @person.work_groups.empty?
          
              passed_params=    {:roles                 =>  User.admin_logged_in?,
                                 :roles_mask            => User.admin_logged_in?,
          Severity: Minor
          Found in app/controllers/people_controller.rb - About 1 hr to fix

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

              def project_managers_of_selected_projects projects_param
                project_manager_list = []
                unless projects_param.blank?
                  projects_param.each do |project_param|
                    project = Project.find_by_id(project_param)
            Severity: Minor
            Found in app/controllers/people_controller.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 set_tools_and_expertise has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def set_tools_and_expertise person,params
                  exp_changed = person.tag_with_params params,"expertise"
                  tools_changed = person.tag_with_params params,"tool"
                  if immediately_clear_tag_cloud?
                    expire_annotation_fragments("expertise") if exp_changed
            Severity: Minor
            Found in app/controllers/people_controller.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 project_or_institution_details has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def project_or_institution_details projects_or_institutions
                details = ''
                unless params[projects_or_institutions].blank?
                  params[projects_or_institutions].each do |project_or_institution|
                    project_or_institution_details= project_or_institution.split(',')
            Severity: Minor
            Found in app/controllers/people_controller.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