redmine/redmine

View on GitHub
app/models/repository.rb

Summary

Maintainability
D
2 days
Test Coverage

Class Repository has 61 methods (exceeds 20 allowed). Consider refactoring.
Open

class Repository < ApplicationRecord
  include Redmine::Ciphering
  include Redmine::SafeAttributes

  # Maximum length for repository identifiers
Severity: Major
Found in app/models/repository.rb - About 1 day to fix

    File repository.rb has 391 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class ScmFetchError < StandardError; end
    
    class Repository < ApplicationRecord
      include Redmine::Ciphering
      include Redmine::SafeAttributes
    Severity: Minor
    Found in app/models/repository.rb - About 5 hrs to fix

      Method committer_ids= has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        def committer_ids=(h)
          if h.is_a?(Hash)
            committers.each do |committer, user_id|
              new_user_id = h[committer]
              if new_user_id && (new_user_id.to_i != user_id.to_i)
      Severity: Minor
      Found in app/models/repository.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_committer_user has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

        def find_committer_user(committer)
          unless committer.blank?
            @found_committer_users ||= {}
            return @found_committer_users[committer] if @found_committer_users.has_key?(committer)
      
      
      Severity: Minor
      Found in app/models/repository.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 stats_by_author has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def stats_by_author
          commits = Changeset.where("repository_id = ?", id).
                      select("committer, user_id, count(*) as count").group("committer, user_id")
          # TODO: restore ordering ; this line probably never worked
          # commits.to_a.sort! {|x, y| x.last <=> y.last}
      Severity: Minor
      Found in app/models/repository.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