SysMO-DB/seek

View on GitHub
app/controllers/policies_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

Method sharing_params_to_policy has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

  def sharing_params_to_policy params=params
      policy =Policy.new()
      policy.sharing_scope = params["sharing_scope"].to_i unless params[:sharing_scope].blank?
      policy.access_type = params[:access_type].blank? ? 0 : params["access_type"].to_i
      policy.use_whitelist = params["use_whitelist"] == 'true' ? true : false
Severity: Minor
Found in app/controllers/policies_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 send_policy_data has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def send_policy_data
    request_type = white_list(params[:policy_type])
    entity_type = white_list(params[:entity_type])
    entity_id = white_list(params[:entity_id])
    
Severity: Minor
Found in app/controllers/policies_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 get_selected_projects has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def get_selected_projects project_ids, resource_name
    if (resource_name == 'study') and (!project_ids.blank?)
      investigation = Investigation.find_by_id(project_ids.to_i)
      projects = investigation.nil? ? [] : investigation.projects

Severity: Minor
Found in app/controllers/policies_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 send_policy_data has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def send_policy_data
    request_type = white_list(params[:policy_type])
    entity_type = white_list(params[:entity_type])
    entity_id = white_list(params[:entity_id])
    
Severity: Minor
Found in app/controllers/policies_controller.rb - About 1 hr to fix

    Method preview_permissions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

      def preview_permissions
          policy = sharing_params_to_policy
          current_person = User.current_user.try(:person)
          contributor_person = (params['is_new_file'] == 'false') ?  User.find_by_id(params['contributor_id'].to_i).try(:person) : current_person
          creators = (params["creators"].blank? ? [] : ActiveSupport::JSON.decode(params["creators"])).uniq
    Severity: Minor
    Found in app/controllers/policies_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 preview_permissions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def preview_permissions
          policy = sharing_params_to_policy
          current_person = User.current_user.try(:person)
          contributor_person = (params['is_new_file'] == 'false') ?  User.find_by_id(params['contributor_id'].to_i).try(:person) : current_person
          creators = (params["creators"].blank? ? [] : ActiveSupport::JSON.decode(params["creators"])).uniq
    Severity: Minor
    Found in app/controllers/policies_controller.rb - About 1 hr to fix

      Method sharing_params_to_policy has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def sharing_params_to_policy params=params
            policy =Policy.new()
            policy.sharing_scope = params["sharing_scope"].to_i unless params[:sharing_scope].blank?
            policy.access_type = params[:access_type].blank? ? 0 : params["access_type"].to_i
            policy.use_whitelist = params["use_whitelist"] == 'true' ? true : false
      Severity: Minor
      Found in app/controllers/policies_controller.rb - About 1 hr to fix

        There are no issues that match your filters.

        Category
        Status