talho/openphin

View on GitHub
app/controllers/admin/groups_controller.rb

Summary

Maintainability
C
1 day
Test Coverage

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

  def update
    group = Group.find(params[:id])
    @group = group if current_user.viewable_groups.include?(group)
    if @group.nil?
      flash[:error] = "This resource does not exist or is not available."
Severity: Minor
Found in app/controllers/admin/groups_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 show has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    group = Group.find_by_id(params[:id])
    @group = current_user.viewable_groups.include?(group) ? group : nil

    respond_to do |format|
Severity: Minor
Found in app/controllers/admin/groups_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 index has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def index
    page = params[:page].blank? ? "1" : params[:page]
    @reverse = params[:reverse] == "1" ? "DESC" : 'ASC'
    @sort = params[:sort]
    @groups = current_user.viewable_groups
Severity: Minor
Found in app/controllers/admin/groups_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 update has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def update
    group = Group.find(params[:id])
    @group = group if current_user.viewable_groups.include?(group)
    if @group.nil?
      flash[:error] = "This resource does not exist or is not available."
Severity: Major
Found in app/controllers/admin/groups_controller.rb - About 2 hrs to fix

    There are no issues that match your filters.

    Category
    Status