SysMO-DB/seek

View on GitHub
app/helpers/policy_helper.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Method uniq_people_permissions_and_privileged_people has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def uniq_people_permissions_and_privileged_people(permissions, privileged_people)
    uniq_permissions_by_contributor permissions

    people_from_permissions = permissions.select{|p| p.contributor_type == 'Person'}.collect(&:contributor)

Severity: Minor
Found in app/helpers/policy_helper.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 process_permissions has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def process_permissions permissions, resource_name, display_no_access=false
    #remove the permissions with access_type=NO_ACCESS
    permissions.select!{ |p| p.access_type != Policy::NO_ACCESS } unless display_no_access

    html = ''
Severity: Minor
Found in app/helpers/policy_helper.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 your_project_access_type has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def your_project_access_type policy = nil, resource = nil
    unless policy.nil? or resource.nil? or !(policy.sharing_scope == Policy::ALL_SYSMO_USERS)
      unless policy.permissions.empty?
        my_project_ids = if resource.class == Project then [resource.id] else resource.project_ids end
        my_project_perms = policy.permissions.select {|p| p.contributor_type == 'Project' and my_project_ids.include? p.contributor_id}
Severity: Minor
Found in app/helpers/policy_helper.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 policy_and_permissions_for_public_scope has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def policy_and_permissions_for_public_scope(policy, permissions, privileged_people, resource_name, updated_can_publish_immediately, send_request_publish_approval)
Severity: Minor
Found in app/helpers/policy_helper.rb - About 45 mins to fix

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

      def process_privileged_people privileged_people, resource_name
        html = ''
        if !privileged_people.blank?
          html << "<h3> Privileged people:</h3>"
          privileged_people.each do |key, value|
    Severity: Minor
    Found in app/helpers/policy_helper.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