haru/redmine_code_review

View on GitHub
app/controllers/code_review_controller.rb

Summary

Maintainability
F
4 days
Test Coverage

Method new has a Cognitive Complexity of 95 (exceeds 5 allowed). Consider refactoring.
Open

  def new
    begin
      CodeReview.transaction {
        @review = CodeReview.new
        @review.issue = Issue.new
Severity: Minor
Found in app/controllers/code_review_controller.rb - About 1 day 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 31 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    @review = CodeReview.find(params[:review_id].to_i) unless params[:review_id].blank?
    @repository = @review.repository if @review
    @assignment = CodeReviewAssignment.find(params[:assignment_id].to_i) unless params[:assignment_id].blank?
    @repository_id = @assignment.repository_identifier if @assignment
Severity: Minor
Found in app/controllers/code_review_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

File code_review_controller.rb has 329 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class CodeReviewController < ApplicationController  
  before_action :find_project, :authorize, :find_user, :find_setting, :find_repository, :find_priorities

  helper :sort
  include SortHelper
Severity: Minor
Found in app/controllers/code_review_controller.rb - About 3 hrs to fix

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

      def update_diff_view
        @show_review_id = params[:review_id].to_i unless params[:review_id].blank?
        @show_review = CodeReview.find(@show_review_id) if @show_review_id
        @review = CodeReview.new
        @rev = params[:rev] unless params[:rev].blank?
    Severity: Minor
    Found in app/controllers/code_review_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 assign has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

      def assign
        code = {}
        code[:action_type] = params[:action_type] unless params[:action_type].blank?
        code[:rev] = params[:rev] unless params[:rev].blank?
        code[:rev_to] = params[:rev_to] unless params[:rev_to].blank?
    Severity: Minor
    Found in app/controllers/code_review_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 new has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def new
        begin
          CodeReview.transaction {
            @review = CodeReview.new
            @review.issue = Issue.new
    Severity: Major
    Found in app/controllers/code_review_controller.rb - About 3 hrs to fix

      Method update_diff_view has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def update_diff_view
          @show_review_id = params[:review_id].to_i unless params[:review_id].blank?
          @show_review = CodeReview.find(@show_review_id) if @show_review_id
          @review = CodeReview.new
          @rev = params[:rev] unless params[:rev].blank?
      Severity: Minor
      Found in app/controllers/code_review_controller.rb - About 1 hr to fix

        Method show has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def show
            @review = CodeReview.find(params[:review_id].to_i) unless params[:review_id].blank?
            @repository = @review.repository if @review
            @assignment = CodeReviewAssignment.find(params[:assignment_id].to_i) unless params[:assignment_id].blank?
            @repository_id = @assignment.repository_identifier if @assignment
        Severity: Minor
        Found in app/controllers/code_review_controller.rb - About 1 hr to fix

          There are no issues that match your filters.

          Category
          Status