gitlabhq/gitlabhq

View on GitHub
app/models/ci/build.rb

Summary

Maintainability
F
4 days
Test Coverage

Class Build has 121 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Build < Ci::Processable
    include Ci::Metadatable
    include Ci::Contextable
    include TokenAuthenticatable
    include AfterCommitQueue
Severity: Major
Found in app/models/ci/build.rb - About 2 days to fix

    File build.rb has 792 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Ci
      class Build < Ci::Processable
        include Ci::Metadatable
        include Ci::Contextable
        include TokenAuthenticatable
    Severity: Major
    Found in app/models/ci/build.rb - About 1 day to fix

      Method persisted_environment_variables has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def persisted_environment_variables
            Gitlab::Ci::Variables::Collection.new.tap do |variables|
              break variables unless persisted? && persisted_environment.present?
      
              variables.concat(persisted_environment.predefined_variables)
      Severity: Minor
      Found in app/models/ci/build.rb - About 35 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 job_jwt_variables has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def job_jwt_variables
            Gitlab::Ci::Variables::Collection.new.tap do |variables|
              break variables unless Feature.enabled?(:ci_job_jwt, project, default_enabled: true)
      
              jwt = Gitlab::Ci::Jwt.for_build(self)
      Severity: Minor
      Found in app/models/ci/build.rb - About 35 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 expanded_environment_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def expanded_environment_name
            return unless has_environment?
      
            strong_memoize(:expanded_environment_name) do
              # We're using a persisted expanded environment name in order to avoid
      Severity: Minor
      Found in app/models/ci/build.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