gitlabhq/gitlab-ci

View on GitHub

Showing 44 of 58 total issues

Function parse has a Cognitive Complexity of 93 (exceeds 5 allowed). Consider refactoring.
Open

def parse(input_filename, output_filename, drop_index_filename):
    "Feed it a file, and it'll output a fixed one"

    # State storage
    if input_filename == "-":
Severity: Minor
Found in lib/support/mysql-postgresql-converter/db_converter.py - About 1 day 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

Class Converter has 65 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Converter
    def on_0(s) reset()                            end
    def on_1(s) enable(STYLE_SWITCHES[:bold])      end
    def on_3(s) enable(STYLE_SWITCHES[:italic])    end
    def on_4(s) enable(STYLE_SWITCHES[:underline]) end
Severity: Major
Found in lib/ansi2html.rb - About 1 day to fix

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

    class Commit < ActiveRecord::Base
      belongs_to :project
      has_many :builds, dependent: :destroy
      has_many :trigger_requests, dependent: :destroy
    
    
    Severity: Minor
    Found in app/models/commit.rb - About 4 hrs to fix

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

      class Build < ActiveRecord::Base
        LAZY_ATTRIBUTES = ['trace']
      
        belongs_to :commit
        belongs_to :project
      Severity: Minor
      Found in app/models/build.rb - About 3 hrs to fix

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

        class Project < ActiveRecord::Base
          include ProjectStatus
        
          has_many :commits, ->() { order('CASE WHEN commits.committed_at IS NULL THEN 0 ELSE 1 END', :committed_at, :id) }, dependent: :destroy
          has_many :builds, through: :commits, dependent: :destroy
        Severity: Minor
        Found in app/models/project.rb - About 2 hrs to fix

          Method nav_link has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

            def nav_link(options = {}, &block)
              if path = options.delete(:path)
                if path.respond_to?(:each)
                  c = path.map { |p| p.split('#').first }
                  a = path.map { |p| p.split('#').last }
          Severity: Minor
          Found in app/helpers/application_helper.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 remove_old has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def remove_old
                # delete backups
                $progress.print "Deleting old backups ... "
                keep_time = GitlabCi.config.backup.keep_time.to_i
          
          
          Severity: Minor
          Found in lib/backup/manager.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 process? has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

            def process?(only_params, except_params, ref, tag)
              return true if only_params.nil? && except_params.nil?
          
              if only_params
                return true if tag && only_params.include?("tags")
          Severity: Minor
          Found in lib/gitlab_ci_yaml_processor.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 validate_job! has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

            def validate_job!(name, job)
              job.keys.each do |key|
                unless ALLOWED_JOB_KEYS.include? key
                  raise ValidationError, "#{name}: unknown parameter #{key}"
                end
          Severity: Minor
          Found in lib/gitlab_ci_yaml_processor.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 handle_sequence has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def handle_sequence(s)
                indicator = s[1]
                commands = s[2].split ';'
                terminator = s[3]
          
          
          Severity: Minor
          Found in lib/ansi2html.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 <=> has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            def <=>(other)
              return unless other.is_a? VersionInfo
              return unless valid? && other.valid?
          
              if other.major < @major
          Severity: Minor
          Found in lib/version_info.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 execute has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def execute(project, params)
              before_sha = params[:before]
              sha = params[:checkout_sha] || params[:after]
              origin_ref = params[:ref]
              
          Severity: Minor
          Found in app/services/create_commit_service.rb - About 1 hr to fix

            Function parse has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def parse(input_filename, output_filename, drop_index_filename):
                "Feed it a file, and it'll output a fixed one"
            
                # State storage
                if input_filename == "-":
            Severity: Minor
            Found in lib/support/mysql-postgresql-converter/db_converter.py - About 1 hr to fix

              Method unpack has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def unpack
                    Dir.chdir(GitlabCi.config.backup.path)
              
                    # check for existing backups in the backup dir
                    file_list = Dir.glob("*_gitlab_ci_backup.tar").each.map { |f| f.split(/_/).first.to_i }
              Severity: Minor
              Found in lib/backup/manager.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 validate! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                def validate!
                  unless validate_array_of_strings(@before_script)
                    raise ValidationError, "before_script should be an array of strings"
                  end
              
              
              Severity: Minor
              Found in lib/gitlab_ci_yaml_processor.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 validate_job! has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def validate_job!(name, job)
                  job.keys.each do |key|
                    unless ALLOWED_JOB_KEYS.include? key
                      raise ValidationError, "#{name}: unknown parameter #{key}"
                    end
              Severity: Minor
              Found in lib/gitlab_ci_yaml_processor.rb - About 1 hr to fix

                Method unpack has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def unpack
                      Dir.chdir(GitlabCi.config.backup.path)
                
                      # check for existing backups in the backup dir
                      file_list = Dir.glob("*_gitlab_ci_backup.tar").each.map { |f| f.split(/_/).first.to_i }
                Severity: Minor
                Found in lib/backup/manager.rb - About 1 hr to fix

                  Method convert_to_postgresql has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def convert_to_postgresql
                        mysql_dump_gz = db_file_name + '.mysql'
                        psql_dump_gz = db_file_name + '.psql'
                        drop_indexes_sql = File.join(db_dir, 'drop_indexes.sql')
                  
                  
                  Severity: Minor
                  Found in lib/backup/database.rb - About 1 hr to fix

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

                      def attachments
                        fields = []
                    
                        if commit.matrix?
                          commit.builds_without_retry.each do |build|
                    Severity: Minor
                    Found in app/models/project_services/slack_message.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 can_execute? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      def can_execute?(build)
                        return if build.allow_failure?
                    
                        commit = build.commit
                        return unless commit
                    Severity: Minor
                    Found in app/models/project_services/slack_service.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

                    Severity
                    Category
                    Status
                    Source
                    Language