gitlabhq/gitlabhq

View on GitHub
app/models/commit.rb

Summary

Maintainability
D
2 days
Test Coverage

Class Commit has 69 methods (exceeds 20 allowed). Consider refactoring.
Open

class Commit
  extend ActiveModel::Naming
  extend Gitlab::Cache::RequestCache

  include ActiveModel::Conversion
Severity: Major
Found in app/models/commit.rb - About 1 day to fix

    File commit.rb has 367 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Commit
      extend ActiveModel::Naming
      extend Gitlab::Cache::RequestCache
    
      include ActiveModel::Conversion
    Severity: Minor
    Found in app/models/commit.rb - About 4 hrs to fix

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

          def order_by(collection:, order_by:, sort:)
            return collection unless %w[email name commits].include?(order_by)
            return collection unless %w[asc desc].include?(sort)
      
            collection.sort do |a, b|
      Severity: Minor
      Found in app/models/commit.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 uri_type has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def uri_type(path)
          entry = @raw.tree_entry(path)
          return unless entry
      
          if entry[:type] == :blob
      Severity: Minor
      Found in app/models/commit.rb - About 45 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