gitlabhq/gitlab-ci

View on GitHub

Showing 58 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                elif line.startswith("UNIQUE KEY \""):
                    index_name      = line.split('"')[1].split('"')[0]
                    index_columns   = line.split("(")[1].split(")")[0]
                    index_lines.append("CREATE UNIQUE INDEX \"%s\" ON %s (%s)" % (index_name, current_table, index_columns))
                    drop_index_lines.append("DROP INDEX IF EXISTS \"%s\"" % index_name)
    Severity: Major
    Found in lib/support/mysql-postgresql-converter/db_converter.py and 1 other location - About 5 hrs to fix
    lib/support/mysql-postgresql-converter/db_converter.py on lines 195..199

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 93.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

                elif line.startswith("KEY \""):
                    index_name      = line.split('"')[1].split('"')[0]
                    index_columns   = line.split("(")[1].split(")")[0]
                    index_lines.append("CREATE INDEX \"%s\" ON %s (%s)" % (index_name, current_table, index_columns))
                    drop_index_lines.append("DROP INDEX IF EXISTS \"%s\"" % index_name)
    Severity: Major
    Found in lib/support/mysql-postgresql-converter/db_converter.py and 1 other location - About 5 hrs to fix
    lib/support/mysql-postgresql-converter/db_converter.py on lines 187..191

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 93.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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 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 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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      elif line.startswith("KEY"):
                          index_columns = line.split("(")[1].split(")")[0]
                          index_lines.append("CREATE INDEX ON %s (%s)" % (current_table, index_columns))
          Severity: Major
          Found in lib/support/mysql-postgresql-converter/db_converter.py and 1 other location - About 1 hr to fix
          lib/support/mysql-postgresql-converter/db_converter.py on lines 192..194

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 48.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      elif line.startswith("UNIQUE KEY"):
                          index_columns   = line.split("(")[1].split(")")[0]
                          index_lines.append("CREATE UNIQUE INDEX ON %s (%s)" % (current_table, index_columns))
          Severity: Major
          Found in lib/support/mysql-postgresql-converter/db_converter.py and 1 other location - About 1 hr to fix
          lib/support/mysql-postgresql-converter/db_converter.py on lines 200..202

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 48.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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 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 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_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
                Severity
                Category
                Status
                Source
                Language