otwcode/otwarchive

View on GitHub
app/controllers/chapters_controller.rb

Summary

Maintainability
D
1 day
Test Coverage

Method show has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    @tag_groups = @work.tag_groups
    if params[:view_adult]
      cookies[:view_adult] = "true"
    elsif @work.adult? && !see_adult?
Severity: Minor
Found in app/controllers/chapters_controller.rb - About 4 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 a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def update
    if params[:cancel_button]
      # Not quite working yet - should send the user back to wherever they were before they hit edit
      redirect_back_or_default(root_path)
      return
Severity: Minor
Found in app/controllers/chapters_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 a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    if params[:cancel_button]
      redirect_back_or_default(root_path)
      return
    end
Severity: Minor
Found in app/controllers/chapters_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 show has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def show
    @tag_groups = @work.tag_groups
    if params[:view_adult]
      cookies[:view_adult] = "true"
    elsif @work.adult? && !see_adult?
Severity: Minor
Found in app/controllers/chapters_controller.rb - About 1 hr to fix

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

      def update
        if params[:cancel_button]
          # Not quite working yet - should send the user back to wherever they were before they hit edit
          redirect_back_or_default(root_path)
          return
    Severity: Minor
    Found in app/controllers/chapters_controller.rb - About 1 hr to fix

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

        def post
          if params[:cancel_button]
            redirect_to @work
          elsif params[:edit_button]
            redirect_to [:edit, @work, @chapter]
      Severity: Minor
      Found in app/controllers/chapters_controller.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

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

        def destroy
          if @chapter.is_only_chapter? || @chapter.only_non_draft_chapter?
            flash[:error] = t(".only_chapter")
            redirect_to(edit_work_path(@work))
            return
      Severity: Minor
      Found in app/controllers/chapters_controller.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