haru/redmine_code_review

View on GitHub

Showing 30 of 30 total issues

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 controller_issues_new_after_save has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

      def controller_issues_new_after_save(context = {})
        if context[:request] && context[:project] && context[:issue]
          project = context[:project]
          request = context[:request]
          parameters = request.parameters
    Severity: Minor
    Found in lib/code_review_issue_hooks.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

    Class AutoAssignSettings has 28 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class AutoAssignSettings
        def initialize(yml_string = nil)
          yml_string = {:enabled => false}.to_yaml if yml_string.blank?
          load_yml(yml_string)
        end
    Severity: Minor
    Found in lib/code_review_auto_assign_settings.rb - About 3 hrs to fix

      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

        File code_review.js has 298 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*
        # Code Review plugin for Redmine
        # Copyright (C) 2009-2023  Haruyuki Iida
        #
        # This program is free software; you can redistribute it and/or
        Severity: Minor
        Found in assets/javascripts/code_review.js - About 3 hrs to fix

          Class CodeReview has 25 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class CodeReview < ActiveRecord::Base
            include Redmine::SafeAttributes
            belongs_to :project
            belongs_to :change
            belongs_to :issue
          Severity: Minor
          Found in app/models/code_review.rb - About 2 hrs to fix

            Function setAddReviewButton has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

            function setAddReviewButton(url, change_id, image_tag, is_readonly, is_diff, attachment_id) {
              var filetables = [];
              var j = 0;
              $('table').each(function () {
                if ($(this).hasClass('filecontent')) {
            Severity: Minor
            Found in assets/javascripts/code_review.js - 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 view_issues_form_details_bottom has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

              def view_issues_form_details_bottom(context = {})
                project = context[:project]
                request = context[:request]
                parameters = request.parameters
                code = parameters[:code]
            Severity: Minor
            Found in lib/code_review_issue_hooks.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

            Function setAddReviewButton has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function setAddReviewButton(url, change_id, image_tag, is_readonly, is_diff, attachment_id) {
              var filetables = [];
              var j = 0;
              $('table').each(function () {
                if ($(this).hasClass('filecontent')) {
            Severity: Minor
            Found in assets/javascripts/code_review.js - About 2 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 create_assignment_info has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                Open

                  def create_assignment_info(project, assignment)
                    repository_id = assignment.repository_identifier
                    o = '<tr>'
                    o << "<td><b>#{l(:review_assigned_for)}:</b></td>"
                    o << '<td colspan="3">'
                Severity: Minor
                Found in lib/code_review_issue_hooks.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 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

                  Method get_mail_addresses has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def get_mail_addresses(review)
                      mail_addresses = []
                      review.root.users_for_notification.each { |u|
                        mail_addresses << u.mail
                      }
                  Severity: Minor
                  Found in app/models/review_mailer.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 review_auto_assign has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def review_auto_assign
                      return unless CodeReviewAssignment.where(:changeset_id => changeset.id).all.length == 0
                      return unless changeset.repository
                      return unless changeset.repository.project
                      setting = CodeReviewProjectSetting.find_or_create(changeset.repository.project)
                  Severity: Minor
                  Found in lib/code_review_change_patch.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 path has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def path
                      begin
                        return file_path if file_path
                        return @path if @path
                        if attachment_id
                  Severity: Minor
                  Found in app/models/code_review.rb - About 55 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 scan_comment_for_issue_ids has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def scan_comment_for_issue_ids
                      ret = super
                      project = repository.project if repository
                      return ret unless project
                      return ret unless project.module_enabled?('code_review')
                  Severity: Minor
                  Found in lib/code_review_changeset_patch.rb - About 55 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

                  Severity
                  Category
                  Status
                  Source
                  Language