redmine/redmine

View on GitHub
app/controllers/repositories_controller.rb

Summary

Maintainability
D
2 days
Test Coverage

File repositories_controller.rb has 344 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'digest/sha1'
require 'redmine/scm/adapters'

class ChangesetNotFound < StandardError; end
class InvalidRevisionParam < StandardError; end
Severity: Minor
Found in app/controllers/repositories_controller.rb - About 4 hrs to fix

    Class RepositoriesController has 32 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class RepositoriesController < ApplicationController
      menu_item :repository
      menu_item :settings, :only => [:new, :create, :edit, :update, :destroy, :committers]
      default_search_scope :changesets
    
    
    Severity: Minor
    Found in app/controllers/repositories_controller.rb - About 4 hrs to fix

      Method diff has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

        def diff
          if params[:format] == 'diff'
            @diff = @repository.diff(@path, @rev, @rev_to)
            (show_error_not_found; return) unless @diff
            filename = +"changeset_r#{@rev}"
      Severity: Minor
      Found in app/controllers/repositories_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 entry_and_raw has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

        def entry_and_raw(is_raw)
          @entry = @repository.entry(@path, @rev)
          (show_error_not_found; return) unless @entry
      
          # If the entry is a dir, show the browser
      Severity: Minor
      Found in app/controllers/repositories_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 find_project_repository has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        def find_project_repository
          @project = Project.find(params[:id])
          if params[:repository_id].present?
            @repository = @project.repositories.find_by_identifier_param(params[:repository_id])
          else
      Severity: Minor
      Found in app/controllers/repositories_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 show has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def show
          @repository.fetch_changesets if @project.active? && Setting.autofetch_changesets? && @path.empty?
      
          @entries = @repository.entries(@path, @rev)
          @changeset = @repository.find_changeset_by_name(@rev)
      Severity: Minor
      Found in app/controllers/repositories_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 diff has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def diff
          if params[:format] == 'diff'
            @diff = @repository.diff(@path, @rev, @rev_to)
            (show_error_not_found; return) unless @diff
            filename = +"changeset_r#{@rev}"
      Severity: Minor
      Found in app/controllers/repositories_controller.rb - About 1 hr to fix

        Method add_related_issue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def add_related_issue
            issue_id = params[:issue_id].to_s.delete_prefix('#')
            @issue = @changeset.find_referenced_issue_by_id(issue_id)
            if @issue && (!@issue.visible? || @changeset.issues.include?(@issue))
              @issue = nil
        Severity: Minor
        Found in app/controllers/repositories_controller.rb - About 25 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