gitlabhq/gitlabhq

View on GitHub
app/models/project.rb

Summary

Maintainability
F
1 wk
Test Coverage

Class Project has 257 methods (exceeds 20 allowed). Consider refactoring.
Open

class Project < ActiveRecord::Base
  include Gitlab::ConfigHelper
  include Gitlab::ShellAdapter
  include Gitlab::VisibilityLevel
  include AccessRequestable
Severity: Major
Found in app/models/project.rb - About 5 days to fix

    File project.rb has 1658 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'carrierwave/orm/activerecord'
    
    class Project < ActiveRecord::Base
      include Gitlab::ConfigHelper
      include Gitlab::ShellAdapter
    Severity: Major
    Found in app/models/project.rb - About 4 days to fix

      Method check_repository_path_availability has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def check_repository_path_availability
          return true if skip_disk_validation
          return false unless repository_storage
      
          # Check if repository with same path already exists on disk we can
      Severity: Minor
      Found in app/models/project.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 protected_for? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def protected_for?(ref)
          raise Repository::AmbiguousRefError if repository.ambiguous_ref?(ref)
      
          resolved_ref = repository.expand_ref(ref) || ref
          return false unless Gitlab::Git.tag_ref?(resolved_ref) || Gitlab::Git.branch_ref?(resolved_ref)
      Severity: Minor
      Found in app/models/project.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

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

        def handle_update_attribute_error(ex, value)
          if ex.message.start_with?('Failed to replace')
            if value.respond_to?(:each)
              invalid = value.detect(&:invalid?)
      
      
      Severity: Minor
      Found in app/models/project.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

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

        def container_registry_variables
          Gitlab::Ci::Variables::Collection.new.tap do |variables|
            break variables unless Gitlab.config.registry.enabled
      
            variables.append(key: 'CI_REGISTRY', value: Gitlab.config.registry.host_port)
      Severity: Minor
      Found in app/models/project.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